This came up in a discussion with a friend, and I found myself hard-pressed to think up an any good arguments. What benefits do weak typing confer?
The problem with this kind of discussion is simply that the terms "weak typing" and "strong typing" are undefined, unlike for example the terms "static typing", "dynamic typing", "explicit typing", "implicit typing", "duck typing", "structural typing" or "nominal typing". Heck, even the terms "manifest typing" and "latent typing", which are still open areas of research and discussion are probably better defined.
So, until your friend provides a definition of the term "weak typing" that is stable enough to serve as the basis of a discussion, it doesn't even make sense to answer this question.
Unfortunately, apart from Nick's answer, nobody of the answerers bothered to provide their definition either, and you can see the confusion that generates in some of the comments. It's hard to tell, since nobody actually provides their definitions, but I think I count at least three different ones, just on this very page.
Some of the more commonly used definitions are (and yes, I know that pretty much none of them makes any sense, but those are the definitions I've seen people actually use):
The three definitions that seem to be used most widely, however, are
Unless everybody agrees on a definition of what "weak typing" even is, it doesn't even make sense to think about what its advantages might be. Advantages of what? Even worse, if there is no definition at all, then everybody can just shift their definitions to fit their arguments, and every discussion is pretty much guaranteed to devolve into a flamewar.
I myself have personally changed my own definition several times over the years and have now reached the point where I don't even consider the terms useful any more. I also used to think that weak typing (in its various definitions) has a place in shell scripting, but whenever I have to solve the same problem in Bash and PowerShell, I am painfully reminded how wrong I was.
Remember there are two major concepts that are commonly confused:
The advantages here are often dismissed as just for "new" programmers, but can also be convenient for any programmer:
Less code in any case where you'd otherwise have to cast or assign a new value:
Loose or weak typing
Both definitions are from http://en.wikipedia.org/wiki/Type_system. It said it better than I could.
The main argument for weak typing is one of performance. (this is to answer the OPs question as stated). There's a lot of good discussion about dynamic vs. static, implicit vs. explicit. etc.
C is the most famous weakly typed language, and it does not perform any run time checking or compile time checking of the variables type. In essence you can cast a
C programming is pretty close to the way you would do things with assembly, so there are times where you only care about an address. It's not uncommon to cast or pass a
While run-time type checking doesn't have an extraordinary bit of overhead, there are times when it is just enough to cause a critical section to be too slow. I'm thinking mostly about embedded programming and real time systems in this case.
That said, in most cases having a strong type system that is either compile time checked or runtime checked helps more often than it hurts.
Good article on the subject: Strong typing vs Strong testing
How much does it cost for a month to hire average developer? Probably around $2000-$10000 /month.
State of the art server = $50-$100/month. So who cares if the code will run slower when you will be able to write much more in much less time?
Strong typing is incompatible with rapid changes and tight schedules.
You should get on the web sometimes :) SQL, JS, PHP, XML, HTML, perl... all weak typing.
Besides... checking the typing, freeing objects, etc? That's monkey coding - and to be honest you need that only on the clientside, when you write some big app used by thousands of people. Otherwise... let the compiler do this for you. And you can always code some very small part in C when you need speed...
protected by gnat Jan 2 at 15:31
Thank you for your interest in this question.
Because it has attracted low-quality answers, posting an answer now requires 10 reputation on this site.
Would you like to answer one of these unanswered questions instead?