Post #101,358
5/11/03 9:54:41 PM
|
Quotes from Uncle Bob
I've been a statically typed bigot for quite a few years. I learned my lesson the hard way while using C. Too many systems crashed in the field due to silly typing errors. When C++ came out, I was an avid adopter, and rabid enforcer of strong typing. Emphasis mine. C++ static typing was a good thing as compared to C, because C sucked so bad at it. About two years ago I noticed something. I was depending less and less on the type system for safety. My unit tests were preventing me from making type errors. The more I depended upon the unit tests, the less I depended upon the type safety of Java or C++ (my languages of choice).
I thought an experiment was in order. So I tried writing some applications in Python, and then Ruby (well known dynamically typed languages). I was not entirely surprised when I found that type issues simply never arose. My unit tests kept my code on the straight and narrow. I simply didn't need the static type checking that I had depended upon for so many years. Emphasis mine. Gee. Big surprise. What have we been arguing about with Mr. Burns here? :-)
Regards,
-scott anderson
"Welcome to Rivendell, Mr. Anderson..."
|
Post #101,361
5/11/03 10:23:42 PM
|
Maybe it's just me...
but I'm really scratching my head at the huge fuss made over static/dynamic typed languages.
Since the languages we're talking about are OO, shouldn't any properly designed system (imo) be setup so that for the programmer they don't have to worry about the type of the language?
Example: In Java, if I get back an SQL object, I don't have to know the type (Integer, Float, ect) to shove it back to the client, just call the getString() on it and the object will handle it for me.
(note: I'll admit that Java and C++ both fail at this - mostly because they were derived from C, which have primitive datatypes and is statically typed. But in both cases, what they've added in, their new stuff, is set up so that the programmer really doesn't have to worry about the type.)
Frankly, the further and further I get into OO, I'm beginning to see that primitive datatypes are a bad idea. They're a pain in the neck, get in the way and cause problems.
|
Post #101,384
5/12/03 3:34:37 AM
5/12/03 4:05:02 AM
|
Static languages make the code brittle ...
and a pain in the neck to write. You end up writing a lot of code just to satisfy the compiler. It also locks everything in making it very hard to evolve the system. Paul Graham expresses it really well [link|http://www.paulgraham.com/hp.html|Hackers and Painters]
"A programming language is for thinking of programs, not for expressing programs you've already thought of. It should be a pencil, not a pen. Static typing would be a fine idea if people actually did write programs the way they taught me to in college. But that's not how any of the hackers I know write programs. We need a language that lets us scribble and smudge and smear, not a language where you have to sit with a teacup of types balanced on your knee and make polite conversation with a strict old aunt of a compiler."
Edited by bluke
May 12, 2003, 04:05:02 AM EDT
|
Post #102,707
5/20/03 4:09:02 AM
|
History revisionism - beware !!! (IMHO)
The true issue over why Java (Strong typing) became popular over weakly typed languages was that it was the *only* way security would work for connected code over the Internet as it was 3-5 years ago. The 'sandbox' security of Java enabled objects to be 'tightly' validated for type whereas Smalltalk et al would merely pass an object that *could be* tampered with in transit (does not understand).
This is a different issue to compile time awareness of an object's type.
VPNs are elimnating the need for validating objects (using strong typing) over WANs.
Weakly typed languages are a damned site more flexible and have more to offer in the long term in terms of coding and testing.
Cheers
Doug Marker
|
Post #102,818
5/20/03 3:08:49 PM
|
Re: History revisionism - beware !!! (IMHO)
dmarker: The true issue over why Java (Strong typing) became popular over weakly typed languages was that it was the *only* way security would work for connected code over the Internet as it was 3-5 years ago. [...]
I'm not sure that is entirely correct. Glenn Vandenburg writes (see link below) that at the time of Java's introduction, there were several competing "safe code" models for mobile code. All used very different security models and only one (Java) was strongly typed.
[link|http://www.vanderburg.org/cgi-bin/glv/blosxom/2003/05/17#Software/Languages/static_vs_dynamic|http://www.vanderbur...static_vs_dynamic]
Unfortunately Glenn gives very little details about any of them.
-- -- Jim Weirich jweirich@one.net [link|http://w3.one.net/~jweirich|http://w3.one.net/~jweirich] --------------------------------------------------------------------- "Beware of bugs in the above code; I have only proved it correct, not tried it." -- Donald Knuth (in a memo to Peter van Emde Boas)
|
Post #102,849
5/20/03 6:50:22 PM
|
Another issue was the potential popularity of a lang
>> When Java first hit the streets, mobile code was a hot topic. General Magic was promoting their Magic Cap environment, featuring mobile code ("agents") heavily, and powered by a language called Telescript. Nathaniel Borenstein was researching "active mail", sending active invitations and the like via email using a dialect of Tcl called Safe-Tcl. Someone (I can't remember who at the moment) was developing roughly equivalent functionality in Perl (the Safe.pm module). Luca Cardelli at DEC was developing a beautiful and novel little language called Obliq.
All of those languages supported secure mobile code, and all of them used very different security models. My memory of Telescript is fuzzy, but I know for a fact that Java is the only one of the rest that is statically typed. And I remember from my evaluation at the time that Java and Telescript had the two most complex security models (and complexity is not a good thing in a security model). <<
The above extract from the link points out some other work that was being done but one also needs to take into account the political dynamics of the day ...
- MS was creaming the market & competition with its classic tactics
- IBM decided to get behind Sun's Java (Oak) as a counterbalance to MS propaganda about DCOM (and DCOM & Active-X's inherent weakness for net use)
- Smalltalk was there but had completely failed to garner popular support. This went beyond the effort of the various ST tool vendors
- Java won because it was so familiar to the multitudes of C & C++ programmers. Java was very shallow when it 1st came out (effectively in ver 1.0.3). Over 5 years, Sun IBM HP & others developed the bulk of what is J2SE & J2EE today. That Java has many flaws didn't stop it carving out an empire that tipped MS temporarily on its ear. MS had to go back to the drawing board & invent .NET & C#
- The other languages that were or were about to enter the scene had no substantial backers that would enable them to do any better than Smalltalk in garnering market share, some appear to have been still borns.
What ST vs Java taught me was that elegance (ST) does not dictate victory. Also I believe there is much confusion (due to time passing) over the issue of Java's strong typing. It was the strong typing and thus tiny code packets that enabled Java's applet concept to work well over WANS & appear secure (just a pity that MS succeeded in poisoning Applets with their 'dirty' Java VM back in MSIE 2 & 3.
Cheers
Doug Marker
|
Post #102,938
5/21/03 10:13:13 AM
|
Re: Another issue was the potential popularity of a lang
dmarker: The true issue over why Java (Strong typing) became popular over weakly typed languages was that it was the *only* way security would work for connected code over the Internet as it was 3-5 years ago.
dmarker: Java won because it was so familiar to the multitudes of C & C++ programmers. [...] The other languages [...] had no substantial backers
I wouldn't disagree with your second statement. Java was definitely a strongly marketed language[1]. And I wouldn't disagree that the perception that strong typing is necessary for secure mobile code had some (small) effect. However, I'm not sure that the first statement is accurate as stated, especially with the emphasis on the word "only".
Footnotes: [1] I recently flipped through a first generation Java book on my bookshelf. I had forgotten how much of the book was just propaganda (and inaccurate at that!) without much technical content.
-- -- Jim Weirich jweirich@one.net [link|http://onestepback.org|http://onestepback.org] --------------------------------------------------------------------- "Beware of bugs in the above code; I have only proved it correct, not tried it." -- Donald Knuth (in a memo to Peter van Emde Boas)
|
Post #101,465
5/12/03 1:14:44 PM
|
Gee...I thought it was a friendly discussion...
... the kind that might be helped by a brew or two... ;-)
Actually, I have found the same things. However, I don't think (just yet) that unit testing is the antithesis of strong typing...or that one obviates the other. Especially, when you're writing code in a team environment (read: several different levels of expertise), where someone wants to use (or, nor often, abuse) your base class for something it wasn't exactly designed to do (like compare Strings to Locomotives).
StrongTyping != evil for all values of StrongTyping (or evil, for that matter)....
jb4 "We continue to live in a world where all our know-how is locked into binary files in an unknown format. If our documents are our corporate memory, Microsoft still has us all condemned to Alzheimer's." Simon Phipps, SUN Microsystems
|
Post #101,524
5/12/03 6:07:43 PM
|
Re: Gee...I thought it was a friendly discussion...
jb4 StrongTyping != evil for all values of StrongTyping
Actually, I like to use the term Manifest typing rather than strong or static typing. Some static, but non-manifest typing systems (such as the one in Haskel) looks rather promising.
There's a lot of confusion regarding static, strong, weak, dynamic (etc.) typing. Here's my general definitions ...
Strong: No type errors can happen unnoticed. Weak: Type errors can happen unnoticed. Static: The type of an object can be determine at compile time. Dynamic: The type of an object cannot (in general) be known at compile time. Manifest: Every variable must be explicitly declared.
Ruby, Python, Smalltalk and brethern are have Strong, Dynamic, non-manifest typing.
Haskel has Strong, static non-manifest typing.
Eiffel has Strong, Static and Manifest typing.
Java has Strong, Static, Manifest typing, with a tendency to use dynamic typing in collections (and therefore suffers from the drawbacks of both manifest and dynamic typing).
C is also manifest and static, but with a lot of weak type holes (where you can accidently circumvent the type system).
C++ has manifest static typing and has closed many of the accidental type holes in C, but still allows the programmer to delibrately circumvent the type system.
FORTH would be dynamic, non-manifest and VERY weakly typed.
Perl is a tough one. One one hand, I would expect it to be similar to Python or Ruby. But if you consider the types in Perl to be scaler, list and hash, then Perl would have static and manifest typing.
There's a good article on strong typing at [link|http://perl.plover.com/yak/typing/|http://perl.plover.com/yak/typing/].
Have fun.
-- -- Jim Weirich jweirich@one.net [link|http://w3.one.net/~jweirich|http://w3.one.net/~jweirich] --------------------------------------------------------------------- "Beware of bugs in the above code; I have only proved it correct, not tried it." -- Donald Knuth (in a memo to Peter van Emde Boas)
|
Post #101,527
5/12/03 6:24:18 PM
|
Manifest typing....a la Fortran.
I remember Fortran 4 (Lincoln Pre-processor)... every damn spelling mistake became a variable.
|
Post #101,688
5/13/03 1:57:41 PM
|
Thanks, Jim. Nicely put.
jb4 "We continue to live in a world where all our know-how is locked into binary files in an unknown format. If our documents are our corporate memory, Microsoft still has us all condemned to Alzheimer's." Simon Phipps, SUN Microsystems
|
Post #103,183
5/22/03 7:59:50 PM
|
Re: Ditto - Thanks, Jim.
|
Post #101,783
5/14/03 3:24:33 AM
|
Next experiment: try it without OO
________________ oop.ismad.com
|