Front ends for Julia codebases?

I have an idea. It involves a pretty UI with low latency. Unfortunately, I lack a bit of soft-ware skills. I know JAVA, a bit of scala, C#, bit of C/C++, yadda yadda. I’m most comfy in JAVA because development is easy, although the code bases usually end up yucky one a UI is involved. What are people doing to embed Julia into their applications? ZMQ to Java? Julia straight to JS?

Where would you recommend a hack like myself to start?

Edit - is golang trendy for this? It seems pretty easy!

1 Like

i remembered GitHub - Gnimuc/CImGui.jl: Julia wrapper for cimgui

2 Likes

https://github.com/JuliaGizmos/WebIO.jl might work, depending on how complicated the communication between the UI and the rest of the Julia code needs to be.

Depends a lot on the UI you have in mind. If is is sophisticated and low latency and aim to be multi-OS : Qt is probably the best choice to build the apllication. I know that there are some attempt for a direct Julia/Qt interface. Maybe have a look to Trying to find GUI options for Julia (windows + linux)

@longemen3000 - This is a very interesting option - thank you! I’m not so sure how hard it would be to make new widgets and add interactivity but this is very very close to what I want/need. I’ll test it out on linux and windows and see how stable it is. Thank you.

@rdeits - please don’t take this as anyform of criticism - it’s not. I love WebIO/Blink/interact/etc. However, I’ve had a really hard time making anything more than simple one off demos with those tools. It is worth revisitting because I see many of the components of the ecosystem have been under development since I last used it.

@LaurentPlagne - QT is a good option. I read through that thread and hit a lot of dead ends. Many of the projects are failing to build, have no documentation, or haven’t been touched in >6 months, etc. Makes it hard to want to jump on board and give one a try. I have no intentions of commercialization so QT or related API suggests are entirely welcome.

Alternatively, using a language with a no brainer GUI toolset (cross compatable is ideal but not required) would be great as well. I’m not afraid of ZMQ, or polling some kind of julia backend. I feel like this is a missing element for a lot of julia applications and I want to kind of document my way through it as I try a few options and weigh pros/cons.

4 Likes

A lot of dead ends indeed. I though that @barche QML route was an interesting options.

Blockquote
I feel like this is a missing element for a lot of julia applications and I want to kind of document my way through it as I try a few options and weigh pros/cons.

Would be great ! I think that the topic of building an application (with UI) has not been addressed very often. This is related to the question “is Julia a general purpose language ?”. Most attempts that I have seen are based on WebIO. My poorly-educated guess is that the micro-service architecture could be a nice option : let Julia deal with computations as a service and use QT or Web clients or something else deal with the GUI. It could also help to isolate the Julia computations if someone do not want to share its sources.

5 Likes

@longemen3000 I failed to build CImGui - probably because I’m using Fedora over Ubuntu. I’ll have to try to track that down.

Warning: 
│ │ ================================================================
│ │ === Building GLFW has failed. Most common problem is,        ===
│ │ === that you don't have x-org installed.                     ===
│ │ === You can install it via: `sudo apt-get install xorg-dev`  ===
│ │ ================================================================

But this is a common theme for this type of effort. The backend for the front ends are really complicated to accommodate a lot of architectures/OS’s/etc. Manually linking all the C/C++ libraries to get a CMake to work, or installing dozens of programs from a package manager, reading stack exchange, etc. The JVM solves this issue via virtualization, but we all know what comes with that…

This is why I tend to think reaching out to another language, which has “mature” front end API’s would give the most results for the least effort - but maybe its more or less the same.

I also see why people have been targeting web interfaces, but I’m not super convinced that the JS landscape is very sane to explore. It seems like an open admission that you need to learn 3-5 languages, and 10 frameworks to make any kind of informed decision. Seems like a huge caveat for a solo developer coming from Julia. Maybe I’m oldschool, or outdated, but I still fancy the idea of desktop applications.

1 Like

I have built a few (small) Julia applications with the GTK front-end. In the end I was not happy with them. There ends up being a lot of UI code and it starts bleeding into the computation code…which may be my fault.

