Syntax can be hard to learn. Although I have trouble reading lisp / clojure / haskell, I respect that for those who understand it is a simple pleasure to write code in.
The problem, as highlighted is not limited to computer languages. Often people who try to learn another language from English continually say “but why do they do it like that? English does it better.” Unfortunately, learning your first language (eg. mother tongue) is vastly different in approach from learning your second and third.
Many times learning the second is the hardest – why is this? You have to open up your cemented neural pathways to the idea that something can be expressed in a foreign way. Unlocking those pathways is hard, as it is like fighting an inertia you have had for a long time.
I learned Spanish, then French. After that I find my ability to learn languages is vastly easier. Why? Because I understand the concepts of tenses, gender, case, mood and respect the subtleties of each language.
I no longer learn concepts, I learn the implementations and the nuances of each language. The same now for most programming languages. In a language, I need to express conditionality. I need collections and looping, filtering
and transforming. I don’t need to learn these concepts again so I can pick up languages quicker and quicker as I learn more concepts.
I now see a trend towards less shared-state/synchronised realtime applications and a strengthening towards functional (map/reducible) programming and languages supporting shared-nothing and actor patterns. The interesting thing is that we used to think by sharing state an synchronising it was faster and more scalable than copying objects and using more memory. Now it is more scalable to do exactly that.
We now have the programming power, the memory and the disk space for almost anything – we are now stripping back our programming languages to make it ‘easier’ for us to write code. By easier I don’t mean we are writing simpler code. As Ola Bini points out in his blog programmers are wanting a higher level of expressiveness. To do this, we have to make some assumptions like we are not going to share and synchronise data/state everywhere in our application. Sure, it may happen on the database or in a 3rd party library like an aggregator, but we as expressive functional programmers don’t want the bother of covering all those horrid edge cases which are hard to debug and harder to reproduce. I’ve seen some shocking issues with ThreadLocal being used and abused. Which happens alot.
In my own code I have found issues where I have overridden variables or options to my own detriment. Each time thinking ‘if only I had put that into another (usually local) variable. I believe this is the biggest (current) pitfall in Java. It is too easy to modify the contents of objects from any library which has access to it. It almost sounds like a security flaw. It’s calling out saying “hey, you there. You want to use me somewhere else? Don’t clone me, oh no. Just change my state a bit. It’s alright. Surely.”. No.
I am finishing a book on Beginning Scala at the moment, which sounds interesting but mostly just copying the good things in Ruby and cramming it into Java-esque syntax. For these languages it is more important to learn the ‘idoms’ of the language, which is what should give you more expressiveness.
Ruby has alot of this. I am awed that this language was created over 15 years ago. It is a beautiful and expressive language. It reminds me of going from Windows background and learning Linux. You can do some really powerful stuff,
and you can really get yourself into trouble (metaclass?). Guard the gates of expressiveness and you will be treated with a powerful tool.
My next blog post will talk about JRuby in detail.