So, as a few of my posts here have hinted at so far, I’ve been experimenting with other languages on Glitch, seeing what I could get working just with what’s installed on the container. I’ve especially been focusing on compile-to-JS languages that are available on NPM because of the space savings from pnpm and caching.
I thought it might be helpful to keep a list of what I’ve discovered so far. Feel free to comment with your own experiments
- Java: OpenJDK 1.8 and Maven are present. Otherwise untested.
.NET: .NET Core 2.1 is installed including the
dotnetCLI tool along with the ASP.NET runtimes. I was able to compile a basic F# HelloWorld using this guide. See also Fable below.
- Python: both Python 2.7 and 3.5 are installed as well as pip. There is a hello world starter glitch for Python/Flask available for remix.
Go: A template exists for a Go app using the gin framework, but it no longer works as the
gobinary no longer seems to be present on the container.
Rust: Works. I was able to build a hello-rust template using the Iron framework for the backend. Note that due to disk space premium, some of the more popular options like
nickelwere a no go: they run out of disk space during compilation.
Other langs found in
ls -al /usr/binbut untested:
- C/C++. Both gcc and clang. Also LLVM tools.
- OCaml. the OCaml compiler and camlp4 are installed.
- Perl. including CPAN.
- Lua 5.2.
- PHP and/or PHP7.
- Ruby, including Rails
Compile to JS languages:
- Typescript: Installs via npm. Not tested personally, but unsurprisingly seems to work just fine as there’s a number of projects using it, including several “hello world” type starter apps to remix.
- Elm: Installs via npm, works great. Have written several little projects, including a hello world to start with. Slight gotcha here: for some reason the “add dependency” tool finds some very ancient version of Elm labeled “2.0.0” rather than the actual current version of 0.19, so it’s best to manually install this.
- ClojureScript: Can install the lumo-cljs compiler via npm, and basic compilation works, as well as backend node dependencies. However a bug in the CLJS compiler seems to break library imports for frontend applications due to how it handles symlinks. I’ve talked this over with Lumo’s dev and a fix may come, but he’s quite busy with other projects at the moment.
- Fable: F# to JS compiler. Works! I’ve built a project from the minimal Fable template here. Note that the deps do eat quite a bit of disk space.
- Bucklescript: OCaml to JS compiler, also used for Facebook’s Reason. Works, but you must install via the GUI “add package” tool in the editor. If you install manually at the console it will “lose” the built bsb compiler on the next restart. Also the initial install takes a very long time as it has to build the compiler from source, but restart time seems to be fine after that. I’ve created a hello-world demo.
Some other notes from my experimentation:
- If you start from the
node-app/hello-expressproject template, Glitch will run the project with
pnpm install --shamefully-flatten && npm start, and the sample code hosts the static
index.htmlvia Express through a random forwarded port. This is useful for compile-to-JS languages at least, as you can just customize the
startscript to compile your language of choice, and then have the
index.htmlpoint to your build output for the JS.
- Because of this setup and the way Glitch “restarts the world”, optimization is kind of a tradeoff here: it’s probably best to use optimized output for payload’s sake if nothing else, but this will also slow down the startup time of the instance.
hello-webpage/webpagestarter template on the other hand does not have
nodeinstalled, but does have Python, OpenJDK, and .NET Core installed still.
- The Python/Flask template instead uses a
start.shbash script to start the server. I haven’t experimented with this, but maybe this might prove a more flexible start for other language experiments since it’s not depending on npm.
- The Go template however instead uses a
glitch.jsonfile, which contains two keys,
install, which appear to just be commands for Glitch to run when starting the app. It does seem to work too; the template fails, because the go binary isn’t available, but it does try to run the command given in the
- Disk space is very limited. Disk space is only 200MB, so that limits the amount of space we have for dependencies, installing additional tools, etc. npm dependencies are sort of an exception though, as much of that is cached by pnpm and Glitch so that it doesn’t count against the instance size limit.
- RAM is a bit tight. Instance has 512MB of RAM, which is not bad for lightweight servers, but not good for running big toolchains in memory. When writing your build scripts, don’t bother with live reloading tools and the like, since Glitch will restart the whole server on change anyway. Compile once.
- Glitch expects a listening server to be running after it does
start. If it doesn’t find one, it will just restart the server in a loop. I had a hell of a time figuring out why my Fable template was doing this.
I hope this is helpful, and if any of the Glitch folks have further insights on some of the unclear stuff, or you’ve done your own experiments feel free to share. I’ll try and keep this post updated.