Programming Languages for Machine Learning Implementations
Programming Languages for Machine Learning Implementations – Machine Learning (Theory)

		

			

		

	
	
		Machine learning algorithms have a much better chance of being widely adopted if they are implemented in some easy-to-use code.  There are several important concerns associated with machine learning which stress programming languages on the ease-of-use vs. speed frontier.

Speed  The rate at which data sources are growing seems to be outstripping the rate at which computational power is growing, so it is important that we be able to eak out every bit of computational power.  Garbage collected languages (java, ocaml, perl and python) often have several issues here.

Garbage collection often implies that floating point numbers are “boxed”: every float is represented by a pointer to a float.  Boxing can cause an order of magnitude slowdown because an extra nonlocalized memory reference is made, and accesses to main memory can are many CPU cycles long.
Garbage collection often implies that considerably more memory is used than is necessary.   This has a variable effect.  In some circumstances it results in no slowdown while in others it can cause a 4-order of magnitude slowdown.  The basic rule here is that you never want to run out of physical memory and use swap.
Some of these languages are interpreted rather than executed.  As a rule of thumb, interpreted languages are an order of magnitude slower than an executed languages.
Even when these languages are compiled, there are often issues with how well they are compiled.  Compiling to a modern desktop processor is a tricky business, and only a few compilers do this well.


Programming Ease Ease of use of a language is very subjective because it is always easiest to use the language you are most familiar with.  Nevertheless, significant differences exist.

Syntax Syntax is often overlooked, but it can make a huge difference in the ease of both learning to program and using the language.  A good syntax allows you study and improve the algorithm rather than the program implementing it.  (Algorithmic improvements often yield the greatest speedups while optimizing.)  The syntax needs to be concise (so that you can view the entire algorithm) and simple (so that it can become second nature).
Library Support Languages vary dramatically in terms of library support, and having the right linear algebre/graphics/IO library can make a task dramatically easier.  Perl has a huge number of associated libraries which greatly ease use.
Built in Functionality Languages differ in terms of the primitives that are available.  Which of these primiitives are useful is a subject of significant debate.

Some form of generic programming (templates, polymorphism, etc…) seems important.
Functions as first class objects is often very convenient while programming.
Builting lists and hash tables are often extremely useful primitives.  One caveat here is that when you make a speed optimization pass, you often have to avoid these primitives.
Support for modularity is important.  Objects (as in object oriented programming) is one example of this, but there are many others.  The essential quantity here seems to be an interface creation mechanism.


Scalability  Scalability is where otherwise higher level languages often break down.  A simple example of this is a language with file I/O built in that fails to perform correctly when the file has size 231 or 232.  I am particularly familiar with Ocaml which has the following scalability issues:

List operations often end up consuming the stack and segfaulting.  The Unison crew were annoyed enough by this that they created their own “safelist” library with all the same interfaces as the list type.
Arrays on a 32 bit machine can have only 222-1 elements due to dynamic type information set aside for the garbage collector.  As a substitute, there is a “big array” library.  However, having big arrays, arrays, and strings, often becomes annoying because they have different interfaces for objects which are semantically the same.


Familiarity  This isn’t just your familiarity, but also the familiarity of other people who might use the code.  At one extreme, you can invent your own language (as Yann LeCun has done with Lush).   At the other extreme, you can use a language which many people are familiar with such as C or Java.



The existing significantly used machine learning code bases seem to favor lower level languages.

Weka is one of the best known general purpose machine learning toolkits.  It is implemented in Java and has far more algorithmic coverage than any other system I know of.
LibSVM is implemented in C++ and Java.
SVMlight is implemented in C.
C4.5 is implemented in C.
SNNS is written in C.

Both R and Matlab are also useful languages, although I have not used them. 
None of the language choices seem anywhere near ideal.  The higher level languages often can’t execute fast and the lower level ones which can are often quite clumsy.  The approach I’ve taken is to first implement in a higher level language (my choice was ocaml) to test ideas and then reimplement in a lower level language (C or C++) for speed where the ideas work out.  This reimplementation step is quite clumsy and I would love to find a way to avoid it.
	

	 




	
		
	