6

There are a lot of discussions all over the internet and on SO, i.e. here and here, about static vs dynamic languages.

I'm not going to ask again about one vs another. Instead, my question is for those who moved (or at least tried to move) from static typed language to dynamic.

I'm not talking about moderate usage of JS on your web page or other scripting language embedded into statically typed software or small personal scripts. I mean moving to dynamic language as your primary general purpose language for developing production quality software in team.

Was that easy? What was the biggest advantage and the biggest challenge? Was it fun? :)

UPD: Did you find IDE support good enough? Did you find that you need less IDE support?

Community
  • 1
  • 1
Pavel Feldman
  • 4,621
  • 7
  • 30
  • 31
  • Which language are you moving from? A well designed one or... something that makes you write your types all over the place, again and again? – MichaelGG Feb 24 '09 at 20:47
  • I currently use Java and considering moving to Groovy. I got some concerns about using it in team, but that probably should be another question. – Pavel Feldman Feb 24 '09 at 20:54
  • @MichaelGG, what do you mean by that? When do you repeat types? Even in PHP you have classes. – Dan Rosenstark Feb 25 '09 at 01:01
  • @Pavel, have you considered Scala? – MichaelGG Feb 25 '09 at 04:07
  • @Daniel, I mean that you have to explicitly type every single variable, everywhere. Even when it's completely obvious and redundant. Better design allows the types to be inferred for the most part, making static typing far easier. – MichaelGG Feb 25 '09 at 04:07
  • I haven't tried Scala yet, but I'm going to, thanks. – Pavel Feldman Feb 26 '09 at 01:00
  • @MichaelGG, what languages do this, for example? You mean the annoying repition of this in PHP or self in Ruby? Or something different. – Dan Rosenstark Feb 28 '09 at 06:02
  • I think he means ArrayList arr = new ArrayList(); while compiler can perfectly get all needed information from var arr = new ArrayList(); – Pavel Feldman Feb 28 '09 at 11:39
  • @Daniel, yes, as Pavel says. Java, C#, etc. are terribly verbose because they don't infer. Since he said he's coming from a static checked language, I assumed not Ruby :). – MichaelGG Mar 01 '09 at 04:29

5 Answers5

10

Was that easy?

Moderately. Some Java-isms are hard habits to break. My first six months, I wrote Python with ;'s. Icky. Once I was over it, though, I haven't looked back.

What was the biggest advantage?

Moving from the "write -> compile -> build -> run -> break -> debug -> write" cycle to a "write -> run -> break -> write" cycle. It takes time to get used to immediate gratification from the Python command-line interpreter. I was soooo used to endless design and planning before attempting to write (much less compile) any code.

At first I considered the python command line to be a kind of "education-only" interface. Then reading docstrings, doctests, and user guides where the application is being typed at the >>> prompt, I started to realize that the truly great Python software boils complexity and nuance down to stuff you can type interactively.

[I wish I could design stuff that worked that cleanly.]

What was the biggest challenge?

Multiple inheritance. I use it very rarely.

Was it fun?

So far.

It's also amazingly productive. More time with user requirements and real data. Less time planning an inheritance hierarchy with proper interfaces to capture meaning and compile correctly and be extensible enough to last at least to the next revision.

S.Lott
  • 384,516
  • 81
  • 508
  • 779
  • How did you get over not having to type everything? I tend to dabble in Python every 6 months or so and think "how elegant!" but then I feel comforted by the (relative) type-safety of C when I switch back. – Andrew Keeton Feb 24 '09 at 23:48
  • Python is very strongly typed. Very. There's never any mystery or confusion about what type is used where. A formal variable declaration isn't really all that helpful. – S.Lott Feb 25 '09 at 01:29
5

If I were you, I would try Scala!!!.

Scala has some aspects really interesting that lets you feel like doing dynamic, while doing static.

  • Scala is a statically typed language with dynamic typed smell, because the compiler makes you less repetitive inferring your assignments.

  • A compiled language with a warm and wonderful script flavor.Cause you can use the scala console, or even write scripts just like ruby or python. So you can choose between "write -> compile -> build -> run -> break -> debug -> write" or "write -> run -> break -> write" as S.Lott said.

  • Scala is a complete Functional language with full support for OO. So you don't lose many important OO aspects like inheritance, encapsulation, polymorphism, etc.

