Programming languages

I guess the most important topic for a software developer is what programming languages should you learn. I've been reading hackernews/reddit/quora/stack overflow and many people upvote an utter worthless garbage answers like "there's no end all be all language, all are good at something". I'm so sick of hearing this nonsense, and you will certainly not be hearing it from me today.

I myself certainly will not pick just about any language by random to do a project because I don't think all are equal. Some are dreadful, some are meh, some are strong and bring delight and joy. So, I'll tell of a story of what languages do I know somewhat proficiently and could just start coding a project with it if I wanted to:

  • Pascal
  • Java
  • C/C++
  • C#
  • Groovy
  • Go
  • Rust
  • Lua
  • OCaml
  • Ruby
  • Scala
  • Clojure
  • Lisp
  • Visual Basic
  • Javascript
  • Bash
  • Prolog
  • Python

For some of them I may not know frameworks/tools and etc. but if there was a project and I needed to make a change I wouldn't have tough problems going into appropriate place and changing something.

That being said, I don't consider any of them equal. And I certainly don't consider that "some language is really good at something that other's do not". For instance, as far as I'm concerned, C++ is good for nothing as of 2018. Maybe good for people making business of building static analysis tools detecting segfaults, but, once Rust got into shape it made C++ obsolete. Yet some poor souls who do not wish to learn a better way try to criticize Rust and to justify C++, saying:

  • "Oh, we can have many programmers who know C++ but not so for Rust"
  • "It doesn't have as many libraries"
  • "C++ has to maintain backwards compatibility, thus why can't do so and so"

But this is pathetic reasoning. Neither amount of developers who know the language, neither count of it's libraries, neither excuse of why some better way cannot be implemented because we'll break existing clients say anything about a quality of a language.

You see, just the very fact that Rust was born to replace C++, and the fact that Mozilla developers said "C++ is not cutting it - we need a new language" that in itself should be an indication that this language will be done better in every aspect than C++ was. These native hackers that were tormented year after year of the C++ beast decided to make everything better, where their heart was hurting - they fixed it.

    Just a few points where Rust is better than C++ all around:
  • No segfault native code performance
  • Nice package manager
  • Macros better and more sophisticated all around
  • Simpler syntax in many cases
  • Move by default

I will not go on forever comparing languages, because a book could be written which languages were invented and what problems they addressed.

I will go through a short story of the stuff I tried, I said it was not good enough, and moved to something else.

My very first language was Pascal, we started it in school, I hated it because I couldn't simply declare variables at the time they were actually needed - everything had to be defined before you use it in a block (I don't know if this is still true at the time of this writing and I don't care). Then I came to university. C++ for me was much better because you could define variables where you need them. After that, I've learned Java in university, now there's garbage collection and a nice IDE with JVM and so much standard library at my disposal. That seemed amazing at the time. Then, I went to my first work, a big company that had a policy which grieved me - just about always using Microsoft products and stack. My heart was dreading when I worked with windows, because I've been using linux at home and I had to deal with this unstable/crashing beast at work. There I've learned C#/C++/Visual Basic and bunch of worthless to me stuff that comes with Visual Studio. Also, I've learned scala on my own, read the Odersky's book and was very impressed - reading file in scala was one line of code instead of java's try catch abomination without apache commons library. Then I've came across an article advocating for lisp (I cannot remember how I got there now, but that is a great read) and decided I want to do clojure (because it's related to lisp). At first I seemed much better off, doing a few projects, having repl, etc. but I started to hate debugging it. There was no compilation, refactoring is horrible in dynamic language, and it encouraged me leaving old code behind because anything can break (and I did not want to write many tests to know code is correct, because then you also have to refactor bunch of tests with the code). Sure, I'm open for clojure, but I guess I'd love code to just compile and work. Also, I learned Rust, great language to get most out of CPU, maybe not for just doing quick and productive everyday work without ownership semantics getting in your way. Then I've came to the pinnacle of my learning as of today when I've discovered OCaml.

    So, in short, after my entire journey I've concluded that OCaml gives me:
  • Greatest productivity
  • Least pain
  • Predictability
  • Performance (although single threaded)
  • Low memory footprint
    To put someone in who doesn't know OCaml in perspective I'll compare it with Java:
  • Types are completely inferred most of the time, unlike in Java, where you need to specify each variable's type explicitly
  • Java added local type inference at version 10, in 2018, after more than two decades its first release of 1995.
  • There are no null pointer exception anywhere.
  • If field of a struct is a string - there must be a valid string there. You will never get a banana or a donkey or a zebra in that field and never have to worry about using it. If you don't instantiate every field in a struct that is a compiler error - not silent nulls waiting to screw you over in the worst time possible.
  • Minimal syntax - programs are much shorter than java, at the very least 3 times I'd say (feel free to watch the whole talk)
  • Fast executable startup
  • Much lower memory usage, similar to unix tools
  • Recently I found out it has a reverse debugger (VERY VERY few projects have this, it's huge)
  • Transpiles to javascript (typesafe code in frontend and backend)

Most of my new projects I work on at my spare time I start with OCaml because I don't see anything better as of today at 2018.

Now, sure, some might skip through this list and say, meh, sounds boring, I'll keep my java. And I understand that, java is clearly a wrong choice, but I understand it's hard to impress people with words. That's why I'll say - just try it. I've also heard a saying "if it compiles it usually works" bunch of times but I never felt that power before I tried OCaml. So, I urge you, the reader, to make something with OCaml, maybe a website, maybe a command line tool, just look for an excuse to use it in your project - you will not be disappointed my friend.

Oh, and for windows folks out there, I really think you should use linux, it teaches you how things work and how to think, but there's an alternative clone OCaml implementation for windows and it is called F#. It integrates well with .NET stack, so, all favorite .NET libraries can be used. Except, with F# your project will be few times smaller and less verbose than, say, C#.

So, the thing to take from this information and what I want to say now: try OCaml, it is most likely better than your best language you know now.

Further, I'll share from my experience what is the OCaml of the databases.

Have a good one, Abner