Hacker Read top | best | new | newcomments | leaders | about | bookmarklet login

Clojure is fun but starting a Clojure program that just prints hello world takes over 1 second, even worse on a raspberry pi. I suppose command line tools are not its main purpose.


sort by: page size:

A Clojure programs takes 3-4 seconds to load, making it untenable for command-line programs.

Unfortunately Clojure start time is about the same regardless of build tool, and it's especially not good on the RPi.

Clojure is slow at startup because of the long list of classes have to be loaded at init I think.

On modern hardware Clojure starts in under a second. I write simple support scripts in Clojure all the time.

I really like Clojure as a language, but the JVM implementation takes over a second to start. This lack of responsiveness makes it a poor choice for many small scripts that should run quickly. If not for this issue, I would probably use Clojure on a regular basis.

It's the main reason I don't use Clojure. I was so excited to learn a modern Lisp. Got an my tools working and wrote my first cli app. Horrendous load time. I realised it's really only suitable for long running processes and I never do that sort of thing so can't use it.

The trouble with Clojure in my opinion is the slow JVM warmup, especially when writing small command line tools in Clojure, it's a real pain in the ass to run

   lein run myscript.clj
and then sit there waiting for 2 - 3 seconds to see your result. Might sound insignificant but it's noticeable when you're constantly switching between source and result. Obviously the way to get around this is to load everything into a REPL and enjoy the advantages of explorative programming.

This is where Haskell has an advantage, the runghc command is very fast, and compiling your script/program into a static binary means it's quick to execute as well.

Clojure (and Scala) need to sort out the JVM warmup to make them viable general purpose languages.

The bizarre thing is, running Java on the JVM startsup almost instantly.


Clojure is not a very fast language.

I never worked with Clojure, but a simple java "hello world" starts and finishes within a second. Same with a simple java Swing UI "hello world" sample. If some application is doing something slow during initialization - it is not the platform itself, but the specific code to blame.

"So you have no excuses not to build your CLI tools in Clojure now."

Except that the toy program is 25MB and takes multiple minutes to compile...


I read it fine, but Clojure is an application of the JVM. The fact that a popular interpreted language of the JVM takes 1.2 seconds for hello world is a problem of the JVM itself, or at least it's ecosystem. An interpreted language in C wouldn't take nearly that long.

I'm very familiar with the live editing aspect of Clojure, and I like it a lot actually.

What I am saying is that Clojure's long startup time is still annoying if you want to restart, for example if you trashed your repl session or want to start with a clean slate.

If Clojure would start fast enough it could also be used for CLI scripts and we would not need Babashka at all.

All in all, I think Clojure is a great language, but the slow startup time is still a disadvantage.


Also fix clojure startup time please. I want to be able to run it like fast Unix style commands such as ls and grep.

Slow launch means you tend to write monolithic applications. You can't write cli tools with Clojure. You can't compose Clojure applications. You have to write a big bulky JVM app. Which definitely has its place, but ClojureScript is expanding Clojure's reach.

"It has a slow startup time. Clojure runs on the JVM and has a significantly slower startup time compared to Node. Again, this is only a problem from an outsider’s perspective. We have REPL. You start the app only once, and it keeps running in the background. You can interactively include new changes, without having to startup every time."

I've been using Clojure for about 8 years and this is one of the talking points I find most annoying. The slow startup time is a disadvantage, and it should be owned. It disqualifies clojure from a large class of applications and if you're not honest about it you lose credibility, and you retard potential attempts to solve it. It doesn't mean you can't write software with Clojure, but be honest about the fact that it makes lots of types of usage (not all) a poor match.


Clojure doesn't have slow start-up, Leiningen and Boot-clj make it feel slow. But once you start a REPL you can keep it running. I keep mine running for weeks.

> Clojure's startup time is pretty brutal for a lot of things I'd like to use it for, and no amount of REPL-driven development can make Clojure appropriate for CLI tools.

If you got the repl-driven development down, you wouldn't test your CLI by launching it, you would just evaluate the same functions as the CLI uses. Only time when you'd want to launch the CLI would be before releasing a build or for E2E tests. Once you got the code down for your repl and the startup time becomes a hassle, you compile down your Clojure program to a binary with GraalVM and now it starts up fast.

Otherwise, give babashka a try. Basically single-binary Clojure environment. https://github.com/borkdude/babashka


> Java is not as bad as you think. Clojure does takes a little longer though

For example, I have a Python script[1] that runs on each command prompt to print status about my current git repository. Just timed it, it runs in .08-.12 seconds within a repo and about .02s outside of a repo. I still want to rewrite it in C using libgit2 someday, but something like that would be unusable if it was written in Clojure.

[1] https://github.com/kbd/setup/blob/master/HOME/bin/repo.py


Clojure's very slow startup forces you to this workflow, relying entirely on the REPL to compensate. It's not any better compared to a language with a fast change-test-debug cycle.
next

Legal | privacy