Why answering you questions suggesting Scala? Because I tryed script languages before, and the main was Ruby. And it was just like S.Lott said. But not so easy for me and my team. Most of time static is safe, less error prone, and even faster if you have the right language.

Answering you three questions putting Scala inside we have:

Was that easy?

Yes. Sometimes you need to concentrate to leave you old concepts aside and go deep.

What was the biggest advantage?

You feel in home cause you don't need to change you environment or rewrite existing applications to migrate to Scala (talking about Java). If you come from Java, you can start playing with Scala after reading some articles. Not too much effort. Another important advantage is the use of a functional language en its embedded power.

Was it fun?

Sure! Changing your mind, changing your way to solve problems to the best is for sure funny.

This is my vision. You don't exactly need to leave off static to grab the advantage of dynamic.

paulosuzart
  • 1,082
  • 2
  • 13
  • 28
2

Nice question.

I am now working in Ruby, PHP and ActionScript (the least dynamic of the three) instead of languages that I would prefer, like Java and C#. But beggars, I mean, workers in this economy, can't be choosers. Or rather, you have to choose your battles and your master.

It's hard to compare Ruby and Java because they've got more than one difference, and you only asked about the dynamic/static thing (and not even about the strongly vs. weakly-typed thing!). But on that front, what affects me most is always the IDE. I was always horrified when other Java programmers used Notepad or Textpad to write code, and nowadays there are just too many advantages of a good IDE for that madness. Not true with Ruby! I use Netbeans and it does really well, but one of the main differences is that I have to actually type code. Autocomplete, for me, was/is a way of life (I write SMS messages in full English/Spanish with the predictive dictionary, for instance, and never use abbreviations) and writing Ruby code does require more work.

So at first it was painful and I was constantly looking at, for instance, function names of classes that I had written (or that are part of Ruby) just to get the spelling right! So that sucked, I thought, and I continued to think that until...

I moved back to ActionScript the other day, and to get my IDE autocompleting (FlashDevelop or FlexBuilder) I declare all variables with types (strongly-typed by choice, if you will)... and suddenly I thought what a friggin' hassle!

And then today I had to do some feature additions on a Ruby project and it felt free and cool. The code is clean, and why would I be informing the IDE of what I'm trying to write anyway?

So I would say that 1) the biggest challenges are learning the language and the framework you're working in, like always 2) it's been amazingly fun and deeply eye-opening. New languages always carry new things with them, but dynamic languages just feel different. And that's just the kind of thing that gets you to wake up at 7am and do some coding on a Sunday morning before falling asleep again.

I like programming and like most of you, I've spent some time with stored procedures, XSL, static, dynamic, whatever... it's all fun, and they all feel totally different. In the end, the framework you are working in will be the thing that will convince you too stay or not (if you have a choice), I think, but languages are to learned, studied and experienced, not compared.

Dan Rosenstark
  • 68,471
  • 58
  • 283
  • 421
  • >I was always horrified when other Java programmers used Notepad or Textpad to write code. Sooo true for me. Should add this to question. – Pavel Feldman Feb 24 '09 at 23:56
1

I can't qualify myself fully under that handle but I did spend a while writing some an interesting Python mini-game after having spent many years writing Java. So, I might be mixing a little bit of moving from compiled to interpreted along with it.

I found myself using notation to mimic static typing. :)

However, I did find myself cranking code out at a slightly better clip. Having an interpreter is a godsend as far as learning new language/writing new code. The shorter the time between finishing a line of code and seeing it work, the faster you can write, and I think that is probably the best thing most dynamic and interpreted languages.

My code didn't look too different, all things considered. Though, Python has a lot of fun data structures. :)

Drew
  • 15,158
  • 17
  • 68
  • 77
1

I'm also interested in this topic. Tried do dive into Ruby and Rails a while ago, and it really helped me to grasp the ASP.Net MVC stuff, which i think is a bit too chalenging at first for average .net developer.

If you're interested more on moving in this direction, or curious about how some developers moved from static to dynamic languages as their full time jobs, i highly recommend this Alt.Net podcast.

ljubomir
  • 1,495
  • 1
  • 21
  • 40