
Programming languages are directly related to what you want the computer to do. It does not make sense to use Scratch to write a device driver, or C++ to teach kids coding. Eventually the computer will run ones and zeros but for us humble humans we need a programming language that makes us as productive as possible.
Legendary Google programmer Jeff Dean is said to code in ones and zeros and then write that in some programming language so his colleagues can understand the code. I have a tough time believing that story, but I love it nonetheless.
In my early programming days, there were way fewer languages. C and later C++ were quite dominant. If you were to code a video game a device driver or a business application, you used the same language. Maybe with some derivatives, like Oracle’s Pro-C which allowed us to embed SQL into C.
Now, there are so many languages, I know the name of just a fraction of them. Still, one has to choose, and do so carefully: the wrong pick can slow your project down a lot.
The question of what programming language to use for an AI project came to me a few years ago when I started coding what later became the core of Decisive AI engine. I had been coding for enterprise business applications for many years, so I was fluent in Java, SQL and various tools and frameworks such as Spring, Hadoop and Hibernate.
So, why not Java? Indeed one can use Java to write AI applications. There’s a great deep learning framework that is getting to maturity now for Java applications: www.deeplearning4j.com. But Java is just too clunky when it comes to handling arrays of data. Say you have an array of a few thousand results of some run, and you want to filter for some, then order that, and then transform the resulting array into some other type of array. Thinking of doing that in Java makes me tired.
Java is a great business and general programming language, but it is old. It inherits too much from C (but not its speed). So I did some research and started experimenting with Scala. Scala solves a lot of the issues with Java, it is awesome with arrays and collections in general, improves the language and yet it keeps the advantages of Java: it runs in a JVM and at least it’s not slower than Java.
So, is Scala the language of AI? Well, it does a great job, but then it has some important gaps: doing some research to see which algorithm performs better, or maybe testing some mathematical formulas applied to an algorithm was a lot of work with Scala. Asking around I was enlightened with the use of Octave (Mathlab’s open source version). In fact, telling people that I was using Scala for AI algorithm development drew some puzzled faces.
Very popular in engineering and in school, Octave does not try to be a general programming language, but one for mathematics and linear algebra in particular. Great! I was shocked by how fast I could create a lot of random data, do some calculations, get results and plot them on a graphic.
Octave is great for algorithm development and research, but we hit a wall when the algorithm moved to a prototype phase where we needed a neural network as a way to generalize a function. Octave does not have an artificial neural network (ANN) library (mathlab does, but we quickly realized it is pretty bad).
So, the next stop was Python. I was well aware that Python is the most popular language in the AI world. It is an easy and popular language, often used in serious production applications. Yet, I’m not convinced it is a replacement for Java or Scala: it is interpreted, which makes it slow, too dynamic which makes it easy for the coder to write errors and I can’t shake out the overall feeling that it is a language not well thought out from the very beginning.
But, why not for prototyping? Its weaknesses turn into strengths, and we don’t care about speed or maintaining millions of lines of code in a big system. On top of that, Python has the huge advantage of having TensorFlow as a library for ANN. So Python turned out to be a great tool for prototypes and proof of concept.
Last but not least, we had one last gap to fill. At Decisive, we deploy trained intelligent agents for military simulators and video games. This means that the ANN has to run in whatever platform the simulator or games runs on. Scala won’t do well there, it needs a JVM and it is slow.
So, what is fast and runs everywhere? C! Yes, we go full circle and finish where we started. I’m not suggesting everything needs to be in C, but a C module that can run a trained ANN is a must. C is fast, so libraries like TensorFlow and ND4J implement critical parts in C or C++.
In short, there isn’t a single language for AI. Coding AI means something very different than any other coding: instead of telling the computer what to do in an imperative way, we code so the computer learns how to achieve a goal. We need to do some research, for which Octave is very good, then prototyping with Python and TensorFlow. Then it’s a learning platform that is scalable and flexible with Scala and finally, we use C for cases where speed is a must, probably the final module that ships to the customer.