5 ms·
If anyone is interested in compiling small binaries with Julia do check out staticcompiler.jl and supporting statictools.jl that manages to produce small binari
by arbitrandomuser 3y ago
If anyone is interested in compiling small binaries with Julia do check out staticcompiler.jl and supporting statictools.jl that manages to produce small binaries without the Julia runtime ,
Ofcourse it's a wip , and not fully mature , I'm just putting it out there for people to know.
There's some really cool demonstrations come out of this ...
Wasm fluid simulation in Julia:
https://alexander-barth.github.io/FluidSimDemo-WebAssembly/ https://alexander-barth.github.io/FluidSimDemo-WebAssembly/
Differential equations demo in the browser:
https://tshort.github.io/Lorenz-WebAssembly-Model.jl/ https://tshort.github.io/Lorenz-WebAssembly-Model.jl/
Someone even setup Julia to run on AVR mcus for Arduino
(Directly using gpucompiler which statictools uses to compile to binaries):
https://seelengrab.github.io/articles/Running%20Julia%20baremetal%20on%20an%20Arduino/ https://seelengrab.github.io/articles/Running%20Julia%20bare...
- ubj 3y agoYep, I was aware of StaticCompiler.jl. I wish it was more mature. Static compilation is indeed possible with Julia. But it's very limited in its capabilities and certainly not as effortless as a simple `mojo build myfile.mojo`.
- suavesito 3y agoWell, it is as simple as that... using PackageCompiler.jl [1] (PkgC.jl). It does create huge executable (you can easily trim them), but those are relocatable and portable between machines as they include most (if not all) of the dependencies needed to run them. They are already used in production in several places. I don't have the link at hand right now, but maybe someone else might jump to give the link to talks given by Chris Rackaukas on this. From my personal experience. I've done graphical apps in GTK3 in Julia with PkgC.jl cross-compiling from Linux to Windows. And they worked. :) [1] https://julialang.github.io/PackageCompiler.jl/stable/ https://julialang.github.io/PackageCompiler.jl/stable/
- ubj 3y agoPackageCompiler.jl is more fully featured, and I'm definitely looking forward to further developments :) But it still has some pain points: * Massive executables (which you mentioned). This makes it very difficult to use with embedded systems. * Functions are not precompiled by default. You need to write a precompile script [1], which leads to a "two script problem": one script to do what you actually want, and another script that (hopefully) hits all the types you'll possibly need at runtime. And yes you can use `--trace-compile=file.jl` or SnoopCompile.jl instead, but this is still another step I need to worry about when compiling something. [1]: https://julialang.github.io/PackageCompiler.jl/dev/sysimages.html#tracing https://julialang.github.io/PackageCompiler.jl/dev/sysimages...
- suavesito 3y agoWhile the second part is true, it is a fundamental restriction because Julia compiles a method until it is actually hit and types are defined for the call stack. In equivalent manner, for StaticCompiler.jl you need a declarations of the methods/symbols you need to export. So, while it is true you need to do an extra step compared with other languages, it is not a fundamental problem with respect to PackageCompiler.jl, but rather a design restriction given how Julia works.
- Max-Limelihood 3y agoThat's not a fundamental restriction or design problem with Julia, you're just describing JIT compilation. Plenty of languages can be compiled either ahead-of-time or just-in-time. Actually, this should be unusually easy for Julia, because their JIT compiler isn't a heuristic-based compiler like JITs for Python or JS. The problem is funding. There are 0 full-time employees working on this issue because JuliaComputing has gotten about 10% of the funding Mojo has.