Hacker News new | past | comments | ask | show | jobs | submit login
Clojure is a product design tool (2015) (precursorapp.com)
155 points by dustingetz on June 22, 2023 | hide | past | favorite | 69 comments



Om is definitely not the place to start Clojure web development. I'm not sure it's even maintained. Kit and Fulcro are full-stack frameworks but if it's just SPA then re-frame is best option.


electric is the state of the art in clojure nowadays from my understanding



I guess one note for anyone inspired is that re-frame is really just for state management - it doesn't compare to Om and definitely could not replace it.

Reagent would be the best comparison, and if you wanted something equivalent to JavaScript's Redux you could use re-frame (in addition to your rendering library). However, I think for most people Reagent's built in state management can get them a lot further than one might think.


To add, lots of Clojure programmers prefer wo work without big frameworks and prefer libraries, this avenue works well too if you are so inclined.


Should we add (2015) to the submission title?

The blog post has no date, but I found an earliest entry at waybackmachine from march that year [1].

[1]: https://web.archive.org/web/20150314172909/https://precursor... .

Edit: I see the title has been updated, thanks!


My summer promise to myself is to get into the lisps and do some new stuff. I've been stuck with C, NASM, Python and JS/PHP for quite some time now and I feel like I should branch out. Clojure seems like a good choice but CL seems to be more recommended across sites I've read.

I realize this might be slightly OT but, yeah.


I started out with Clojure, but recently have been really enjoying Janet.[0]

Janet is a tiny (the entire language, core library, interpreter, assembler, and compiler are all < 1 MB combined), some-batteries-included, embeddable Lisp implemented in C. It borrows a number of Clojure's design sensibilities but isn't married to the JVM. It has super-fast startup times, so it's great for scripting. It has a built-in event loop, so you can do concurrent stuff out of the box. And the accompanying build tool compiles straight to native executables (either statically or dynamically linked) so distribution is a breeze.

If you're Clojure-curious but want something lighter-weight with (IMHO) a much more gradual learning curve, Janet is a great pick.

[0] https://janet-lang.org


I checked out Janet and it is pretty cool. However, if your goal is to learn a lisp, Janet isn't the best option.

Janet looks lispy, but it really deviates from both core lisp and clojure conceptually.

To me, the biggest benefit of learning a lisp variant is in the concept, not the parens.

Scheme is probably the most beautiful, clojure the most fun, and common lisp the most standard. Racket is very close to scheme, has good libs, and feels modern.

I cut my teeth on 'The Little Schemer' book, and found it super enjoyable. Good luck!


I started with CL in December '20 and used it for small toy projects for about 18 months and then, when my last child was born, completely forgot it exists.

Janet looks really interesting. How did you go about learning it?


I learned it mostly just by reading through the official documentation[0], but also by looking at code examples in the test suite of the compiler itself at janet-lang/janet[1], the official contrib library at janet-lang/spork[2], and hanging out in the community chatroom on gitter[3].

Recently, one of the veterans in the community published an online beginner-focused book called "Janet for Mortals" that I wholeheartedly recommend: https://janet.guide

Aside from that, the community and ecosystem around Janet is still very much developing. I don't know of any really good tutorials on YouTube, for example, and while I know of a blog or two there aren't many. So there's totally a niche for someone to create new content, if that's something you're interested in doing.

[0] https://janet-lang.org/docs/index.html

[1] https://github.com/janet-lang/janet

[2] https://github.com/janet-lang/spork

[3] https://gitter.im/janet-language/community


Sounds interesting, I have bene following https://llthw.common-lisp.dev/ and it seems to be fine. I might need to do it twice because some of this is not intuitive to me at all.

Will take a look at Janet! Thanks for the tip!


It does seem majorly incomplete, that just gives you a very-high level overview of Common Lisp.

Not to disparage the effort, but I hate following a guide or tutorial just to learn it ends when it starts to get good.


Agreed. I wish more books, essays and tutorials were aimed at more intermediate or senior people - or at least a little higher than basics.


How does it compare to ClojureScript on Node.js?


I'm not familiar with running ClojureScript on Node.js, so I can't give a confident answer. :)


