My thoughts after using Clojure for about a month
acdw.net318 points by speckx 4 days ago
318 points by speckx 4 days ago
https://web.archive.org/web/20260603023617/https://www.acdw....
> I am now generating this website with Clojure As everyone knows, you are not a true lisper until you have written your own static site generator. It gave me such a great high with how easy it was to add my own "templating engine" on top, implemented all using macros. The downside is that the crash came hard; there is so much more to a good static site generator such as optimizing the output, supporting scoped CSS, server-side rendering of SPA framework components, and of course integration with the Node ecosystem (for better or for worse there is just so much useful stuff). I have since moved over to Astro. It's still fascinating how far I was able to push my own SSG all by myself though. Heh, inspired by hiccup, I ended up implementing my favorite Clojure templating library but in Nix, exactly for the purpose of static site generation :) Even have a nifty demo of how it looks for that, it basically looks/works the same as hiccup: https://emsh.cat/niccup/examples/blog/ Funny, learning Janet I exactly did that. Was quite a fun experience with the built-in PEG, so I did markdown parsing from scratch. Maybe eventually I will be a true lisper (fell in love with Scheme over 20 years ago but could never really use any lisp professionally. Now I at least do some small things in Clojure and babashka. I love babashka) Oh I've written an SSG in multiple variations of lisp, as well as sh, make, and most other languages I toy around with. It's been a good "kick the tires" project but I think I need a new one. Yeah integrating NPM is the big one, then you’re whole day converts to recovering from breaches > As everyone knows, you are not a true lisper until you have written your own static site generator. I think that part is quite normal. I use ruby for the same purpose,
though the only difference is that the code I use is also to be
used for dynamic websites at the same time (cgi, rack, sinatra, in
theory ruby on rails but I just can't stand rails and DHH these
days, so I am in the opposition crowd). Using static websites, though,
always feel as if I have significantly less flexibility. I do generate
some static .html files as well, but they feel less useful to me, aside
from being displayed faster, of course. Once you learn Clojure's syntax and semantics, you're no longer bound to the JVM. There's ClojureScript (JS), ClojureCLR, ClojureDart, jank (C++), Basilisp (Python), babashka (SCI), and many others. This means that, if you don't know Java or don't like the JVM, you can likely use Clojure wherever you already feel most comfortable. For the most part, any Clojure code which doesn't use host interop will work on all dialects. Clojure also has support for conditional code, depending on the current dialect. This is one of Clojure's superpowers. As someone who loves Clojure, I wonder about the real portability across host languages. Do you have experience with any of these other dialects? (beyond the obvious CLJS & Babashka?) I am developing a test suite for portability of clojure.core across dialects. You can find it here: https://github.com/jank-lang/clojure-test-suite Currently, we have Clojure, ClojureScript, ClojureCLR, Babashka, Basilisp, Phel, and jank running the test suite. I have only used Clojure, ClojureScript, and Babashka in production. But I am the creator of jank. I’d like to say thanks for that - I’ve been using it on my IR version of joker: https://rcarmo.github.io/projects/go-joker/ and it’s been very helpful to pin down bugs. I build and maintain Portal, which runs on multiple platforms including: Clojure, Babashka, ClojureCLR, ClojureScript, nbb, joyride, basilisp and soon jank. The main thing that's different per platform is the os/fs/http/ws libraries but the runtime state and serialization is all the same and reused across all platforms. Also, recently I was able to get most of Portal's reagent viewers, which were designed primarily to run in a browser via ClojureScript, running on the JVM for Server Side Rendering. Clojure is the most portable language I have ever used! I am learning Clojure this week, and my test project is a calculator / unit convertor [1]. I wanted it to run in the CLI and on the web, so it targets several hosted platforms: Babashka / JVM / ClojureScript. It's a single code base written in cross platform .cljc files. I already have about 250 tests written for the abstract calculator API, run as a test matrix across platforms, so the project is already in a good place for testing a new runtime. I just learned about basilisp from the parent comment, so I asked Claude to add Python support to the same .cljc files I have, and we finished the port in about 30mins, and then fixed Python specific test cases for another 30 mins, but now all of the existing tests are passing. That's impressive in several ways. Portability is achieved by testing. You have to put the platforms you want to support into your test harness, and the earlier the better. A calculator is purely functional, so this is a fairly straight forward port and really easy to test for. I'm not sure about larger projects, but it seems like there is something seriously right about Clojure's design that makes this easy to do. for JS there is also Squint which is a light-weight ClojureScript dialect without the Google Closure Compiler indeed, light-weight means you just add a <script> and you're off to the races. There's also nbb if you're targeting node https://github.com/babashka/nbb > babashka (SCI) Correct me if I'm wrong, but isn't babashka's "host"... um.. "native", for lack of a better word? It's compiled with Graal VM native, no? Yes, there is SCI (Small Clojure Interpreter) in the middle, but that's beside the point, no? Babashka's interop is with Java, since Babashka uses a Graal-compiled version of the JVM. It's still the JVM, just baked down. This is different from interop with the native world. It's different from the host runtime actually being native, rather than a baked down version of a whole VM. Graal's native images blur the line between the JVM and native, I would not say Babashka has a native runtime. Perhaps borkdude would disagree. Might be an interesting discussion. Look at the latest babashka release https://github.com/babashka/babashka/releases/tag/v1.12.218 What do you see in Assets? Native executables, specific to an OS + CPU architecture combination, like Linux + AMD 64 or MacOS + AArch 64. > "I do wish there were an easier way to move in the ]}]})))}-ness of block ends though." If he means navigating the AST, there is Parinfer: https://shaunlebron.github.io/parinfer/ Paredit / Parinfer ruined other languages for me. It lets you navigate up/down/in/out of the Clojure AST with keyboard commands and mutate those expressions, e.g. "Split" will split open the current data structure you're in: `(a| b)` =Split=> `(a)| (b)`, where | is caret. Join is the inverse, and it works for all data structures. Navigating and manipulating code as a tree, directly in your editor. There is nothing like it. Going back to code as bunch of carefully arranged ascii chars feels like a regression. Indeed. The incredibly clumsy way we choose to edit source code has baffled me since I was first acquainted with parinfer. Having to keep the source in the shape of a valid AST almost entirely manually is really annoying. Syntax-directed editors were all the rage in the late 70s early 80s...and a huge failure, because they were a lot more annoying than any text editor has a chance of ever being. It's one of those things that, like visual programming, is absolutely and obviously The Right Thing™ until you try to implement it and use it. That said, we have made progress in both areas, and maybe we will figure them out in the future. Yes, it’s definitely not a trivial problem. But parinfer shows it can be done mostly non-annoyingly at least for lisp; what is less clear is whether it would generalize to languages with more syntax. Check out Ki editor https://ki-editor.org/ — core movements based on AST Huh, very interesting and obvious in hindsight. What languages/syntaxes does it support though? Parinfer is lucky that it's relatively small amount of syntax, so can work for entire languages with relative ease, but how does Ki Editor work with Rust for example, if it does? Special keybindings per language? Looks like it’s written in Rust and the examples are also in Rust :) Apparently it supports any language with a tree-sitter parser, which makes sense, tree-sitter is basically made for this. Hmm, but how does that work in practice? Silly and small example; adding/remove turbofish, is very Rust specific, I can't imagine that to be generalized across all tree-sitter parsers, or I misunderstand how tree-sitter is used here, but how would you add/remove/move around Rust's turbofish for example? This is borderline silly, though. It is clumsy to start. But so is walking. As is running. Have you seen people start out on bicycles? What about writing? Talking? That is to say, all things start out clumsy. And people that are good at it, no longer feel that it is clumsy. Which is why a lot of people that have been working with this for any time just don't think of this much. Such a strange attitude. If a tool is clumsy, we try to improve it, that has been the case since the first stone artifacts created a million years ago. Do you think that the (sort of) tree-based affordances that most modern code editors do support, like autoindentation and brace pairing/enclosing, are silly too? What about some slightly more advanced features, like the AST-based "extend selection" and "move statement up/down" features in JetBrains IDEs? Or do you think that the status quo just somehow happens to be exactly right and going any further would be silly? It would be silly strictly for how strongly worded it is. I should also say that there is nothing wrong with being silly. Someone may actually come up with something some day that meaningfully changes us here. That is, I am not disagreeing that it can be a little bit clunky. But, a lot of the power that experienced users have in reading code is specifically that they have built a bit of automaticity in reading it. That is, the clunky aspects of fixing it is something you pretty much have to do. You just build speed at automatically doing it rapidly. So, the status quo is to use the helper functions that you want to use. But usually after you get the experience in the clunky phase. In the blind community, navigation by indent level is pretty popular, no idea why it hasn't caught on anywhere else. I find it a nice middle ground between the craziness of vim and the slowness of traditional cursor usage. I type out nowhere near enough code for this to matter, but it's pretty cool nonetheless! With respect, this topic in particular has been beaten to death. I too liked Clojure when I tried it some years ago (agreed on the composition and data structures; both are _great_). But the real value-add is in the runtime, not the syntax. Java has a solid runtime but it's not yet as good as Erlang's, maybe even not up to the standards of Golang -- I am talking concurrency / parallelism here (for memory management I have no doubts Java is very good). And I know: green threads and stuff. Well, call me when you can do what Erlang / Golang can do. Then I'll look again, very seriously too. Programming language syntax scarcely matters. It does to some extent but we the programmers tend to over-romanticize it. The runtime and its properties are the much better thing to optimize for. Clojure is about its rigorous and pragmatic "immutability first" paradigm that you simply don't get from other PLs. LISP is much more than just a runtime syntax, such as its distinct evaluation model and metalinguistic core. The JVM was chosen for Clojure because of its reach and vast ecosystem. People have ported Clojure to other runtimes, even Beam (Clojerl), where it enjoys decent success, too. All true. And I loved trying Clojure for 3-4 weeks some years ago. Still want Erlang's runtime though i.e. the many green threads with share-nothing architecture that can communicate with each other. Clojure on JVM with virtual-threads (green threads) and communicating only via core.async channels (CSP inspired) using immutable data structures is pretty neat, FWIW. Cool. I might have to revisit, if I ever find the time. Thanks, your comment aligns with what multiple other commenters expressed. Info gets stale. Fair. You don't think Erlang has an "immutability first" paradigm? Erlang is weird in this regard. It has very strong guarantees when it comes to per-process heap that make GC much simpler: no escape hatches for mutability when most immutable languages do include them! But on the other hand inter-process communication is a form of mutability (using another process as a global mutable variable is trivial) and ETS etc. present a mutable interface. > Programming language syntax scarcely matters. Clojure brings more than syntax though... there's an opinionated take on making all data structures immutable (as in, structural sharing [1]) by default. That's a huge difference in how you architect the program and debug it. [1] https://softwarepatternslexicon.com/clojure/core-concepts-of... I do love immutability. If a language does not have it I am very weary of using it. I only made exception of Rust because of how good is it for so many things + you can design with immutability first and only use mutability when you truly have no other choice and/or just want more performance and are willing to shoulder the extra effort of verification (potentially fuzzy testing even). When it comes to concurrency, what can golang's runtime do that is so special? When I tried it, it seemed like a worse version of Erlang's for people that prefer C style syntax. Depending upon your design space pervasive immutability is a huge boon too and golang doesn't have that but Clojure does - Erlang obviously having that and more. I always wished clojerl took off. I agree Golang is a worse version of OTP, no question about it, but if you are not allowed to code in Erlang/Elixir/Gleam (which sadly is 99.9% of the projects on the planet) then Golang is the next best thing. It has footguns, sure, but with library support and discipline it can get you very far. To me it's embarrassing that PLs still tout syntax and various other goodies, completely glossing over runtime. I might be missing something. But faux humble statements aside, I feel many others are the ones who miss something -- and that's the fact that doing stuff in parallel is a fact of life for 20+ years now and it's time all popular PL runtimes finally wake up to that fact. If not, I am simply not considering them. And I am not saying that arrogantly though it sounds that way; there are some PLs that I _really_ liked and was almost heart-broken that I had to abandon them and not work professionally with them. But I have enough experience to know that runtime choice matters, a lot. For the record, Racket was one of those PLs I abandoned. I know they started working on parallelism some years ago but I had to make a decision next week back then so, Elixir + Golang + Rust it is for me. Have you tried Lisp Flavored Erlang [0]? I never got around to trying it out. I used Elixir for a couple of years, building web backends, and I truly loved the experience. I remember wanting to try out LFE but never got around to it before moving on to a different employer/stack. [0]: https://en.wikipedia.org/wiki/LFE_(programming_language) I have and I did kind of like it but ultimately admitted to myself that I no longer want to use too niche or too new PLs. Elixir has a fairly solid ecosystem at this point and I am only going to switch to something even bigger (I already use Goland and Rust as well). Love the idea of LFE but it needs a bigger ecosystem. > the real value-add is in the runtime, not the syntax. Java has a solid runtime but it's not yet as good as Erlang's, maybe even not up to the standards of Golang won't lie, this is hilarious. you got me from nodding along to being the spitting out food meme guy in a span of couple seconds. JVM runtime is undeniably the most well researched and optimized runtime in history of runtimes, specifically in realm of concurrency and parallelism, it literally carries like half the world on it's back. not to throw any shade on erlang vm - i've been a fan for well more than a decade, but other than making some interesting, but limited in practice, tradeoffs with regard to concurrency architecture, it doesn't really offer much more. go's runtime is just a different beast altogether designed with different goals in mind and with no baggage of backward compatibility with legacy. one particular detail i'm very grateful to Clojure for, is exactly the ability to use JVM runtime without having to touch any Java. > Programming language syntax scarcely matters on the contrary, it matters quite a lot. you might be drinking some of that AI koolaid, conflating our suddenly hypertrophied abilities to produce code regardless of our familiarity with the syntax or the APIs with ability to produce and deliver good quality products, but this delusion is getting reality check as we speak. a realization is propagating through the industry that being able to produce more code than you're able to review, comprehend and internalize is actually not a great thing. and that's where syntax matters - it has to be high signal/noise, it has to expose you to right abstractions and it has to be pliable to allow the codebase reflect the problem in a way that minimizes cognitive load both during production and during consumption. LLMs are language models and syntax is a crucial part of any language. LLM bashing aside (although I tend to agree), I agree with midnight_eclair. The claim that Erlang or Go are outright superior to the JVM doesn't really stand up. They're better at some things, and worse than others. Regarding language syntax, it definitely matters. In the same way the vocabulary we use shapes our thoughts, the expression of a programming language shapes the implementation. Of course, as Clojurists know all too well, it's entirely possible to write Java in any language! I don't think you, I, him and others necessarily disagree at all here, it's just that living language has defects and I can't spend 30 minutes clarifying beforehand like I am doing a math proof. To me the strengths of Erlang BEAM VM and Golang's runtime nullify their weaknesses (and of course they do have weaknesses, some are pretty hard to swallow too). To me they sit on the positive side of "right tool for the job". I just can't work with global mutability anymore. It's an endless hopeless pit of determinism bugs. I picked my battles. Respect to whoever wants to make a career out of chasing them but that's no longer me. I want to make measurable business progress when I work and not babysit defects that should have stopped existing two decades ago. I can agree with other posters that the JVM has come a long way. I might reassess if I get the time. And I am not bashing on anything here. I am saying what my experience showed me. To me it's tiring to pretend that all languages and runtimes are equal and I'll keep claiming they are not. As mentioned above: I don't think we necessarily disagree at all. Well, you are kind of using my comment to vent your frustrations about AI while it has barely anything to do with it -- but you tried to link the two, unsuccessfully. Which is not fair as you have no clue of my stance on AI and are extrapolating a bit too much. Syntax does not matter simply because it's an extremely leaky abstraction of the runtime below, is my point. Of course syntax must be high signal/noise ratio, I believe every reasonable programmer will agree. But many are making entire careers in PLs where that's not the case. Hence, in practice it does not seem to matter much, for the better or the worse. RE: runtime, try and pay attention to the parameters given in my comments. I specifically acknowledged that the JVM is a great and mature runtime but it's lagging behind on STM / actor capabilities. Tearing down a straw man is not impressive and it comes across as you trying to gain visibility by deliberately misrepresenting your discussion opponent's arguments. > you have no clue of my stance on AI and are extrapolating a bit too much apologies, but maybe next time try to elaborate more on sweeping statements like "syntax doesn't matter", because in current context my assumption for why you would say that is not all that outrageous. > Syntax does not matter simply because it's an extremely leaky abstraction of the runtime below, is my point. that would be the reason why syntax does matter, wouldn't it? nobody wants leaky abstractions! ironically, Clojure is a great example of a hosted language that does not leak much in terms of underlying runtime, as evidenced by the fact that it has been implemented on top of a variety of runtimes with decent control over cross-runtime code reuse. > acknowledged that the JVM is a great and mature runtime but it's lagging behind on STM / actor capabilities you're stating this as if it's a fact, but what is your evidence? afaik jvm has a very extensive actor model library (Akka) and clojure does include a solid STM implementation (https://clojure.org/reference/refs). the reality is that both of these approaches to concurrency are simply not popular enough, so your grievances with JVM for (allegedly!) lacking some important features relevant to them are not in sync with the demand. > Tearing down a straw man is not impressive and it comes across as you trying to gain visibility by deliberately misrepresenting your discussion opponent's arguments. don't debate-bro me bro, there are no straw men and no misrepresentations of your messages. if there are invalid assumptions - it's because instead of turning this into a dozen-messages-deep interrogation of what you really meant, i'm taking shortcuts and assuming what i believe is most plausible interpretation. > that would be the reason why syntax does matter, wouldn't it? nobody wants leaky abstractions! Well I thought we were describing our current reality, not our _desired_ one? Yes nobody wants leaky abstractions and yes they are everywhere. Syntax matters insofar as to discourage bad habits, is what I'd refine from my previous statements. Most programmers go for the default so defaults and syntax that steers you the right way to think and write matter a lot. That being said, people write FP Rust (myself included) and have plethora of JS libraries where immutability and FP patterns are the default. Which is a sad state of affairs but much better than nothing -- as it's introducing programmers to immutability and FP and they otherwise would never know. > as evidenced by the fact that it has been implemented on top of a variety of runtimes with decent control over cross-runtime code reuse. That was my top 1 reason to try it btw; I was intrigued by the fact that people are interested in making it work universally in at least two very different runtimes. To me that signals good language design and good architecture. Which I already knew; Clojure and Racket are amazing on their own. > you're stating this as if it's a fact, but what is your evidence? afaik jvm has a very extensive actor model library (Akka) and clojure does include a solid STM implementation (https://clojure.org/reference/refs). As already said multiple times in the thread -- my info is stale (as claimed by multiple posters). That being said, has Akka started making full use of JVM's new green threads? Has Java itself started introducing immutability and STM / share-nothing as first-class citizens? If not, then by the "programmers reach for the defaults first" rule above I'd think Java is not yet ready. OK Clojure has these amazing libraries, kudos. Has anybody rolled up their sleeves and said "Alright, BEAM VM's reign is over, I am making the same or better runtime as them in Java / Clojure!"? If not, I'll not yet revisit. I just don't want to deal with the endless pit of determinism bugs that global mutability nets us. The gift that keeps giving. If Akka / Golang's runtime / Rust's various actor-emulating libraries catch up to the OTP, I'll very likely drop Erlang/Elixir because it's a struggle to have a good stable employment (or even contracting lately) with them. Even if the BEAM VM is slower and has a few annoying sharp edges, its strengths nullify its weaknesses due to the nature of my work (HA web / API servers and also API gateways and orchestrators). > That being said, has Akka started making full use of JVM's new green threads? Has Java itself started introducing immutability and STM / share-nothing as first-class citizens? If not, then by the "programmers reach for the defaults first" rule above I'd think Java is not yet ready. > OK Clojure has these amazing libraries, kudos. Has anybody rolled up their sleeves and said "Alright, BEAM VM's reign is over, I am making the same or better runtime as them in Java / Clojure!"? will akka use green threads? i'm sure it will when the developers behind it deem them useful. will jvm add immutability, stm and share-nothing primitives that (i assume you allege) are missing? sure, i guess, when it becomes frequent enough ask. you make it seem as if the world of software development is in some constant battle for supremacy, but it just isn't. there is no "BEAM VM's reign". and if there was - it's unlikely that anybody would care to topple it. people just want to get their job done and they use whatever tools are available, familiar and convenient for them. > I just don't want to deal with the endless pit of determinism bugs that global mutability nets us and a lot of people agree with you. and there's a lot of tools that address that. and i can assure you, when working with clojure, even on the blasphemous mutable jvm runtime, that class of bugs is non-existent. Well, I don't think you and I disagree on the premises, with the exception of you believing that I make some outrageous general claims -- which I did not. > you make it seem as if the world of software development is in some constant battle for supremacy I could have misinterpreted other people in the past -- very possible. But I also stopped caring about "battles for supremacy" a long time ago and at this point in life and career I simply use my experience and brain to go where my work is more productive, deterministic and fulfilling. To me immutability, share-nothing actors, strong vertical scalability (where a lot of PLs and runtimes do well, not only my favorites) and DX (like live prod REPLs and generally trivial observability) are those axii along which I thrive. You and a few others seem to have emotional reactions to this which, I assure you, are very unnecessary. I ain't threatening neither your livelihood nor preferences. > That being said, has Akka started making full use of JVM's new green threads? Has Java itself started introducing immutability and STM / share-nothing as first-class citizens? Amazing how it doesn't even cross your mind that there are trade-offs to those choices. Green threads are awesome, but guess what, they come at a cost. Same for share-nothing semantics. > Has anybody rolled up their sleeves and said "Alright, BEAM VM's reign is over, I am making the same or better runtime as them in Java / Clojure!"? You are again presupposing the BEAM has an absolute superiority over the JVM. "Better runtime" makes no sense on its own. Better is always relative to something. Better for whom? For what? I'd bet that you work on a traditional CRUD enterprise software, and that IO(the database) is the real bottleneck of your app. In that case, sure, the BEAM is a solid choice(so is Python, Ruby and PHP nowadays). But let's please not pretend that is all there is to software engineering. Any good reason for your rude tone? If we are going to invoke the what crossed somebody's mind trope, I'd lead with that when talking to you -- did it cross your mind to speak calmly and not assume something "did not cross" somebody's mind? RE: your other similarly rude comment, I have not "appealed to authority" anywhere. I said that I have used multiple PLs / runtimes and made an informed choice... for me. I don't intend to add "...for me" after each sentence. It's redundant and obviously implied when it comes to tech because obviously people have made well-working prod systems with combinations of bash and Perl ages ago. So obviously people can make nearly everything work. If you don't intend to discuss out of position of curiosity but want to jump on people then I am not interested. Your first comment assumed I was "speed-running to a conclusion and squinting too hard", and this was "similar to the weird childish name-calling". I think that is in the same area(or worse) than saying "Amazing how X didn't even cross your mind". And sorry, but invoking that you have experience with X, Y, Z and thus your opinion is informed after criticizing some technology IS an appeal to authority. > If you don't intend to discuss out of position of curiosity I'm not the one making sweeping statements on the superiority of one piece of technology. Reading your other response, I think you are the one who have little to no curiosity in understanding how you might be wrong. I have been on the other side as well i.e. the Java / JVM. Hence: "informed". Your negative assumptions are tiring. Sorry that you got offended by what you quoted (and I said) but I'll drop here. > Programming language syntax scarcely matters. It does to some extent but we the programmers tend to over-romanticize it. The runtime and its properties are the much better thing to optimize for. But that really depends on what you're doing. For example if I'm not mistaken Amazon was run for a very long time on a Java backend. And so was GMail's backend (and back then GMail's frontend was, IIRC, Java converted to JavaScript using GWT). And by "early Amazon" and "early GMail", we're already talking about massive scale. It's not as if the JVM got worse since then (as someone commented: a recent addition is that Clojure now use Java's virtual threads) and it's not as if it didn't scale. So I'd say having Clojure on top of Java (for those using that Clojure: there's also ClojureScript, babashka, etc.) ain't really a problem, as long as you're fine with the occasional Java stacktrace and Java ecosystem (GP mentions that btw: that he's not familiar with Java and that, I think, can be a bit of an issue). I'm not sure Clojure is about it's syntax: I like the focus on immutability / pure functions and I do really dig the REPL a huge lot. In addition to that something has to be said as to the incredible stability of the language and many of its libraries. The big value add to me is that I can have a REPL and inspect, in dev (or in prod but that'd be wild), the app I'm working on. And manipulate it: redefining variables and functions etc. And it's not some hacky hot-reloading bolted on as an afterthought kludge: it's a real Lisp REPL. There's value in that IMO. Elixir has all that _and_ Erlang OTP's amazing guarantees. Hence I landed on it. Elixir also offers LiveBooks i.e. you can create pre-made recipes with which you directly remote into your staging / prod and do stuff. All that with immutability and potentially 6 digits of actors / green threads with a share-nothing architecture. --- RE: early Amazon / Google, sure. They made do with what they had and it was and still is a heroic effort. But can we agree that they succeeded _despite_ the numerous warts and defects of the PLs and their runtimes at the time? Not _because_ of them? I feel that people latch onto the misleading "they succeeded with language X and are big, hence the language X is great" thing way too often. No. It's not true. The only thing that follows from "big company A made it big with language X" is: "company A has an amazing engineering team". Nothing else. Are JVM virtual threads not on par with golangs's concurrency? I think core.async even uses virtual threads now If they are, I have not heard about it (which does not mean much, I check Java once a year). And if they really are then I'd give Java a serious look again because it's a mature ecosystem that was gimped by ancient runtime decisions for literal decades. As of Java 24 (Java 25 being an LTS) I'd say they are equivalent. You can use a virtual thread just like you use a regular thread and there's basically no handicaps or gotchas. In Java 21, when they were released, there is a gotcha that the pretty normal use of the `synchronized` keyword would pin a "carrier thread" which ends up blocking all virtual threads from running on that carrier thread. Pinning can still happen in some much more rare cases, same with go. For example, FFI. The memory usage, performance, etc are all go like. You can spawn millions of virtual threads with hardly and memory requirements and without overburdening the OS with context switches. The JVM also enjoys faster GC performance with virtual threads. > With respect, this topic in particular has been beaten to death. Yes and no. From the discussion here I've learned about the existence of jank, which wouldn't have come up a year or so ago and might be an interesting solution to a problem for me as it evolves (that problem mainly being me not wanting to use C++ or any of the other directly supported languages in a plugin ecosystem). So these things are worth bubbling up every now and again just for the discussion to have a chance to play out. The JVM is perfectly capable of Golang-style green threads now. As for Erlang, the creator of Clojure have commented in the past on why he dislikes the Actor model, and I think it is a fair criticism. Sometimes I see people praising Erlang VM as some panacea in which all the VMs should strive to be like. This is overly simplistic in my opinion, and ignores the huge trade-offs that the Erlang VM has. You might be speed-running to a conclusion and squinting too hard if you use the word "panacea". Similar to the weird childish name-calling people do in Rust threads (somebody met one brainless zealot and now of course they'll judge a community of hundreds of thousands of devs by that one loony). I used Java, Golang, Rust, Elixir (so Erlang). My opinion is informed. STM / share-nothing-actors lend themselves amazingly well to online services for many reasons, better explained by other people and documented elsewhere (and I did not come here to advocate but to express preference and offer the take of somebody who has been around). I am not denying that the JVM might have almost caught up in the meantime. More than a decade ago it did not. And yes the BEAM VM is absolutely and markedly _not_ a panacea. It has a few weird sharp edges. It's just that in my work I have found having to avoid them still worth it compared to the alternatives (global mutability and more primitive parallelism which was the case for the JVM for decades). I have used Clojure(JVM), Elixir(so Erlang) and a bit of Golang professionally too. So my opinion "is informed" too for that matter, but this kind of appeal to authority adds nothing to the discussion. > I am not denying that the JVM might have almost caught up in the meantime. More than a decade ago it did not. This presupposes that the JVM had something to catch up in the meantime. Again, this lacks nuance and brings nothing to the table. The JVM makes different trade-offs than the Erlang/Golang VM does, and has different strengths and weaknesses. Both of your comments completely ignores that. > It's just that in my work I have found having to avoid them still worth it compared to the alternatives (global mutability and more primitive parallelism which was the case for the JVM for decades). Clojure runs on the JVM and avoids mutability pretty well. It is amazing for writing concurrent software, and has been for many years(i.e more than a decade ago). > Similar to the weird childish name-calling people do in Rust threads I've seen people do similar things to the JVM. What can the Erlang / Golang runtimes do that the JVM can’t? Thousands of share-nothing actors (fibers / green-threads) with first-class support for communication between them, for a start. Erlang/Elixir -- immutability as well. "As a rule of thumb, if your application never has 10,000 virtual threads or more, it is unlikely to benefit from virtual threads." https://docs.oracle.com/en/java/javase/21/core/virtual-threa... BEAM threads are kinda magicsauce tho, instructions have a cost and after a certain cost total (quantums) the scheduler can divert to another virt thread to guarantee forward progress. Also the immutability rules etc make it easier to optimize this switching. Eh, reduction counting isn't magic. Golang manages similar preemption semantics without counting that many operations (some tight loops do have barriers inserted every so often, but that's the exception and not the rule). And reduction counting has some serious costs! It slows the runtime down a shitload (and the BEAM is already in the bottom half of interpreted language runtimes by speed) and makes lots of JIT-flavored runtime optimizations slower or harder to implement. I like immutability too; I wish Java and Golang did more of it. It costs a lot in terms of unexpected copies in the BEAM though, there's less copy-elision optimization than you'd think. That especially bites if you're doing a ton of message passing, because of how process heaps are implemented and how garbage collection (traditional or ETS/ThreadProgress-based) works. I think what I want is something like Golang but with goroutine-based ownership semantics (or Rust with the Go runtime and goroutines): en excellent scheduler for extremely light-weight green threads, no refcounting or reduction counting, and all the clever optimizations around channel sending and copy elision--but no ability to use a value after it's sent to a channel, and only channel-based access to shared global state. That'd get most of the benefits of process-local heaps but without the (copying, cache/memory fragmentation) drawbacks. These are all true and I have recognized those as innate limitations of the BEAM VM. For now I am OK with those but I am already skirting at the limit and I am starting to want to jump to Golang and Rust again. Obviously. But it's really nice to have the option, and none of us knows the future. I've been bitten by those "0.1% chance" things much more times than I would be not-embarrassed to admit, and I know I a not alone. I believe the point they were making is you can have millions of virtual threads on the JVM no problem. Your information on the JVM is outdated. Good, thanks for the grounding. I'll have to reevaluate at one point then. As I just posted in another comment (https://news.ycombinator.com/item?id=48384622), I'd probably drop Erlang/Elixir due to difficulties of employment and contracting -- if the more popular languages get those STM / share-nothing runtimes. What kind of software actually requires this? Honest question. Anything I can think of would probably be written by C++ devs "requires" is of course subjective, there are always multiple ways to do something. But sometimes it is convenient to model a system as concurrent execution streams, for example: multiple sessions (servers), multiple entities (games, robotics), multiple in-flight transactions (any kind of i/o or concurrent compute). Agreed these are often C++ use-cases but there are obvious benefits to using Erlang or other virtual machines: memory safety, isolation, fault tolerance. Web / API services during bursts. Or just when you _really_ don't want to scale horizontally. Elixir / Golang can do this very well. And they do. I have supervised, led and authored such projects that are in production to this day. Rust too but it's lower-level and you kind of have to hand-roll OTP which of course will always fail. from experience, during bursts it's never actual web/api server that is bogged down, it's the downstream io bottlenecks. if your accepting layer is abstracted away and implemented correctly, there is very little performance difference between different concurrency approaches and all you're exposed to as developer is implementation of your handler functions. Not the case; good abstractions are valuable, but the performance differences between runtimes are very real. Take the example of some simple HTTP<->blob store service gets slammed with millions of requests when someone using the API does a backfill via some framework on their end that aggressively scales request volume up and out. Something like, say, async Python/starlette with a coroutine per request is gonna perform slightly worse than Erlang, which in turn is gonna perform much worse than Go. You're right that those differences are sometimes marginal when the latency of whatever IO the backend's doing dominates the equation. However, in my experience huge volume surges show issues with the runtime (the thing managing/launching multiplexed request handler routines) or the ecosystem (the backend IO libraries' ability to work with the runtime's IO multiplexing and make things like request coalescing easy or automatic) more often than you'd think. It really takes surprisingly little volume to cripple a return-hello-world Phoenix app that indirects the "hello world" behind way too much middleware and message passing; it takes even less to kick over, say, a Gunicorn instance returning "hello world" at the bottom of the Django middleware stack. Golang with Gin, on the other hand, is surprisingly hard to cripple in the same way. And I say that as someone who likes Elixir and Python a lot more than I like Go! Thank you. As a guy who made a career out of Elixir (and begins to regret it recently but oh well) I agree that Elixir's throughput is not amazing. However, it can get very far and we should always optimize for the most common usages. I've personally rewritten one hobby and one professional projects from Elixir to Golang and loved the result; as you said, extremely difficult to bring down a Golang service to its knees. One clarification: Phoenix server behind Caddy/nginx fairs better btw. But, details. Your point stands. I am yet to see a Rust web/API service I wrote to _ever_ buckle under pressure and just crash. It was either an application bug (like the famous Cloudflare's `.unwrap()` error from the last weeks/months) or the Linux OOM killer. Literally never crashed. But I did witness it brutally murder a MySQL cluster because it couldn't serve it fast enough. That was both fun and terrifying to watch on the dashboards. > I did witness it brutally murder a MySQL cluster because it couldn't serve it fast enough. That was both fun and terrifying to watch on the dashboards. Haha yep. In my experience, everyone running CGI/process-per-request application servers is bullish on switching to a concurrent or cooperative runtime...until they realize they just removed the primary ratelimiter on downstream DB/service accesses. The converse war stories are also amusing: people rewrite their whole app in a concurrent/asynchronous framework and nothing changes, because the DB driver is still farming out all queries to a tiny fixed-size threadpool of connections that was the bottleneck all along.
HiPhish - 4 days ago
embedding-shape - 4 days ago
fp64 - 4 days ago
acdw - 4 days ago
tmpz22 - 4 days ago
shevy-java - 4 days ago
Jeaye - 4 days ago
Hammershaft - 4 days ago
Jeaye - 4 days ago
rcarmo - 4 days ago
djblue - 3 days ago
EnigmaCurry - 3 days ago
brazukadev - 4 days ago
JBiserkov - 3 days ago
JBiserkov - 3 days ago
Jeaye - 3 days ago
JBiserkov - 3 days ago
pgt - 4 days ago
perrygeo - 3 days ago
Sharlin - 4 days ago
mpweiher - 3 days ago
Sharlin - 3 days ago
evelant - 4 days ago
embedding-shape - 3 days ago
Sharlin - 3 days ago
embedding-shape - 3 days ago
taeric - 3 days ago
Sharlin - 3 days ago
taeric - 3 days ago
miki123211 - 3 days ago
stodor89 - 3 days ago
pdimitar - 4 days ago
lgrapenthin - 4 days ago
pdimitar - 4 days ago
sorry_i_lisp - 4 days ago
pdimitar - 3 days ago
thaumasiotes - 4 days ago
IsTom - 3 days ago
manoDev - 4 days ago
pdimitar - 3 days ago
bcrosby95 - 4 days ago
pdimitar - 4 days ago
scruple - 4 days ago
pdimitar - 4 days ago
midnight_eclair - 4 days ago
escargot4000 - 3 days ago
pdimitar - 3 days ago
pdimitar - 4 days ago
midnight_eclair - 3 days ago
pdimitar - 3 days ago
midnight_eclair - 3 days ago
pdimitar - 3 days ago
foxygen - 3 days ago
pdimitar - 3 days ago
foxygen - 3 days ago
pdimitar - 3 days ago
TacticalCoder - 4 days ago
pdimitar - 4 days ago
chamomeal - 4 days ago
pdimitar - 4 days ago
cogman10 - 4 days ago
regularfry - 3 days ago
foxygen - 3 days ago
pdimitar - 3 days ago
foxygen - 3 days ago
raspasov - 4 days ago
pdimitar - 4 days ago
lgrapenthin - 4 days ago
whaleofatw2022 - 4 days ago
zbentley - 3 days ago
pdimitar - 3 days ago
pdimitar - 4 days ago
andersmurphy - 3 days ago
pdimitar - 3 days ago
rashkov - 4 days ago
RossBencina - 4 days ago
pdimitar - 4 days ago
midnight_eclair - 4 days ago
zbentley - 3 days ago
pdimitar - 3 days ago
zbentley - 3 days ago