r/functionalprogramming • u/Voxelman • Feb 19 '22
Question Functional language for desktop apps
I want to write a desktop app and I want to use a functional language. The app should be system agnostic and should run on Windows and Linux.
I tend to use Rust. I know that it is not really a functional language, but for Rust you don't need to install a runtime like for Scala or F#. It is also memory efficient. But it is not fully functional.
Is there a functional language that I can deploy without having to install a runtime environment first?
3
u/witoldsz Feb 19 '22
What kind od app would it be?
2
u/Voxelman Feb 19 '22
It should replace an old Delphi app in our company. We are calibrating temperature controller devices
2
u/jmhimara Feb 20 '22
I'm assuming that by "app" you mean gui (or are they synonymous?)
Is memory efficiency and performance critical to your app? If yes, then you should probably stick to Rust. It's a lot less functional than advertised, but pleasant enough to use functionally.
Otherwise I strongly recommend Racket. It has gui libraries built into the language and they're delightful to use. It's also readily cross-platform.
deploy without having to install a runtime environment first?
Maybe not an ideal solution, but a lot of functional languages allow you to embed the runtime inside the executable. Both F# and Racket can do this. I'm sure most can.
3
u/Voxelman Feb 20 '22
Thanks for your answer. I think I will use Rust. Maybe I separate frontend and backend and I use Elm as frontend in a browser.
15
u/sintrastes Feb 19 '22
Since your requirement is simply not having to install a runtime, I thought I'd also mention Haskell, which although it has a runtime, by default it is statically linked to the built binaries.
It's also fairly efficient.
3
u/sintrastes Feb 19 '22
GUI libraries are not the best (but hey, the same could be said of Rust I suppose), but worst comes to worst you can always FFI out to C if you really need to for your UI layer (assuming you're building something with a GUI).
But both WxWidgets and gi-gtk-declarative are nice.
6
Feb 19 '22
Haven't seen in the replies yet, buy maybe ocaml could work. It has a bunch of libraries and integrations for system stuff and I think one can statically link all the stuff. Many things may be missing since community is smaller compared to others, buy anyway may be worth a look depending on the scope you want to do. Not so sure about the windows situation though.
4
u/yawaramin Feb 20 '22
OCaml would definitely work. It has a wrapper for Gtk (Lablgtk). We know desktop apps like MLDonkey, Unison, and 0install are shipped to Windows. It might be a bit painful to set up but it should work.
8
4
3
u/stun Feb 19 '22
Why donβt you give Nim https://nim-lang.org a try?
It is a multi-paradigm programming language with the performance of C with Python-like syntax.
Generates dependency-free executables, and not dependent on a virtual machine like the Scala or F#
Supports most major OSes
Its Wikipedia article page contains a fairly good amount of information as well.
2
u/enverx Feb 24 '22
Nim isn't made for functional programming. Nim's creator himself (Andreas Rumpf, AKA Araq) explains his low estimation of FP in this discussion from last week: https://forum.nim-lang.org/t/8927 .
1
3
u/ragnese Feb 21 '22
Is there a functional language that I can deploy without having to install a runtime environment first?
Why? Don't most GUI apps bundle whatever junk they need already, anyway?
1
u/logan-diamond Feb 20 '22
Hi there! My main language is rust as well but I've come to really like scala + scala.js
More specifically, I've come to really like cats + cats-effect. It's easy to nitpick and point out worts in scala; but the high points really do feel like flying. Cats-effect is an amazing, intuitive and performant asynchronous runtime (i prefer it even to Tokio). Scala.js is mature and productive to work in. Spark is a beast. I'm sometimes frustrated that at how close the performance of my scala code is to my rust code π
If you can use rust, go for rust. Otherwise, I'd highly recommend starting to learn scala/scala.js
1
u/Voxelman Feb 20 '22
Scala is interesting, but I think I go with Rust. Maybe I separate frontend and backend and I use Elm as frontend language.
3
4
Feb 19 '22
Scala Native could do the trick: https://scala-native.readthedocs.io/en/latest/index.html#
4
u/crypto-bv Feb 19 '22
ScalaJS with Electron might be a good option. You can handle all of the UI and state changes from ScalaJS without needing any JavaScript or HTML beyond the boilerplate code. Since it uses electron it should be able to run on everything and ScalaJS gives you access to a huge swath of Scala libraries.
2
3
u/monnef Feb 19 '22
Not that I recommend it, but you can run jar from Scala without installing runtime. You can simply bundle JVM with the application (I think I have used Launch4j with libgdx years ago and it worked well for Windows and Linux).
3
u/videoj Feb 19 '22
Purescript or F#/Fable with Webview or Photino Native. Alternative to Electron that is light and uses the built in browser.
2
u/dorfsmay Feb 19 '22
This is going to sound like a joke, but I'm serious: typescript + React hooks + neutralinojs or even electron.
3
u/yeastyboi Feb 20 '22
I don't think it's a joke. Many commonly used functional programming languages are actually multiparadigm. You can write functional Typescript and you can write imperative Typescript. It's more difficult to write functional code than say OCaml but it's definitely doable.
1
u/DeepDay6 Mar 04 '22 edited Mar 04 '22
As the modern way of compiling Java recommended by Oracle & co (jpackage) includes bundling the relevant parts of the JRE, you should be fine choosing Scala or Clojure+Cljfx. And of course there's GraalVM, compiling even more languages to native binaries.
1
3
u/sintrastes Feb 19 '22
https://koka-lang.github.io should do the trick.
Compiles to runtime-less C.