JAOO 2007: Bob Martin and Chad Fowler - Debating Static versus Dynamic Typing

Download this episode

Download Video

Description

I recently got the chance to attend JAOO in Aarhus, Denmark. Besides learning a great amount about various approaches to solving hard problems that we all face as programmers (regardless of the stack we spend most of our time developing on), I got to meet so many interesting people from all walks of programmer life. What a great conference! For one thing, JAOO is not about specific products. It's not about one company's view of the world. It's not about one class of technologies or developer. It's not just about Java and LAMP or .NET and Windows...


Bob Martin
is the CEO and founder of Object Mentor. He's also an incredible speaker and very passionate about creating "clean", precise, beautiful code. You've seen him on C9 before.

Chad Fowler is CTO of InfoEther, Inc. Chad has been a software developer and manager for some of the world's largest corporations. He is co-founder of Ruby Central, Inc., the non-profit corporation responsible for the annual International Ruby and Rails Conferences, and is a leading contributor in the Ruby community. Clearly, Chad is a dynamic typing kind of guy.

I thought it would be fun to have a little debate centered around the theme of static versus dynamic typing, especially given how popular dynamic language are these days. It was my hope that at the end of the debate it would be made clear what the differences really are and why some prefer dynamic and others static typing. Of course, as developers, we use the right tool for the job, but it's fun to geek out on these types of discussions and we delve into many more related topics. 

Tune in and learn.

Embed

Format

Available formats for this video:

