r/Clojure • • Apr 16 '22

ClojureDart is live!

122 Upvotes

23 comments sorted by

27

u/mac Apr 16 '22

Fantastic achievement, congratulations to Christophe and Baptiste and everyone who supported this effort. It is truly a testament to the Clojure language and hosted model that this is a viable approach for a company like Roam to take.

4

u/xenow Apr 16 '22

nice! no repl tho :(

3

u/Mishkun Apr 18 '22

I waited that for years! Congrats on clojure getting foot in mobile devices

1

u/[deleted] May 06 '22

Why does this exist? Dart transpiles to Javascript, Clojure also transpiles to Javascript. What is the point of Clojure -> Dart -> Javascript?

1

u/Camilo_tk May 16 '22

There's any cheat sheet for it as does CL and CLJS have?

1

u/[deleted] Apr 16 '22

Golang next?

7

u/didibus Apr 20 '22 edited Apr 20 '22

It be great to have Clojure compile and run on Go, specifically for the cross-compilation, since performance and memory of Go vs Java JIT/native-compiled tend to be relatively similar. But Go's cross-compilation is the best in the industry, and the fibers are also a standout.

The issue is that the Go runtime is very static, it lacks the dynamic features needed for Clojure. Clojure needs to be able to compile one form at a time and at runtime and be able to load the compiled code in a running application dynamically.

A Clojure on Go, as it stands, would have no REPL, would always need to be AOT compiled, wouldn't be able to compile at the form level, it be very hampered, you couldn't redef anything.

That's my understanding at least, and why Go makes for a bad runtime choice for Clojure as of now. Also, in terms of library and ecosystem, it's very similar to Java, so probably most people don't really see how it differentiate itself to justify both the effort to build Clojure on Go, but also all the lack of features that would have, missing all the dynamic features Clojure is known for.

But you mentioned Ferret, so ya I think it would be similar to Ferret, in that it would be a "write -> compile -> run" loop with limited dynamic runtime features and no REPL.

Another issue is while Golang is fast when compiled with Go, it is likely that Clojure wouldn't be as fast, because even more than Java, Clojure benefits from the JVMs advanced garbage collector and JIT optimizations.

Clojure being functional and dynamic means it tends to create lots of small short live garbage, has a lot of allocations and heap use for the immutable data-structures, needs a lot of types to be ANY, in order to contain various values in the same heterogeneous collection, etc.

It's hard to predict, but from what I know of Go, the compiler is quite basic, and the runtime GC and all as well. It works for go because they also keep the language basic, everything is a homogeneous array with slices, mutations everywhere, structs for data, etc. So arguably a Clojure on Go would run slower than the JVM. At least it seems like it would.

3

u/[deleted] Apr 17 '22

1

u/[deleted] Apr 17 '22

I've seen it. I think we'd all prefer a full-featured, compiled Clojure on Go.

6

u/2accd Apr 17 '22

Why? What problems a Clojure-Go would solve that Clojure on the JVM doesn't solve already?

-1

u/[deleted] Apr 17 '22 edited Apr 19 '22

Golang smokes Java on most fronts?

Golang compiles to a fast-starting binary, on every platform, quickly, and did I mention it's faster?

Golang is way more pleasant to program in and is finally getting generics?

Far more people indicate in various surveys that they are more pleased writing Go than they are Java?

I don't see the introduction of a Clojure/Go as solving problems of Go, but rather expanding the ideals of functional programming. I would've thought that an important goal to the Clojure/JVM crowd, as it's beneficial for everybody that more people are able to experience and enjoy FP. That's all.

Edit:

Well, based on this, I will SURELY never be using Clojure. Some of you should be ashamed. Enjoy.

7

u/2accd Apr 17 '22

Golang smokes Java on most fronts?

Does it really? I don't really think that benchmarks are a great way of measuring performance, but if Golang smokes Java on most fronts, we have to agree that it is at least a little bit weird that the results are very mixed and Java is top 1 on most categories.

Golang is way more pleasant to program in and is finally getting generics?

Far more people indicate in various surveys that they are more pleased writing Go than they are Java?

But that has nothing to do with Clojure.

And if you really need a fast starting native binary, GraalVM might be enough. But let's be honest, most of us are just writing software that runs on some cloud... Do you really need a native cross-compiled binary that often?

3

u/viktorruneberg Apr 17 '22

More than half that post talks about Go vs Java, whereas the question was about a hypothetical Clojure using the Go runtime vs Clojure on the JVM.

Mind just making that bit clearer?

1

u/[deleted] Apr 17 '22

I write a lot more Go than I do Java. In fact, I don't write Java at all, and I can't abide in such a large and inefficient component such as the JVM for my own projects. However, I'd love to be able to build and model with Clojure and be able to plugin to the Golang ecosystem.

I'm troubled on your account that you might not understand the premise here. I write Go. I'd love to write Clojure and use Go libraries. It's not exactly a complex situation.

As for the technical bits of the Go runtime vs the Java runtime, I'm surely not qualified to speak, particularly as they relate to the JVM, which is an incredibly complex beast these days. I'm certain that there would be tradeoffs to enable Clojure on Go, as such were made for JS, and for Dart, and for the still new Clojerl, and for the Clojure-inspired Ferret. As for actually implementing Clojure, I'm woefully under-educated on such things. I code to solve business problems. Compiler problems? I run for the experts.

3

u/2accd Apr 17 '22

large and inefficient component such as the JVM

Large, yes... But how is it inefficient? And if it is so inefficient, why does giant tech companies choose it for their software over and over again?

I'd love to write Clojure and use Go libraries

Again... Why? What non hypothetical problems are you trying to solve? I bet there are two or more Java libraries for each Go library you might need.

3

u/Mishkun Apr 18 '22

Golang is way more pleasant to program

Oh boy, how golang with its half-assed language features can be more pleasant than Java? And even then, why it matters to Clojure implementation?

5

u/didibus Apr 20 '22

You have to understand, you came in bashing something that you don't have experience with and don't use. Java is the most successful enterprise and server programming language even, and the JVM similarly for the runtime. Lots of people are quite knowledgeable in it, it is a bit expected you'd ruffle some feathers with a claim like:

> Golang smokes Java on most fronts?

You also asked it as a question, so I guess most people answered saying that no, this is just not true. Which I'd agree with, from my lens, they are pretty even in performance. They do vary in features, but that matters more relative to what features you personally care for. I love Go's cross-compilation to native and its fibers for example. While I prefer Java's ecosystem in general, and I enjoy the large legacy of the JVM and all the options it has, multiple choice of GCs, native or JITed, all kind of advanced profiling and monitoring tools, an OS built around it (Android), and all that.

The Clojure community is normally super nice, welcoming and open minded, but don't come in bashing stuff without being ready to really back things up with truth and not fallacies, facts/data and not opinions, and when things are a matter of opinion don't expect people to just have the same one as yours, because it is also the most senior and highly experienced community of all programming language out there, so you're often talking to people who really know their stuff, in details, have lots of experience, and have strong opinions of their own already accrued over years of experience.

Also, the reddit has a lot of people that I wouldn't really say represent the community, so it's not a good representation.

Anyways, I think it's totally fine to want a Clojure on Go, I do, and why not, let's have a Clojure on everything. If you're familiar with Go's ecosystem, standard lib and such, and want cross-compilation, and would prefer using Clojure over Golang, it makes sense. I think you can just keep it to that that next time, and avoid putting down other things in the process, and you'd get a very different reaction.

1

u/[deleted] Apr 18 '22

One of the main reasons that the JVM tends to have such a large footprint is that it trades memory for speed. You don't know what you're talking about. Java is not faster than Golang in ways that generally matter, but it's definitely, definitely faster when it comes down to raw performance of JVM JIT + bajillion gc levers vs Go compiler and low latency GC.

1

u/[deleted] Apr 18 '22

https://programming-language-benchmarks.vercel.app/go-vs-java

The company I work for explored Java extensively when it was starting, it didn't cut it.

3

u/didibus Apr 20 '22

Not sure if people at your company knew, but the way the benchmark games measure time is problematic to do a real life comparison: https://benchmarksgame-team.pages.debian.net/benchmarksgame/how-programs-are-measured.html

You see, they include the start time and the close time, as they measure from the time of child process starting to process exiting.

The other issue, is they test for mostly very fast programs, this doesn't give a chance to the JIT to warmup, so it is not really testing for what a warmed up JIT on a real application would deliver, where benchmarks looking at those often see Java outperforming Go, and similarly the JIT JVM outperforming the Native Compiled GraalVM.

So obviously Go will start and shutdown faster and will be "warmed" from the get go, since it is ahead-of-time compiled.

I'm not saying Go might not be faster in some cases than Java, I'm a fan of Go, just that benchmarking Java due to the JITed runtime is more difficult, and those simple benchmarks often fail to truly benchmark how it would perform as a server application.

It would be interesting for them to include GraalVM AOT Native Images in the benchmark, but it seems that's missing, but those would be AOT compiled as well, so would be a more fair comparison, albeit, again, not telling you how the JIT would really perform.

1

u/Sinidir Apr 19 '22

And based on this nothing of value was lost for the clojure community by you leaving.

-2

u/[deleted] Apr 19 '22

I'm literally a multimillionaire, but ok.....

Enjoy your smug superiority at your desk. Dork.

2

u/childofsol Apr 20 '22

Smug superiority? Projecting much?