UPDATE: The follow-up to this article can be found here.
Normally I’m not one to rant about programming or computer science stuff here (despite that degree I have in it), as I like to keep this more about philosophical crap (which I don’t have a degree in). However, I’ve spent quite a while on a research project and had a couple problems that all boil down to one thing: Matlab’s Java interface sucks. Bad.
If you don’t care for Computer Science stuff or when someone says “Java”, you think “Coffee”, this probably isn’t for you. In fact, it’s probably only really for me to bitch about randomly since I’ve wasted so much time on this.
So the nice folks who create Matlab (Mathworks) build Java support into the language so you can call Java from Matlab on the fly whenever you feel like it. It doesn’t seem very useful since Matlab can do whatever Java can, but I suppose for making GUIs it could be neat. The more useful application is the reverse: calling Matlab from Java. If I have some heavy numerical processing I want to do, and I know Java sucks at doing it, and that Matlab is designed to do stuff up this alley, then this is a great idea.
Apparently Mathworks thought the same idea as me and built easy access for programming languages to do this. The problem is, the only languages that they’ve built this kind of support are C, Fortran, C#, and VBScript. Looking at the examples they give make it seem really easy too. Just fetch the libraries you need and call a function with the name of the command to run. Simple enough.
But to do this in Java is nowhere this simple. It is so bad that the people across the 18 internets have decided upon at least 4 different ways to do this, all of which are terrible. One way to call Matlab from Java involve setting up a server and client relationship between an instance of Java and Matlab respectively and have them send messages to each other. This is terrible because you need to manually open each of those and type in a command to start the whole thing up. You could automate this, but it gets pretty complex pretty fast. Another way is to write some Java code, open Matlab, and then run the Java code, which is still the opposite of what we wanted to do.
It might not be so bad if Matlab gave you no interfaces to any languages, and especially no hooks to Java. But they give you an interface to Java that you can use in your Java programs! It has no documentation and the code examples on their site are vague and completely misleading.
It’s not like Matlab is a crappy language. It’s fine. In fact, it’s easy to debug in and not too hard to do most things your average programmer would think of. It’s just shit like this that makes you have to spawn separate threads that run scripts that do other shit that pisses me off and is completely unnecessary.
I have probably ranted enough for now. Hopefully you get the point from all this. If not, re-read that last paragraph again.