Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GUI in Java, Backend in SML?

I'm a big fan of functional programming languages (namely Standard ML and its dialects), mainly because of their expressiveness which allows for very consise, clean code. I can solve many problems dramatically faster with ML than with say Java.

However, Java is really great when it comes to programming GUIs (->SWT). I would definitely not wanna do that in a functional language.

This brings us to my actual question: Is there a good way to write a program in ML and then wrap it with a GUI written in Java?

What I have come up with so far is the following:

  • Compile the ML programm (e.g. with MLton or Poly ML) and execute the binary as an external program from Java (http://www.rgagnon.com/javadetails/java-0014.html).
    Problem: The only way the Frontend/Backend can communicate is via Strings. This might require tons of (difficult) encoding/decoding.
  • Use JNI/JNA. From what I read, this will allow you to transfer Integers, Arrays etc. I think the external programms have to be written in C/C++ for this to work. With MLton's Foreign Function Interface I can write an Interface to my functional program in C and statically link the whole thing.
    Problem: Apparantly, this only works with dynamic libraries, that is dlls in Windows. However, MLton will only let me compile the ML/C Programm to an executable. When trying to create a dll, I get a whole bunch of errors.

Does anyone have experience with this? Is there a better way to do this?
Thanks in advance! -Steffen

EDIT: I know about Scala which tries to bring concepts from functional programming to Java. I have tried it but I dont think it can compete with an actual functional programming language (in terms of expressivness)

like image 965
smolkaj Avatar asked Jul 29 '11 19:07

smolkaj


1 Answers

That's not quite the exact answer but there is a functional language which is very ml-orientated for the JVM: Yeti

So if you like coding in ML than that's probably currently the closes you can get on the JVM and it integrates of course very well with all the Java APIs.

like image 52
chrisichris Avatar answered Oct 03 '22 23:10

chrisichris