Thanks @djsegal for tagging me, I wouldn’t have seen this otherwise.
Ok here’s a bit of info about the current state of web related packages in JuliaGizmos.
Tools to allow you to build things with html/js/css, with two-way js<–>julia communication.
Currently runs in Mux, Blink, IJulia, Atom/Juno, (probably just about anywhere that displays/outputs html/js/css from julia in future), with very minimal changes for each backend (1-2 lines of boilerplate).
It includes a DSL (adapted from Hiccup.jl) to write html:
dom"div.top-level"(
dom"span#text1"("epic text")
)
becomes
<div class="top-level">
<span id="text1">epic text</span>
</div>
and one for javascript (which originated in @mikeinnes’ Blink.jl). It enables this:
words1 = "I did it"
@js function doit(taskname)
@var result = Math.random() > 0.5 ? "ok" : "bad"
console.log($words1+": "+taskname+", which was "+result)
end
becomes
function doit(taskname){
var result=(Math.random()>0.5) ? "ok" : "bad";
return console.log(("I did it"+": "+taskname+", which was "+result))
}
Julia and JS syntax are not that dissimilar, and because the transpilation is built on Mike’s amazing MacroTools.jl, it’s fairly easy to add more features.
WebIO supports two-way communication between julia and js using Observables.jl. See the WebIO README for more details.
It’s not yet registered, though it probably will be within the next month, Shashi and I are just a little busy atm. Also, and requires nodejs to be installed to get started until then. Nonetheless it should be working pretty well.
Built on top of WebIO is…
Basically allows you to do stuff with Vue.js - simple and cool.
Built on top of Vue.jl is the super new…
Which cobbles together some Vue component libraries, and gives you high-level widgets like sliders, toggle buttons, and dropdowns.
using InteractNext, Mux
power_slider = slider(0:1:9001; label="power level")
julia_updater = on(obs(power_slider)) do power
pwrstr = power > 9000 ? "it's over 9000!!!!" : "power level is $power"
println(pwrstr)
end
webio_serve(page("/", req -> power_slider))
That will spin up a webserver, show the slider (if you’re patient) and print stuff in the julia REPL.
If you check out the examples in the README, you can see plots (using PlotlyJS) and svgs, using the @manipulate
shorthand. Some also use CSSUtil - which exports the vbox
and hbox
functions which allow you to tile WebIO html nodes vertically and horizontally, for simple layouts.
Everything @essenciary says here is essentially right:
there is no mature set of UI components based on Vue. There are some early attempts, but none of them have powerful or diverse enough UI elements, especially not for data vis. One option would’ve been to mash up multiple Vue components from various developers - but that would lead to different coding styles and integration strategies.
It’s not perfect but it’s a start towards enabling you to use high-level code to make web UIs in Julia.
Dash like polish/features is definitely a goal. I’m very interested in chatting to people.
Also, the package is very new, but I believe it works in at least the examples in the README and many more so please try it out and file issues furiously!
And naturally, contributions of docs and automated tests would be so very welcome! They are sorely lacking atm (though some of the Interact.jl docs are relevant), which is sad and I’m sorry.
Other thoughts
I think that a lot of what Escher enabled is now available with a combination of WebIO, Vue.jl, InteractNext and CSSUtil. @shashi has said [citation needed] that this is now the direction of focus, since Escher can only be run standalone (not in IJulia, Atom), is tied to Polymer, and is a bit large, which translates to unreliable and hard to maintain. Hopefully the combination of smaller packages should be better.
I’ve only just briefly looked at it, but Genie looks pretty sweet! @essenciary do you have thoughts about whether/where the WebIO/Vue/InteractNext stuff could fit in there?
Finally, has anyone tried out Puppeteer? I would really love to have some tests for WebIO, Vue, and InteractNext using it, or some alternative. Help! : )