I’d recommend clojure. Clojure is a very modern feeling lisp and has nice features. I really enjoyed working with Common Lisp too and would also recommend it. Idk if I’ve ever had a better dev experience than working with Common Lisp. You do feel it’s age a lot more but it’s not really a problem. Either way you can’t go wrong imo.


I wouldn't use Common Lisp. I think it's quite archaic at this point.

Racket is, to my mind, the most interesting Lisp variant that's actively developed. The macro system / build-your-own-language facilities are like nothing else I'm aware of. This is worth learning about, because it's genuinely something that other languages don't offer. A lot of the rest of the ideas in the Lisp-family can now be found in other languages.


+1 for Racket.

omgmajk, if you care to see some random Racket code/projects, https://github.com/evdubs?tab=repositories&q=&type=source&la... has some stuff to look at.


I'll take a look, thanks!


Racket seems interesting, thanks for the advice. :)


Clojure and Janet are great options. To these recommendations I would probably add Racket (it's used a lot as a teaching language and has tons of cool experimental features) and Hy (for when you need to write python in lisp form).


+1 for Hy.

I'm a lowly systems analyst at ${large_employer}. We're allowed to have Python for data analysis and RPA, but I really prefer the syntax, editor tooling, and REPL-driven development style of Lisp.

Hy has been great!


Never heard of Hy, will check it out! Thanks


I feel like Clojure and its inventor have a kind of cultish fanbase.

When working with it professionally, I didn't feel enlightened or inspired. I felt like I was spending a lot of time tracing execution paths to see where the nulls got in, as I would with Ruby or JavaScript.

---

This is probably the cue for a Clojure acolyte to jump out of the bushes and tell me that all of this is solved with clojure.spec.


I've been trying really hard to get into Clojure as a full stack dev, but this has been my experience as well. Building a simple crud app has been a nightmare. I find that:

- The debugger sucks

- There are other tools for debugging like Portal and Flowstorm, but they involve already knowing what the problem was so you can instrument the function and call it with the same arguments

- Java stack traces make the above very hard to do.

- You're a second class citizen if you don't use emacs. Half of Clojure devs are using the EMACS according to a community survey. Calva, the VSCode extension, does lots of automatic setup to make the REPL work, and when it doesn't work, you have no way to fix it. I have to restart the REPL a lot, which I'm told is the opposite experience I should be having. It took me days to set up a project just so my REPL would switch from Clojure to Clojurescript when I evaluate in different files, and everybody I asked about this didn't understand why I would need it because they were all using emacs.

- Complaining about Javascript and React and then having your whole ecosystem wrap around Javascript and React is really obnoxious. Reagent is falling behind in React versions and it's missing out on performance enhancements. If you need to do niche React things, it's a pain in the ass.

- This might just be me, but I used Citrus with Rum and I found it to be the most over abstracted thing I've ever seen in my life. I know it was inspired by re-frame, so maybe re-frame is the same. But it's like Redux X10 in terms of verbosity.

- Call me crazy, but the Java interop is worse than other guest languages because there's huge impedance mismatch between functional and OOP.

- There are very popular broken libraries. People say "It's okay if a library hasn't been updated in 6 years, because Clojure is so stable!." This is a total myth, there have been several flat out broken libraries being recommended in tutorials.

- While people are working on frameworks (Biff, Fulcro), there are no "best choices" for a lot of problems yet and it leads to frustration just trying to make a simple crud app.

The community hasn't been unfriendly or unhelpful, but sometimes it feels like I'm speaking to aliens.


Been a full-stack Clojure dev for 5 years now, and yeah, fully agree with everything you've said. I'm actually seeing how modern languages these days have a vastly superior debugging process than Clojure can provide, and with much more helpful and easier to understand error messages.

Personally am slowly transitioning away from Clojure. The language is great, but the tooling is not. I care a lot more about tooling these days than the language.


Thank you for writing this. These emperor's new clothes reviews are a sorely needed sanity check.


I've been working professionally with Clojure/Script for about six years now and I don't regret it. I also work on TypeScript when I have to. Here are a few suggestions I have:

> - The debugger sucks

In my experience, Cursive/IntelliJ is the most mature editor setup for Clojure. It includes a step-by-step debugger but I don't really use it. Not because it doesn't work, but because there are other ways of debugging that also work, as explained below.

> - There are other tools for debugging like Portal and Flowstorm, but they involve already knowing what the problem was so you can instrument the function and call it with the same arguments > - Java stack traces make the above very hard to do.

If I don't know where the problem is, I'll look at the Java stack trace and start adding `tap>` calls to see the flow of data. Since Clojure programs are data-oriented, inspecting the state that's flowing through the function arguments is usually all that's needed. It's a bit different process, though. Can you elaborate on your issues with the Java stack traces?

Here's a relevant comment from Alex Miller: https://www.reddit.com/r/Clojure/comments/80al23/how_do_i_do...

> - You're a second class citizen if you don't use emacs. [...]

This doesn't really ring true for me even if a lot of docs are written for emacs. At work people use vim, emacs, VSCode, and IntelliJ. As I alluded to earlier, I think IntelliJ is the one that "just works". If you haven't tried it, I recommend giving it a shot. Personally, I've never been a fan of the "Clojure for the Brave and True" book because learning Clojure and emacs at the same time is a BAD IDEA, and it gives a false impression that emacs is somehow necessary when it isn't.

> - Complaining about Javascript and React and then having your whole ecosystem wrap around Javascript and React is really obnoxious. Reagent is falling behind in React versions and it's missing out on performance enhancements. If you need to do niche React things, it's a pain in the ass.

Reagent works with React 18, function components, Suspense, React.lazy, hydrateRoot, etc... Honest question: what do you feel like you're missing out on right now by using Reagent? IMO, concerns about Reagent's performance are overblown. I don't think most apps suffer from this issue, they suffer from complexity. The Reagent/Re-frame API is the same as it was when I built my first app with it six years ago and the core model is still solid. One critical thing I do think is missing is SSR integration. I recently started a library to work on this: https://github.com/rads/rain

Here are some thoughts from the creator of Helix (successor to Reagent): https://www.reddit.com/r/Clojure/comments/11uluj4/comment/jc...

> - This might just be me, but I used Citrus with Rum and I found it to be the most over abstracted thing I've ever seen in my life. I know it was inspired by re-frame, so maybe re-frame is the same. But it's like Redux X10 in terms of verbosity.

I haven't used Citrus with Rum, but I think Reagent/Re-frame is worth checking out. You're probably going to have a better experience because it's a more mature stack. If you find Re-frame too much, the Reagent ratoms still work and are as simple as it gets for state management.

> - Call me crazy, but the Java/Script interop is worse than other guest languages because there's huge impedance mismatch between functional and OOP.

> - There are very popular broken libraries. People say "It's okay if a library hasn't been updated in 6 years, because Clojure is so stable!." This is a total myth, there have been several flat out broken libraries being recommended in tutorials.

Can you share what libraries you're talking about and/or what issues you ran into?

> - While people are working on frameworks (Biff, Fulcro), there are no "best choices" for a lot of problems yet and it leads to frustration just trying to make a simple crud app.

In my opinion, Biff is the future for server-side apps. It works really well out-of-the-box and the pieces are there to improve it over time. After using om.next and getting burned by it, I haven't had much interest in Fulcro.

> The community hasn't been unfriendly or unhelpful, but sometimes it feels like I'm speaking to aliens.

I'd recommend the Clojurians Slack for support. Hit me up there (@rads) if you decide to give Clojure another shot and want some help working through some of the issues you mentioned.


Thanks for responding. I'm in the Clojure slack already actually.

> If I don't know where the problem is, I'll look at the Java stack trace and start adding `tap>` calls to see the flow of data. Since Clojure programs are data-oriented, inspecting the state that's flowing through the function arguments is usually all that's needed. It's a bit different process, though. Can you elaborate on your issues with the Java stack traces?

This, to me, is the equivalent of placing console.logs everywhere and running the request. Which isn't a terrible thing. Yes, I know Clojure is immutable and I can eval the function in a comment with `tap>`, and run it over and over again without affecting my system. But if I'm just using my site and all of a sudden something happens unexpectedly, I have no idea what function is the problem and what arguments were passed to it. It's often a nil that got passed 5 functions down. I have tried setting it up in a way that I can easily find where the problem is, and I have failed. So in reality, the debugging experience for webapps doesn't feel unlike what it would be for using react and a random backend.

> This doesn't really ring true for me even if a lot of docs are written for emacs. At work people use vim, emacs, VSCode, and IntelliJ. As I alluded to earlier, I think IntelliJ is the one that "just works". If you haven't tried it, I recommend giving it a shot

I'll have to try IDEA. Not pumped about the subscription. My personal experience with Calva, just asking multiple times over multiple weeks for help with a fullstack setup, is that people don't use it and don't care to use it. I got several "I don't use Calva" and "just use emacs" from prominent people in the community.

> Reagent works with React 18, function components, Suspense, React.lazy, hydrateRoot, etc... Honest question: what do you feel like you're missing out on right now by using Reagent?

I got my wires crossed on this one and was confusing it with something else, I apologize.

> Can you share what libraries you're talking about and/or what issues you ran into?

In general, the claim that a library doesn't need to be updated as it wraps around another library is dubious to me. But on my end, Secretary is a very popular client side routing library that was recommended in a lot of places. I wrote a lot of code for it before finding out a key piece of it was broken and nobody seemed to care.

> In my opinion, Biff is the future for server-side apps. It works really well out-of-the-box and the pieces are there to improve it over time. After using om.next and getting burned by it, I haven't had much interest in Fulcro.

I'm interested in Biff, but after trying it a bit, it seemed like I would benefit from it more if I had a grasp on fullstack Clojure development first.

In general, the Clojure slack has been a mixed bag. People are very helpful and nice, but sometimes it seems like I'm asking something simple like "What should I be using for client side routing" and nobody has an answer.


> This, to me, is the equivalent of placing console.logs everywhere and running the request. Which isn't a terrible thing. Yes, I know Clojure is immutable and I can eval the function in a comment with `tap>`, and run it over and over again without affecting my system. But if I'm just using my site and all of a sudden something happens unexpectedly, I have no idea what function is the problem and what arguments were passed to it. It's often a nil that got passed 5 functions down. I have tried setting it up in a way that I can easily find where the problem is, and I have failed. So in reality, the debugging experience for webapps doesn't feel unlike what it would be for using react and a random backend.

For me, there are many ways to approach the problem of "I'm just using my site and all of a sudden something happens unexpectedly" which are not necessarily specific to Clojure. That said, one unique feature of Clojure is that you can literally inspect data and change the code as its running in production, which is not possible in most other languages. Once you're connected to a prod REPL, you can redefine functions to include `tap>` if you want.

> I'll have to try IDEA. Not pumped about the subscription. My personal experience with Calva, just asking multiple times over multiple weeks for help with a fullstack setup, is that people don't use it and don't care to use it. I got several "I don't use Calva" and "just use emacs" from prominent people in the community.

I know that some people on the core Clojure team use IntelliJ for development. I feel your pain about the subscription cost.

> I got my wires crossed on this one and was confusing it with something else, I apologize.

All good, thanks for clarifying.

> In general, the claim that a library doesn't need to be updated as it wraps around another library is dubious to me. But on my end, Secretary is a very popular client side routing library that was recommended in a lot of places. I wrote a lot of code for it before finding out a key piece of it was broken and nobody seemed to care.

I think stability as a cultural value is the most important thing about this, but yeah, it's more of a goal than a rule. I'd suggest using reitit these days. It's well-maintained in 2023 and we use it in production for our Ring apps with no issues. It has a CLJS namespace (`reitit.frontend.easy`) which would replace secretary for you. Plus you get the benefit of routes-as-data and the same interface for both server and browser. I think the chance of this library falling by the wayside any time soon is unlikely.

> I'm interested in Biff, but after trying it a bit, it seemed like I would benefit from it more if I had a grasp on fullstack Clojure development first.

If you need help with Biff, post on the #biff channel. I think people (including myself) would appreciate the fresh perspective. If you don't want to use a framework, try creating a Ring app from scratch with Reitit and Hiccup. Use HTMX to start if you want interactivity. If you can do that first, you'll have a solid foundation to build a full-stack Reagent/Re-frame app on top it because you won't have to change routing libraries or templating languages.

> In general, the Clojure slack has been a mixed bag. People are very helpful and nice, but sometimes it seems like I'm asking something simple like "What should I be using for client side routing" and nobody has an answer.

Just use Reitit. I think you'll see it becoming more common as time goes on.


Let me tell you, I've been diving back into it and it's just the same stuff. It took me a pretty long time just to get logging working. I had to Grok Integrant again because I wouldn't understand my project otherwise. And when it comes to best practices around unit testing, it's another one of those things where no one in the community seems to be sharing much about it. I used Kit to bootstrap this project and the way it set up tests doesn't even work, but this was what most people recommended to me for starting a Clojure project

I think the vibe I have gotten working for so long in Clojure is that you're basically screwed unless you are already in a work place using it.


> I had to Grok Integrant again because I wouldn't understand my project otherwise.

You can use plain functions and `reduce` for system composition if you want. Take a look at how Biff does it: https://biffweb.com/p/thinking-about-system-composition/

DI should be used sparingly for the top-level, stateful pieces of your system. If you can't understand your program without it, is this a problem with Clojure itself or the design of the program?

> And when it comes to best practices around unit testing, it's another one of those things where no one in the community seems to be sharing much about it.

The `clojure.test` API has stayed the same for the last decade and that's what you'll see in most projects. Is the concern about how to run tests? Both of the following libraries work well:

- Minimal test runner: https://github.com/cognitect-labs/test-runner

- Full-featured test runner: https://github.com/lambdaisland/kaocha

If you install neil (https://github.com/babashka/neil), you can do `neil add test` which will automatically set up cognitect-labs/test-runner in your project. Then you can run tests with `neil test` (just an alias, you don't have to use it).

> I used Kit to bootstrap this project and the way it set up tests doesn't even work, but this was what most people recommended to me for starting a Clojure project

I don't really like the approach that Kit takes and prefer something more opinionated like Biff. I'd love to hear your feedback if you do end up trying out Biff.


Currently whenever I think of Clojure I remember this post

https://www.reddit.com/r/Clojure/comments/a79aln/clojure_web...

As far as I know the situation did not improve, I had high hopes for Clojure, but i think it will eventually be as forgotten as Groovy


Clojure seems like it’s doing just fine: plenty of startups like Logseq and Penpot are built on Clojure.

I think it’s just naturally limited because kids aren’t learning lisps in college anymore, but Python or Java instead. It takes a little effort to be able to read and work with lisps if you haven’t ever worked with one before. Clojure also adds functional paradigms on top, which folks are doubly not as primed with early in their careers.

In my opinion, clojure is a great language for experienced teams, though it’ll never be python popular. Re-frame will handle the job in OP fairly well too.


re-frame has a beautiful introduction that made the concepts crystal clear to me as someone who never used a state-management framework before: https://day8.github.io/re-frame/re-frame/ The API documentation lists the most commonly and rarely used parts before going into detail and there are many usage examples.

Reagent has a nice intro tutorial (classic todo-app): http://reagent-project.github.io and many other helpful tutorials and resources for beginners: https://cljdoc.org/d/reagent/reagent/1.2.0/doc/documentation...

However, since Reagent is still stuck with class-components for more complex behavior and relies on Hiccup, which is nice but has a performance cost compared to pure React, I am unsure about its future. Like some others in the Clojure community, I have moved to thin React wrappers like Helix and use Refx to integrate those with re-frame. It may be a bit confusing right now for beginners since there is no “golden path”.

Also, unfortunately, many smaller libraries are poorly documented and it seems like it is expected from the developer to dig into the source code to find out what’s going on.

What I found the most difficult as a beginner was how to setup a project in ClojureScript in the first place, like all the configuration in shadow-cljs, how it interacts with deps.edn, how it integrates with npm, the REPL, etc. But dev/build config has always been a weak spot for me, so it might be just that.

Overall, I still very much enjoy working with Clojure(Script), more than in any other language. Anyone who likes Lisps and functional programming should give it a try (and be sure to watch Rich Hickeys amazing talks!).


Check out uix too: https://github.com/pitch-io/uix

…it’s a reagent alternative for modern react.


> How does someone who has never built a SPA before, let alone ever build a web application in Clojure/S suppose to get started?

I think that Clojure for the Brave and True[0] is a good place to start for Clojure in general, while Web Development with Clojure: Build Large, Maintainable Web Applications Interactively[1] covers the web app side of things.

[0] https://www.braveclojure.com/

[1] https://pragprog.com/titles/dswdcloj3/web-development-with-c...


Sorry, but if you've never built even as much as a "web application" (aka website), maybe learn the goddamn basics first before you try to completely overengineer a simple page as an SPA.


Lisps have an uncanny way of staying alive for a long time. I think Clojure will continue to have a dedicated community around it for the foreseeable future, but it will always be niche.


I used to do Clojure professionally. I think the community’s disdain for frameworks really stunted Clojure’s adoption.

Currently, I’m learning Elixir and Phoenix.


http://www.winestockwebdesign.com/Essays/Lisp_Curse.html

Everything is pretty easy to build, so everyone rolls out their half-baked libraries.


Aww yes the fiction of no friction: the funnel back to blub. The way is no way.


As a hosted lisp, it doesn’t take much to keep Clojure usable. I don’t think it will be forgotten, but the ship has sailed on becoming mainstream.


I'm not sure about that. Python was a good 20 years old when it became mainstream


Related: Penpot - The Open-Source design & prototyping platform [1] is implemented in Clojure.

[1] https://github.com/penpot/penpot


I hated haml when I first saw it ... decade-ish ago? Hate it still. My current company uses it as a dying vestige of when _why and haml and hpricot were all the rage in ruby land.


Same, I really don’t like HAML or Jade or other such things as a HTML replacement. I just never saw the point, it doesn’t seem like less work than just using HTML?


I hated HAML, too, when I first saw it. However, after embracing it, I can't go back to writing ERB or HTML directly anymore. All my projects were slowly transitioned to HAML.

I'd say it was a similar case with Tailwind. I considered that everyone that was loving it was not thinking about the future, and I wouldn't make the effort to give it a proper go. Yet, I can't imagine working without Tailwind now.

Moral of the story: some tech seems odd and useless in the beginning; however, if there's enough love and die-hard fans around it, maybe there's something in it.


> I spend that time on more important things, like polish.

Ironic that Lisp is Polish Notation


I sure wish we could move beyond HTML + JS into a unified Clojure browser. HTML is what’s holding the web back and there’s no excuse for JS to be the only browser scripting language at this point.


I think that once the WASM-GC is standardized and shipped (and perhaps once WASM can directly talk to the DOM), JavaScript will lose some dominance. I think a lot of folks will stick with it, personally, but I'm excited that more languages will eventually feel browser-native.


Please no. I like that webpages are still at least somewhat document-like rather than being only and entirely app-like.


>[:p "Sentence with period after " [:a {:href "#"} "a link"] "."]

Isn't that Hiccup and not Clojure Script?


It is Clojurescript. It is just a vector that contains a keyword, map and string. The Hiccup library would convert that to HTML but at the end of the day, it is all Clojure(Script) data structures.


Yes, but the Hiccup library works with both Clojure and ClojureScript.

Edit: I guess it’s the Hiccups port that works for Cljs. Either way hiccup notation is standard for both.


Clojure has been amazing for me in rapid prototyping of command line utilities. I never quite got the web app aspect beyond plain services, and I think clojurescript suffers from the greater 14 now 15 standards thinking the JavaScript world has with tooling.


No programming language is a product design tool, what a ludicrous title.

I think there are more blog posts about Clojure than software written in Clojure that people use.


A designer who can’t code is like an architect who’s never been inside an actual building.


And a programmer who can't design is like an architect who cant draw


Not as overhyped as "web 3" though.


Someone help me get the karma needed to rightly downvote this.


If you're only interested in downvoting rather than expressing an argument, perhaps you don't have an argument


The haml/clojure comparison made me feel compelled to share the Imba (https://imba.io/) equivalent.

<p> "Sentence with a period after {<a href="#"> "a link"}."

Working demo: https://scrimba.com/scrim/cW2QWgTd


In Clojure, the HTML is just data, you can map, filter, reduce and merge it. I don't think that's the case with Imba.


map, filter, reduce and the usual suspects are great, but if you are working with something like HTML you might want to consider select, transform and traverse instead ala specter.


Before reading, I thought it is about Clojure helping designer to collaborate with engineers and getting customer insight on how the designed product is used. I was completely off.


can anyone explain the Haml 'link-punctuation ritual' to me?


reagent remains sota for frontend.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: