One might be wondering why I'm reading a book on Java if I'm already well acquainted with a large variety of programming languages. I'm merely refreshing my knowledge on Java, and getting up-to-date, because I'm starting as a fulltime Java developer on monday.
I've worked as a python developer for the past 7.5 months, and mainly as a C++ developer for a very long time before that. So why Java?
Let me for now dodge that question and discuss the very relevant issue of typing, dynamic vs static, and my now-biggest frustration that I don't understand why I can't have both in one language. (yes, I know, Common Lisp supports both, but let's ignore that at the moment, because it does have issues)
Considering I have experience working in both worlds, I think I'm in a good position to judge, and the simple fact is: I need both.
On the one hand, static typing is just overhead, just documentation. On the other hand, it really helps when you need it, and you need it more and more later in a project's life when your thoughts on the subject have settled and you have a firm grip on the problem domain.
Static typing is not about abstracting, it is about documenting and constraining data for both the programmer and the compiler alike. In fact, it is much easier to write very abstract code in a dynamically typed language, but it is so much easier to understand statically typed code, again for both the programmer and the compiler alike. A compiler can make many decisions at compile time, and hence produce very optimal (byte)code. It can also tell you about any contradictions between the code you've written and the typing information you supplied, helping you to prevent bugs. The programmer has an easier time understanding where what data is coming from and where the hell it's going.
Hence, for 'understandability' for the programmer, a dynamically typed language needs more verbose documentation. Unfortunately, a compiler can't do much with that kind of documentation, which is also the reason why most dynamically typed languages barely 'compile', and are mostly 'interpreted'
Note that there is a language that does a very good job at giving you the best of both worlds, boo, but I wouldn't call it production-ready just yet.
Wednesday, March 12, 2008
java? wtf? or also, static vs dynamic typing.
Labels:
boo,
dynamic typing,
java,
python,
static typing
Subscribe to:
Post Comments (Atom)

No comments:
Post a Comment