Actual format may change based on video formats available and browser capability.

    The Discussion

    • User profile image
      Chadk

      They say that hieracy isnt how the world works. I dont think it could be further away from the truth.

      Look at our social structure. The way we interact with each other.

      How isnt this hieracy?

    • User profile image
      Johannes
      This is a very interesting video, I'm surprised it hasn't spawned more comments. I feel the 2 most important "unanswered" questions/issues raised were the "IDE" and the "ease of messing up your code" ones.

      I agree that there seems to be a dynamic revolution going on right now and that it would be stupid not to follow the development of the dynamic languages closely. So static-type developers keep you minds open to this development.

      Given the content of the videos I've seen so far from JAOO I'm very sorry I couldn't come to the conference. I'm definately gonna go next year. Can't wait! Smiley
    • User profile image
      Charles
      Johannes wrote:
      This is a very interesting video, I'm surprised it hasn't spawned more comments. I feel the 2 most important "unanswered" questions/issues raised were the "IDE" and the "ease of messing up your code" ones.

      I agree that there seems to be a dynamic revolution going on right now and that it would be stupid not to follow the development of the dynamic languages closely. So static-type developers keep you minds open to this development.

      Given the content of the videos I've seen so far from JAOO I'm very sorry I couldn't come to the conference. I'm definately gonna go next year. Can't wait!


      I only posted this a few hours ago Smiley I expect some good discourse to come from this in time.

      Yes, please do attend JAOO 2008. JAOO is one of the best programming conferences I've ever been to and I can't recommend it highly enough. I hope to be there next year as well!
    • User profile image
      Chadk
      Im also gonna be trying real hard to make it next year. Awesome it is.
    • User profile image
      Balclutha

      Firstly, one point people rarely make when comparing static to dynamic typing is that sometimes problems are about classification. For example, lexical analysis and parsing work well with guards and union types found in OCAML, ML and Haskell; some programs fit naturally into a type system. Static, or otherwise, types matter, and if you get them wrong your program will break.


      Secondly, I think much of the excitement around Ruby in particular, and dynamic languages in general, is due to the fact that many people equate dynamic languages with REPLs (Read Eval Print Loops). Those whose first encounter with a REPL was via a statically typed language such as ML are less likely to be head-over-heels in love with dynamically typed languages. Dynamic typing != immediate feedback. Static typing != C-like syntax.


    • User profile image
      JChung2006
      REPL is the thing I miss most in VB.  Bring it back please, Microsoft.
    • User profile image
      TimP

      I thought it was interesting how dismissive they were of LINQ and functional programming additions to C# 3.0, since they're highly touted around here.

    • User profile image
      Charles
      TimP wrote:
      

      I thought it was interesting how dismissive they were of LINQ and functional programming additions to C# 3.0, since they're highly touted around here.



      Well, keep in mind that they are heavy into dynamic languages and mostly just not very interested in the evolution of static ones (changes to languages and runtimes they don't use)...

      Make no mistake; the addition of functional constructs into static languages (which enable language innovations like LINQ and .NET libraries like ParallelFX...) is a very good thing for developers who use them.

      C
    • User profile image
      staceyw
      hmm.  Lets see, marginal Intellisense, marginal method signature guesses, no good IDE, (no windows dev?), slower, no compile time checks for many cases...  So why is it good again?

      Charles, I am not a Ruby guy either (yet) and you asked a good question.  What kind of apps are being developed today with Ruby and shipping?  Windows apps, Server apps, web page scripting?  I mean I love PowerShell (and Ksh before), but I will not dev a Win app or srv app with it for all the reasons above.  Scripts and tying things together is nice.  Personally, I don't feel the static nature of c# is hard - I find the compiler helps me a great deal to find many classes of bugs very early in the cycle.  I have been through the VB variant type years ago and I don't want to go back to that.
    • User profile image
      JChung2006
      staceyw wrote:
      I have been through the VB variant type years ago and I don't want to go back to that.

      They are not advocating going back to that; I recall their comments about C being a weakly typed language and how that was not a good thing.  The dynamic languages that they evangelize are strongly typed.

    • User profile image
      raymond
      Outstanding video.

      Uncle Bob's remarks regarding "static typing is a failed strategy" and his final comment the real stuff and the relevant stuff is happening in the Ruby community calls out for a reply by Anders. Wink

      A very interesting happy accident video. Smiley


      Cool
    • User profile image
      tomkirbygre​en
      I love the recent focus on core issue in languages design and trends and the JA00 videos have been the best of the bunch. I've had them looping in the background at work so I can get on with mundane stuff and allow these conflicting ideas to just 'wash over' me. Kudos Charles for bring us this stuff.
    • User profile image
      spookware
      I simply must disagree about performance not being an issue anymore. It seems dishonest the way that argument is put form. Perf does not exist in isolation.  Just because people think performance is good enough does not mean performance does not matter even for stuff like desktop applications. Why? Because all though perf may "feel" fine perf and power are intimately related, and people are starting to care a whole lot about power use.

      Remember the faster your code runs the sooner the CPU(s) can go back to sleep. The smaller your working set gets you get fewer trickle writes to the hard drive as you dirty pages. Fewer trickle writes mean longer periods with the disk spun down. Better socket coding stratatagies can allow the wireles NIC to enter a lower power state more often. etc....

      So please stop thinking every computer is a server where the CPU is allways underutilized and there is no power management. Laptop sales are the leading growth driver for the PC industry so until all computers stop running on batteries then perf still matters.


    • User profile image
      JChung2006

      Charles, I'm surprised that you didn't mention that Chad was one of the authors of the "Pickaxe" book.

      Programming Ruby: The Pragmatic Programmer's Guide

    • User profile image
      punkouter

      I'm pretty much a beginner on this dynamic language thing. My background mainly is from assembly, C/C++, Java and C#, all the static typing languages. While, I do have a bit experience with Hashkell in my university years, I haven't put much effort on learning it (it's just for a class project, mainly using lists and functional programming). So my questions are maybe a bit newbie-ish, bear with me.

      Ruby has been a buzz for quite a while for now and it's come to my attention to learn it. However, I still couldn't grasp the 'feeling' on using Ruby.

      1. Is it like using the C++ Template mechanism? Like when you could just place a template T and call like T.something() but the type inferring is done in runtime as oppose to C++ compile time?

      2. Isn't that going to be pretty hard to track down the source of problems when it happens? I had a terribly awful experience with hunting these kind of bugs when one of my programmer puts everything as objects in a Map class and he accidentally put an object of a different type in the map. How do you hunt those kind of bugs in Ruby? Do we have to keep checking the object type lwith 'is-a' mechanism? That would be awful and it wouldn't show me where the bug does actually occur. So, maybe the question is, how to debug or how debuggable is Ruby (and other Dynamic Languages also). My experiences with javascripts which I think is a kind of DL has taught me that DL is hard to debug. It also taught me to always strongly typed things to shield me from these kind of mistakes which i often call 'stupid mistakes'. Am I wrong?

      3. From the architect perspectives, in particular Design Patterns, is it applicable in DL? Will it streamlines patterns? For instance if Im using the Strategy patterns, then I do not need to declare an abstract base class. In the video, you discussed this. But isn't that bad? I mean, I can throw anything to my 'engine' any object that have a 'process()' function althought that might mean very different. The Strategy pattern will most likely lose its meaning.

      4. Can I draw/architect appropriate/sane softwares out of it? It seems like Class diagrams is also losing its meanings. And without a map, I cant picture how my software will turn out to be. How can you assess bugs?

      5. How can I restrict/restrain my inexperienced and clumsy programmers from doing some stupid mistakes? In statically typed world, I can restrict them by strongly typing everything and mking sure they play by my rules. How do you implement that kind of leash on them?

      I still have doubts about DL. And I have to confess that right now I cant picture building a large software using DL. If I cant get off my head from the 'stupid mistakes' how can I possibly focus on 'clever mistakes'? In other words, if I cant asses that the lower layers, the basic things will run fine, how can I build something reliable on top of it? My picture of DL right now is like building a building on sand.

      This is still my preliminary opinion though, I dont really have professional experiences on any DL and I still need to learn about it.

      Anyway thanks for the video, and sorry for the long post

    • User profile image
      esoteric
      Half-way through there's already been some simplifications, albeit for the sake of the audience. A couple of points...

      First; statically typed languages don't have to always have types expressed explicitly, that's where type-inference comes into play, both in C# 3 and F#. That's one benefit of dynamically typed languages taken away.

      Second; polymorphism may be restricted to use explicit (intensional) subtyping in C#, but there's also the concept of structural subtyping. I've encountered this in the excellent little language haXe, which has this concept of static compatibility. There is no need for explicit relationships, it just checks for "accidental" compatibility of signatures. That's a great feature. In fact it goes perfect together with object literals.

      In some cases, one may want to force intensional contracts, and then one can use explicit class and type inheritance. As a static feature, that does not support dynamic incidental compatibility, but it also doesn't break dynamically for a lack of such compatibility.

      It's one of the best JAOO videos on channel 9 though (also liked Gilad Bracha's somewhat). Too bad there aren't any actual presentation videos here.
    • User profile image
      Minh
    • User profile image
      Charles
      I'm not doing anything differently... Not sure what to tell you.
    • User profile image
      Minh
      Charles wrote:
      I'm not doing anything differently... Not sure what to tell you.

      It'd appear that videos coming from

         wm.microsoft.com

      cannot be seen by me, WMPlayer or Silverlight, whereas videos coming from

         mschnlnine.wmod.llnwd.net

      work just fine.
    • User profile image
      staceyw
      Minh wrote:


      Same thing here.  The server issue would seem to make sense as to why I get it and sometimes (after restarting IE) it does not happen.  I assume DNS client is sometimes getting 1 server over the other in round robin order.  So the server seems to be issue...
    • User profile image
      Charles
      Minh wrote:
      
      Charles wrote:
      I'm not doing anything differently... Not sure what to tell you.

      It'd appear that videos coming from

         wm.microsoft.com

      cannot be seen by me, WMPlayer or Silverlight, whereas videos coming from

         mschnlnine.wmod.llnwd.net

      work just fine.


      What happens when you click on the Full Screen button?
    • User profile image
      Charles

      It seems as though the MS streaming cluster is having problems... Not sure when this will be resolved.

      C

    • User profile image
      dcook

      I'm pretty sure that the answer (as usual) is: use the right tool for the job. Sure, that's kind of avoiding the question, but I am pretty certain that there are places where assembly is better than Ruby. Rare, but they exist. And I'm pretty sure there are places where Ruby is better than C#. Rare (I'm a C# zealot!), but I think they might exist. Tongue Out

      I'm glad they argued both sides, though. There really are two sides to the issue, and understanding both points of view makes it possible to make an informed decision.

      Just to be clear that this isn't an argument between strong versus weak typing (weak typing is often defined as "an object doesn't have a strong notion of its own type" or "everything is implicitly castable to anything else"): I can hardly think of any times when I really want weak typing. Maybe when intoducing my mom to programming, but that's about it. Luckily for the scripting languages, most of them use strong typing, so this isn't really an argument. It's an argument about static (a variable has a notion of the type of object it holds) versus dynamic (a variable can hold an object of any type).

      The argument about achieving polymorphism via inheritance is an interesting one, though I think that is not strictly an issue of static versus dynamic typing - it's more of an argument between type identification (interface versus duck) and inheritance models. Not all dynamically typed languages support duck typing. I suppose it could be considtered as an optional layer of dynamic typing, though some static languages have some aspects of this as well, just a bit more explicit.

      The weaknesses of polymorphism via inheritance are somewhat well known, which is one of the reasons why Interfaces seem to be growing in popularity over base classes. Interfaces avoid some of the problems raised. Single-base-class, multiple-interface inheritance models (like the CLR's) reflect this.

      To some degree, the distinction between static and dynamic typing isn't entirely clear. For example, you can do dynamic typing in many "statically typed" languages. C# has an object type, and you can use the Invoke APIs to perform dynamic name-based dispatch. All that is missing is syntactic sugar to make the dispatch look pretty.

      In any case, I like the structure of static typing. I find it lets the compiler enforce the rules that I want to follow anyway. I don't want those rules enforced by discipline or unit tests when they can be enforced by the compiler.

      I do like C# 3.0's var keyword, because it lets the compiler do some of the work for me while keeping almost all of the rule enforcement.

      For large, complex programs where you want as much error checking done up front, I think static typing makes sense. For small, quick programs, dynamic typing might be better.

      But that's just me. For everybody else, I suggest doing what works best for your situation. Play around with both kinds of programs and see what works for you and your team.

    Comments closed

    Comments have been closed since this content was published more than 30 days ago, but if you'd like to send us feedback you can Contact Us.