What I’ve been happy with is using Julia as a WebSocket server and building my UI in ReactJS or Angular and using the BootStrap CSS. The WebSocket provides a clear barrier between UI code and computation code. With ReactJS or Angular you get a UI that dynamically updates based on the data which I find provides for a clean implementation of the UI.

4 Likes

Let me just add my +1 for CImGui. I use it for all my GUI needs, and it works surprisingly well on all the OS’s I’ve tried. If you can get everything built correctly (which I never had problems with, even running on Wayland) then I think it’ll suit just about problem you throw at it. Custom widgets are also pretty easy; I managed to port one of the node editors to Julia without much difficulty, and find it really easy to modify and improve.

In terms of how it changes your codebase, I think that because it works in immediate mode, it’s easy to modularize your UI logic so that it fits the structure of your project well. It does have a solid chunk of required boilerplate to get the first window running (about 50 lines), but I’ve managed to hide that stuff at the ends of files or in its own file without difficulty.

4 Likes

I’ve built numerous applications with Vue.js (JavaScript front-end framework) and what I’ve thought I’d do if I wanted to power a Vue app with Julia is simply write an API with Genie.jl. For example, you could write a module in Julia that exports functions and then you could write an API in Genie.jl that calls those functions, passing to them arguments that are obtained from the query string parameters, and then returning the results of the function calls to the client as a JSON object.

When I first discovered Genie.jl I streamed a video on my Twitch channel showing exactly this, if you’re interested:

3 Likes

@pixel27 - I like the React paradigm(at least I think I do). Do you know of places to learn React/Angular for a complete idiot? The last time I wrote JS was back when it was something you put in HTML to add 2 numbers in a form, or say “ALERT: YOU ARE ON MY WEBSITE AND IT’S 2001”. When I found PHP I never really cared to look back.

@jpsamaroo - How did you build it for wayland systems? I’m trying lots of things and failing to get GLFW to build. https://github.com/JuliaGL/GLFW.jl/issues/188

@mthelm85 - I stumbled on Genie, but I’ll be honest. I don’t exactly get it. So I write an API then I write an interface in Julia/Genie then I write an interface in say HTML/CSS and then hook in via JS?

I’ve been eyeing up Kotlin and JavaFX. Can’t tell if that’s a mistake or not yet.

1 Like

I don’t understand why you don’t use Interact and WebIO if you are even considering angular/react.

Using Interact.jl is so much easier than building a custom angular app. We use it all the time for modelling interfaces.

I don’t want to make a modelling interface. I post a lot about DS but my interests are in a very interactive physics application. It needs several forms, toolbars, a couple clicky canvas/graph widgets, etc.

For sure. If you need that degree of complexity angular/react would be great.

Although by modelling I also mean physical models :slight_smile:

1 Like

Let’s say you wanted a user to be able to add some numbers in a GUI in the browser.

In Julia:

You would write a function in Julia to add two numbers add(x, y) = x + y and then you would write an API with Genie such that when your client app hits the endpoint https://mycoolsite.com/add?x=2&y=1 your code would extract x and y from the query string parameters, feed them to your add function, and then return the result (3 in this case) to your client in a JSON object.

In whatever front-end language/framework you go with:

You would then write a front end that has a couple of form inputs for each number and it would call the API and handle the response.

For front-end web development I can highly recommend the Vue.js framework. I’ve built numerous applications with it (I’m happy to show live examples if you’re interested) and I’m a big fan of it. For learning Vue/React, I can highly recommend any course by Maximilian Schwarzmüller on Udemy. He has courses on both Vue.js and React.js (and probably Angular too). I have completed a couple of his Vue courses and he’s a phenomenal instructor. If you complete one of his courses you will be able to develop some really nice, production-quality stuff without a doubt. That being said, it’s probably a good idea to learn plain vanilla JavaScript before going down the path of tackling a front-end framework.

2 Likes

For ReactJS I started at:

At the moment I like it better an Angular because it’s “less intrusive”. Angular defines how you create/layout the application which is good if you are working on a team since you’ll know how a service was added and whatnot…not so good if you just want to blast something out.

For angular I would probably start here:

1 Like

6-minute presentation by Mary McGrath of Brown University - totally awesome when I saw it the first time, totally awesome now: “JuliaCon 2019 | Prototyping Visualizations for the Web with Vega and Julia | Mary McGrath”:

and the code:

It’s an interactive React app w/ Julia on the backend…

3 Likes

@raf - do you have an example UI maybe you could screen cap? If it’s all proprietary/lock and key stuff don’t. I’m just curious. My UI’s always looks kinda blah. One key thing I need is a plot widget I can click around and manipulate. I’ve made these in JAVA OpenGL back in like 2004 or something, but that’s not really where I want to be. 2-D interactivity would be fine.

@pontus - cool talk! Not what I’m looking for but very nice use of available tools! Worth sharing.

@pixel27 - thank you! I’ll peruse the tutorials there and see how clueless I am.

@mthelm85 - Thank you for the suggestions. I think I see better how to use Genie. Hm. I’ll check out Vue as well!

Oh they look terrible because its just for science lol. But you can use html css so basically anythinjg is possible.

This is a plant growth model interface. Note that half of it is auto-generated. There are about 100 check boxes and dropdowns offscreen above this that select different models and things to plot, and regenerate the sliders for the new parameter sets. Interact makes that kind of thing pretty straightforward.

Mouseovers give detailed info about what the sliders are.

Edit also I hear you on the click around widget, I’ve wanted that too - say for selecting grid points on a map. If you built one for interact we could all use it :slight_smile:

Edit2: Here’s another one for maipulatable grid simulations. Again auto generated for arbitrary models, works on electron, juno, jupyter, web etc. Also currently incredibly ugly and unstyled lol…

2 Likes

@Raf - fine looking UI to me. I made some mini apps with windows and things with Blink which I don’t have access too and can’t share for legal reasons. They were kind of like that too.

Here’s where my research has lead me.

Golang : Not something you can pick up in a few days.

React/Angular: Nice for a lot of things. A basic app I could stand up in a day or something. But, something that looks polished (IE: not like 2001 HTML clicky buttons) would take exponential time for me. Highly interactive custom widgets, would also take a lot of time/effort because of my JS deficits.

Julias/Interact/Blink/etc: Awesome solutions. Basically the same thing I’d get from React/Angular with considerably less effort. Easy integration to plots for widgets and things(one thing I need)! All in Julia -huge plus. Downsides though: High latency, and there is a limit to the kind of interactivity I need. Mouse clicks, explicit control over widget displays, etc, won’t come trivially. I may not be savvy enough to solve those problems. Bugs happen, sometimes weird bugs, nothing show stopping, but I want this to be robust (I can’t dev on this project 24/7 I have a day job)

ClmGUI + Julia : Cannot get it to install for the life of me. Almost borked my OS display drivers trying to get around wayland. Shame - it looks amazing and exactly like what I want even if the code is a little verbose. If anyone can help with this I’d reallllly appreciate it.

Kotlin + JavaFX/TornadoFX : Kotlin is actually a confusing language to learn. It’s not very Java-like, and TornadoFX docs aren’t something you can sort through in a day or two. There’s CSS attributes that assume you know everything about how JAVA + JAVAFX works - I don’t! Despite the fact that Kotlin has a succint syntax for mundane operations, I’m not super convinced I’d be more productive here. SceneBuilder isn’t useful unless you want a really basic UI - I don’t. Goal is a quick UI made by a nonexpert that doesn’t suck horribly for somewhat complicated custom tasks.

Java + JavaFX : Is easy, but verbose. Has widgets I care about (charts etc) that can easily be modified via inheritance for the functionality I want! May let me extend to OpenGL without too much of a hell hole if I need too. Downsides: Not 100% sure how to connect to a julia backend. Thinking ZMQ. Maybe deploy java via the web and use Genie? Not sure if that’s possible. An interesting plus to this (well sort of not a plus) is if ZMQ passing slows basic operations down, I can write some in Java instead. An OOP paradigm can be pretty useful for some physics concepts, maybe there could be symbiotic relationship for some applications? I did end up entering a place for some of the code where I wanted some OOPness to smooth things out… The battle would be in harmonizing the two worlds in a useful way.

Clojure + anything: Sounds cool - but clojure… WTF? Would take a lot of time to figure out if this is worthwhile… Never bothered with LISP. REPL sounds nice, but at the cost of my sanity, not sure if it’s worth it.

3 Likes