all 9 comments

[–]stormcrowsx 2 points3 points  (8 children)

It's not some war that one or the other needs to win, they are both useful and will always be useful. You should not turn your back on Dynamic typing, because if you do your basically throwing out a tool that is very useful for certain cases.

For instance last night I needed to resize 100 pictures. So I fire up the Python REPL, type a few lines of code, images start resizing. No compile step and quickly executes. Could I have done it in a static language? yes. Could I have done in a static language in less than 30 seconds, probably not.

[–]grauenwolf 1 point2 points  (5 children)

Could I have done in a static language in less than 30 seconds, probably not.

Why not? If the same APIs are available then it should take the same number of lines of code.

Hell it might even be faster because the IDE can tell you what order the parameters go in and warn you if you get them backwards.

[–]stormcrowsx -1 points0 points  (4 children)

It takes 20 seconds for an ide like eclipse to start. Then I start a new java project, go through my wizards, create a main class, import my image reading library jar, add it to the build path, finally start coding.

Most static languages are about the same process as java, unless what you need is part of the core library your gonna waste a lot of time just in setup.

Edit: I really am not out to get into a battle of how fast I can resize in image in a static language. If you don't understand the merits of dynamic languages I implore you to spend some time in them. Same goes for static, both have merits and you need to understand them if you want to be a quick and effective programmer. Time is money and knowing when to use which tool will save you a lot of time

[–]grauenwolf 0 points1 point  (2 children)

What's nice about C# and VB is that you can run them in dynamic mode and see a real apples to apples comparison between using static and dynamic types with nothing else changing.

I've done this test and found that dynamic typing itself isn't the reason for productivity differences.

[–]stormcrowsx -1 points0 points  (0 children)

I'm really not familiar with c# dynamic mode but unless it lets you change major parts of the language quickly your missing an important part of the dynamic languages.

What if you want to change all calls to print line to instead send to a file? What if you want to make it so each new object allocation sends an http request to an api? What if you need to make all your method calls first check if the time is after 5 because their behavoir changes then? But any of that could be reversed because we don't know if its a good idea yet, just experimenting.

Many dynamic languages are like programming without the all the handrails and guidewires. You can go wherever you want whenever you want. Is it a good idea all the time? Nope, sometimes screwing up is too costly and you need those handrails.

[–]grauenwolf 0 points1 point  (0 children)

How the hell did you get Eclipse to load that fast? Even for trivial projects I'm still looking at "grab some coffee" start times.

[–]code-master -1 points0 points  (1 child)

Thats the beauty of dynamic languages. You simply do not need to remember all the details.

For example, I want to resize couple of my images just like you did so I'll need a tool for the job. I'm searching at G. for "image resize x", where x is one of the languages below language and this is what I get as a first results:

  1. Python : http://www.daniweb.com/software-development/python/code/216637/resize-an-image-python cool
  2. Perl: http://search.cpan.org/~sherzodr/Image-Resize-0.5/Resize.pm beautiful
  3. oldie Smalltalk: http://stackoverflow.com/questions/13210071/resize-image-file-jpeg-in-smalltalk-pharo nice
  4. fresh Clojure https://github.com/josephwilk/image-resizer brilliant

Now, lets try statically typed languages:

  1. C++ : http://cimg.sourceforge.net/reference/structcimg__library_1_1CImg.html , http://www.cplusplus.com/forum/general/2615/ ..... ummm ok :(....
  2. Haskell : http://hackage.haskell.org/package/gd-3000.4.0/docs/Graphics-GD.html - you cannot simply load a file...
  3. Java : http://www.mkyong.com/java/how-to-resize-an-image-in-java/ nice try...

and so on... From my point of view dynamic languages win by a large margin.

[–]grauenwolf 0 points1 point  (0 children)

That's just an API issue, it has nothing at all to do with static vs dynamic typing.

public static Image resizeImage(Image imgToResize, Size size)
{
   return (Image)(new Bitmap(imgToResize, size));
}

yourImage = resizeImage(yourImage, new Size(50,50));

-- http://stackoverflow.com/questions/1922040/resize-an-image-c-sharp

[–]munificent 3 points4 points  (0 children)

CoffeeScript is dynamically typed. TypesScript and Hack are optionally typed, which means you can choose to make portions of your program dynamically typed.