| «« Urgent My Foot! | Coke vs Coffee »» |
|
About
I'm Ryan Lowe, a Software Engineering graduate living in Ottawa, Canada. I like agile software development and Ruby on Rails.
I write this blog in Canadian English and don't use a spell checker. Typos happen.
Projects
» Full-time Ruby on Rails freelancer
» Full-time with Rails since May 2005 » Former committer for RadRails (now Aptana) » I also have a few Rails side-projects in development: 1. wheretogoinTO.com Toronto nightlife 2. Hey Heads Up! TODO list and sharing 3. Layered Genealogy family history research 4. foos for foosball scoring 5. fanconcert for music fans (on hold) Hiring Rails developers? I can telecommute by the hour from Ottawa, Canada »» Email: rails AT ryanlowe DOT ca
BulletBlog
Now hosted on Hey! Heads Up -- check it out!
Syndication
Pings
Recent
blog@ryanlowe.ca no more
Forging Email Headers: Good, Bad or Ugly? Sarcastic Dictionary (Part 1 of Many) Tags Hierarchies Twisting Rails is Risky Business Risky Business? My Take on Early Alphas Whoa, it's August 2007 Closing Comments A Postscript to "Growth at the grassroots" An Abuse Trifecta »» All Blog Posts
Linkage
del.icio.us/ryanlowe
technorati/ryanlowe.ca/blog Aurora Roy Jim Andrew Trasker Travis Kibbee Karen Dr. Unk Ayana Van Bloggers Joel Spolsky Robert Scoble Tim Bray Dave Winer Raymond Chen James Robertson Ruby/Rails Bloggers rubyonrails.org weblog David Heinemeier Hansson Dave Thomas James Duncan Davidson Mike Clark Jamis Buck Signal vs. Noise Tobias Luetke Amy Hoy: (24)slash7 Jeremy Voorhis Eclipse Bloggers Planet Eclipse EclipseZone Luis de la Rosa Eclipse Foundation Kim Horne Billy Biggs Ian Skerrett Mike Milinkovich Bjorn Freeman-Benson Denis Roy
Archives
|
Strong vs Weak Typing
As someone that has used strongly typed programming languages for most of his short career, I'm finding it hard to grasp the advantages of weakly-typed ones. Paul Vick makes a good point when he says that generics make strongly typed languages even stronger, and this seems to go straight against the new wave of weakly typed languages like Python and older ones like Smalltalk. It seems somewhat related to the enabling vs. directing thread that was going around recently. Strongly typed languages direct you down an inflexible path: you may only assign a value of type A to a variable of type A or one of its superclasses or interfaces. Once you do that it may be painful to change the type later in the code because you have to edit all of the types. Weakly typed languages enable agile processes where a value's type may change often and variables don't have type. Good unit testing with weakly typed languages prevents programmers from making mistakes with types. Refactoring support in IDEs like Eclipse digs into this advantage of weak typing though. If I can change the strong type of a variable everywhere in the code with one action then isn't this the same difficulty as changing a weak type except now I have a more rigid type contract? If the tools enable the same type flexibility as weakly typed languages wouldn't a strongly typed language be better? Maybe I need a few examples. I haven't seen the light yet. Update 7:30 PM as James Robertson points out I'm way off base here. That'll teach me for thinking out loud. :) I won't correct my post though -- it's already been linked to. Yep, I really meant to ask: what is the advantage of dynamic typing over declarative typing? Posted at March 27, 2004 at 03:50 PM ESTLast updated March 27, 2004 at 03:50 PM EST Comments
Ryan, Python and Smalltalk are strongly, dynamically typed languaged - if you call a method on an object which doesn't implement that method, you get a specific behaviour (which is usually to raise an exception). In C, a weakly typed language, if you try and dereference a null pointer, all you get is a segmentation fault. » Posted by: Giovanni Corriga at March 27, 2004 07:07 PMOK, so I'm mistaking what strong and weak types are. I'm actually referring to dynamic and static typing then. What are the advantages of dynamically typed languages? » Posted by: Ryan at March 27, 2004 07:27 PMThe best way to learn about the benefits of a dynamically typed programming language is to play with one! You might check out MzScheme or Squeak (implementations of Scheme and Smalltalk-80, respectively). Programming in those languages is a totally different experience than programming in a statically typed language like Java or C#. Some people find it easier to learn (and teach) dynamic languages because precisely because they lack a strong definition of "type". For people new to computer science, types can be a really hard concept to grasp. Dynamic languages don't require you to care about type as a formal concept unless you want to, so you're free to focus on more fundamental concepts (iteration, recursion, procedural abstraction) without getting into the nebulous and confusing world of types. » Posted by: Steve at March 27, 2004 08:25 PMI'm kind of comfortable with types. It might be hard to get out of that paradigm ... but I'll try. :) » Posted by: Ryan at March 27, 2004 09:19 PM"The Computer Science and Engineering Handbook" at least provides some consistent terminology; so we can talk about static-type-checking and dynamic-type-checking, explicit types and implicit types, and languages that are type-safe and those that aren't. http://citeseer.ist.psu.edu/cardelli97type.html » Posted by: Isaac Gouy at March 27, 2004 09:58 PM |