Julia online compiler

Why that?

It’s open source! You just buy a domain, rent and setup a server, and provide access to those who want play with Julia online compiler. :wink:

In the meanwhile the core Julia developers can continue to work on improvement of Julia for the rest of us. They still have a lot to do.

P.S. Sorry, just a bit allergic towards

if it’s about other peoples money.

7 Likes

Hi,
So how did the Rust-Lang team do it?

Rust’s playground has several limitations.

Network

There is no network connection between the compiler container and the outside world.

Memory

The amount of memory the compiler and resulting executable use is limited by the container.

Execution Time

The total compilation and execution time is limited by the container.

Disk

This sandbox does not provide any disk space limits. It is suggested to run the server such that the temp directory is a space-limited. One bad actor may fill up this shared space, but it should be cleaned when that request ends.

It’s unclear how much the Rust Foundation spends on the Rust playground, but the Rust Foundation’s 2023 report reveals that they spend about $400,000 on infrastructure. While I could imagine that most of the money goes to compiling crates, I don’t expect the Rust playground to be cheap.

Running Julia directly in the browser would provide more opportunities. We just have to wait a little longer.

4 Likes

Do what exactly? If you mean their Rust playground, then I only know what the developers have written on their README and a few forum threads. If you want to learn how to implement your own playground for Rust or possibly another AOT-compiled language, you should contact the playground’s maintainers or ask Rustaceans in a Rust forum.

If you mean an online REPL with JIT compilation, then they never did that. My point was that Julia has fundamental differences, so many of the Rust playground’s approaches like its user limitations will not work. The upcoming AOT-compiled juliac might be similar enough to use the same approach, but its limitations will be the opposite of beginner-friendly. It’s better to instead research successful online REPLs for other languages with a heavily used built-in REPL.

Another option is that some online “compilers” run (mostly) interpreted languages by closing sessions after executing a script once, so the user cannot interact with the REPL. While less common for languages with REPLs, it’s idiomatic and friendly enough for beginners, and the user limitations might be easier. JuliaScript.jl or something similar can be used to save compilation for reruns of scripts with no edits, which will be more beneficial in Julia than most interpreted languages.

3 Likes

I took a stab at this:

julia-playground

(If you right-click the .gif and open it in a new tab, it’s much easier to see)

The frontend is a Vue.js app that incorporates a Monaco Editor. It sends the code to a Node.js API which executes it in a Docker container and returns the result back to the frontend app. Here are the repos:

The Dockerfile is in the repo with the API.

I’d be more than happy to invest time in this project if anyone is seriously interested in trying to stand this up, but there are a ton of issues that would have to be worked out. For example, I think you would want to have a preloaded set of packages in the Docker image for it to be a nice experience. There is also plenty to discuss regarding security and scalability of this approach. And then the elephant in the room is obviously funding. Running this wouldn’t be free and somebody would have to be willing to pay for it…

To run this locally, you would do the following:

  1. Make sure you have Node.js and Docker installed.
  2. Clone the repos
  3. For the web app, run npm install to install the dependencies, then npm run dev to run the app on localhost.
  4. For the API, you would first need to build the Docker image from the included Dockerfile, then run npm install to install the dependencies and, finally, start the API with node index.js.
12 Likes

Hi,
I think it’s worth spending money on this because it will help grow the Julia community.

Hi,
Why Docker? Containers have some problems. For example, installing packages in containers is not very easy and you have to build your own image. I think a virtual machine in Xen is both fast and secure.

Who’s money, more exactly, do you want to spend?

6 Likes

A website to teach Julia using Julia in WASM similar to Rustfinity would have greater impact and lower cost.

We must be more patient until Julia in WASM can be used in production.

4 Likes

Note there’s already (and we sort of compete with that unsuccessfully…):

VS Code for the Web (https://vscode.dev) has been available for some time now and it has always been our goal to support the full edit / compile / debug cycle in the browser. […] It is harder for other languages since we must be able to execute (and therefore debug) the code. For example, to run Python source code in a browser, there needs to be an execution engine that can run the Python interpreter. […] To find out what is possible with WebAssemblies today, we decided to take a Python interpreter written C/C++, compile it to WebAssembly, and run it in VS Code for the Web.

I believe the VS Code is cut-down, and maybe even Python in it too (but not too much).

Julia has already been run in WebAssembly. Julia is huge so it’s slower to start, but it can be cut down a lot, e.g. OpenBLAS left out (was done that way already?).

LinearAlgebra.jl is not longer part of Julia, or its repo, at least. I think cutting out as much as possible, and making it work that way for a start is a good goal, without VS Code, then with.

Even though mthelm85’s demo for Julia on the web, just posted here was cool, it wasn’t really on the web only, since connecting to a server, i.e. using Docker there, and we should just not try, too hard (IMHO), to make such a playground work, to eliminate all the (server) costs.

Running in WebAssembly, i.e. in the browser, mean more development cost, but worth it since it’s work we want to day anyway, make Julia even smaller, for small binaries, already making huge progress there. All web browsers support GC now for WebAssemly, in case we want to adopt it, not provide our own GC, and I see there’s also some work to allow exceeding the 4 GB limit.

JuliaHub seems to provide some kind of Julia IDE, with VS Code or Pluto, as part of its cloud products. I believe there’s a free tier once one is logged into JuliaHub, not sure how much compute does the free tier offer. These seems to be the docs:

1 Like

If I’m really interested in a language, I just install it. I certainly don’t contribute to grow the language by using a restricted online tool.

To make Julia grow, I need to install it locally anyway. And with juliaup (or downloading the portable) it takes less than 2min to install Julia on any machine (no admin rights required).

For me, I believe more newcomers are impressed by pages like

which are based on PlutoSliderServer.jl.

6 Likes

I actually see an interest for an online tool when I’m traveling without my computer but with a smartphone. Having access to an online tool would allow me to quickly test/develop code snippets which I can then later incorporate in my main system.

Github Codespaces?

1 Like

It’s just what I know how to do - no other reason. I didn’t mention in my post that every request made by the frontend to the API spins up a new container, executes the code, then kills the container. I was quite pleased with how quickly it can do so for code that only uses pre-loaded packages. The only problem I found executing code that Pkg.adds stuff is that it takes much longer (as you would expect). Other than that, installing packages worked fine.

I’ve read in a few places that VMs are more secure, but that they are generally slower to spin up/down than containers…I don’t have any experience with that though.

I was hoping to be able to get a live demo that everyone could access, but all the cloud providers want your credit card number for “free tier” accounts and I also couldn’t find any cloud provider that allows you to set a limit on the amount of cost that an app can incur. For example, I’d love to get all this running in the cloud if I could limit my monthly expenses to an amount I’m comfortable with, and the service would just become unavailable after that point…the only thing I found is the ability to receive notifications when you reach a certain amount. I don’t want that though, I want an automatic kill switch.

@mthelm85 Check out https://demo.jupyter.b-data.ch
→ Resources are limited to 2 cores and 8 GB RAM.

Cross reference: JupyterLab + code-server + Julia

https://demo.jupyter.b-data.ch is a reference deployment of b-data / Docker / Deployments / Jupyter · GitLab serving glcr.b-data.ch/jupyterlab/julia/pubtools amongst others.

There are also Julia-based Data Science dev containers for use with VS Code (local/‘remote SSH’) and GitHub Codespaces (web browser).

1 Like