Monday, 8 July 2013

Dynamic/Static typing, a single observation

It is fair to say I have written more lines of code in statically typed rather than dynamically type ones.

This is in part due to my day job and also having written a fair amount of Java in my spare time. It is also fair to say I have written a reasonable amount of code in dynamically typed languages. Primarily in CoffeeScript and Python with some JavaScript and other less popular languages (read as Lisp).

At home I tend to flip between the two every six months or so and dream of a languages the lets me add type information when I start to need it. That is as the code base grow bigger.

Well bigger is a bit of a subjective word. With my most recent return to dynamically typed languages I have observed that the definition of bigger can be put of by being really intolerant to bad or messy code. Constantly asking myself things like "is this a simple as can be?" or "can I improve this code?" and then acting on it really helps.

Statically typed languages lets you get a way with a little bit more, because the compiler can capture some of the errors for you and the better IDE tools let you manage it better.

I would say coding in a dynamically typed language helps my statically typed programming just because it reminds to to focus on simplicity, not adding complexity if not needed and on having an interface that can be guessed (consistency is very important here).

I am currently taking a look at Typescript, it adds a statically typed layer to JavaScript. You don't have to use the typing a the start meaning you can start to add types when you need to. Well it adds a whole lot more like classes and modules but the statically type part is the attractive bit.

No comments:

Post a Comment