Live data from Hacker News

Using Clojure for Web Apps

github.com

31–40 of 122 posts

Re: Using Clojure for Web Apps

#31
post #29
post #17

Earlier quoted context omitted.

IMO languages like Clojure (or Go) don’t need a fully powered batteries included web framework like Rails or Django. The approach to pick together what you actually need (router, db bits and pieces, etc) with composable libraries works really great

It sort of guarantees that in a couple of years time half your stack will then be unmaintained, though (at least in my 10 years of Clojure experience).

That’s not limited to Clojure nor does it matter whether it’s a batteries included framework or not. I’m seeing this more and more, to the degree that often I’m back to rolling my own instead of relying on a library or framework that has a high likelihood to f being abandoned.

Re: Using Clojure for Web Apps

#32
post #21

What I'd really like to see is a full stack clojurescript framework like next.js or meteor. I think fulcro comes close but it uses JVM clojure on the server side, so it's not entirely possible to re-use code on either end.

> I think fulcro comes close but it uses JVM clojure on the server side, so it's not entirely possible to re-use code on either end.

You can reuse an awful lot of code between Clojure and ClojureScript using cljc files. In my experience it is rare to have code that you want to reuse between the browser and server that you can't make portable.

Re: Using Clojure for Web Apps

#33
Some of my favorite Clojure libraries in this space:

- instaparse: takes EBNF (and other formats) as a string and gives you a parser instantly (!!!) https://github.com/Engelberg/instaparse

- re-frame: React-Redux alternative that IMO is much easier to work with https://github.com/day8/re-frame

- reagent: React wrapper https://reagent-project.github.io/

- ring https://github.com/ring-clojure/ring

- fulcro https://github.com/fulcrologic/fulcro

More than any library, though, what keeps bringing me back to Clojure is its incredibly blissful set of persistent data structures. It's a pernicious accident of history that we are taught to accept references to mutable objects as normal, inevitable, and desirable in most CS curricula. It is much easier to develop, debug, and maintain immutable data structures instead, and I consider my good fortune every time I get to debug something in Clojure rather than in some reference-laden OOP soup.

Re: Using Clojure for Web Apps

#34
post #18

We use pedestal+fulcro3+pathom om.next was before that, but it seems to be almost abandoned, also fulcro author have solved a lot of depressing pain points of om.next. Those three work like a perfect Lego.

I'm thinking of writing a project with a similar stack, is there any chance your code is open source? Also, what's your experience with Fulcro been like? Do you have any thoughts about it in comparison with other Clojure SPA libraries like re-frame?

Projects are closed source, so I can share only some general architectural examples.

Experience was like.. two weeks of hair pulling, gallons of coffee and no weekends, followed by intense relief and gratitude to fulcro author Tony Kay (also pathom author Wilker Lúcio) for all that not always obvious things which make great sense in the long run. This happened to me with several great Clojure things, so I immediately knew good experience was just around the corner.

Oh and his online book http://book.fulcrologic.com/ has great general SPA insights.

Three pretty serious apps with fulcro so far.

Re: Using Clojure for Web Apps

#35
post #17

Earlier quoted context omitted.

I've used Luminus to fill that space, and I gotta say I don't think that's the best way to go for Clojure. Getting started with Luminus was fine, but it was often very confusing and I didn't understand a lot, whereas when I added things as I needed them and checked out a couple libraries, I had a lot easier time debugging what was wrong. What's going to make Coast different?

IMO languages like Clojure (or Go) don’t need a fully powered batteries included web framework like Rails or Django. The approach to pick together what you actually need (router, db bits and pieces, etc) with composable libraries works really great

Are either commonly used in the way Rails, Spring, and Django are? Clojure is niche but Go is big and I don't see many webapps powered by Go like they are in Ruby/Java/Python with Rails/Spring/Django. In the web world most Go programs I see are API backends.

Here's why I think "just use composable libraries" is a bad idea:

First it isn't very friendly to new developers. You tell them to go out there and find their libraries and they have zero clue where to start.

The second problem is its not very friendly to developers with a couple years experience either. Frameworks take care of so much stuff that most people don't know they need to take care of. Not just obvious things like connecting to an RDBMS but also very basic stuff that every website will need like CSRF protection, session management, etc.

And finally, when you rely on a wide variety of micro libraries you're actually relying a wide variety of other developers. What is going to have more support and development in the future: 10 libraries split across 10 developers with varying levels of commitment, or 1 framework with a group of developers working together on it?

You don't need to build your framework like Rails or Django. You could make it easier to plug in other libraries. But it should have a sane default for everything it needs for the benefit of both new and intermediate developers. Spring kinda works like this. It's easy to use Spring libraries for different parts but you can also just use your own.

Re: Using Clojure for Web Apps

#36
post #5
post #3

Pretty simple Webapp that you could have done 7 years ago. That not necessarily a bad thing but I wouldn't develop a webapp with those tools. Specifically the 'Component' library. I really didn't enjoy working with it and it one of the most complex to understand parts of our web application. So while this seems like a fun set of slides (I have not watched the presentation yet), it's not what I would call a great intr…

You do have alternatives to the `component` library. This new library, `clip`, might sit better with you: https://github.com/juxt/clip

I use 'integrant' for my projects. I have not yet tried 'clip'.

Re: Using Clojure for Web Apps

#37
post #17

Earlier quoted context omitted.

IMO languages like Clojure (or Go) don’t need a fully powered batteries included web framework like Rails or Django. The approach to pick together what you actually need (router, db bits and pieces, etc) with composable libraries works really great

After having gone through this, I now disagree. There are a vast many things in which I am not an expert. The pick and choose / compose your libraries / lego approach sounds great until your trying to weigh different options (of which none seem to have a wide enough install base to be truly battle tested). Is buddy/buddy-auth the way to go for security? Or is it Friend? The former seems to receive more recommendation…

I generally agree with your statement, otoh I have used some libs that are not being actively maintained for years and they still work, out of the box.

Clojure strength is its weakness. But yes, there is a long way to make it more beginner friendly

Re: Using Clojure for Web Apps

#38
post #28

Earlier quoted context omitted.

After having gone through this, I now disagree. There are a vast many things in which I am not an expert. The pick and choose / compose your libraries / lego approach sounds great until your trying to weigh different options (of which none seem to have a wide enough install base to be truly battle tested). Is buddy/buddy-auth the way to go for security? Or is it Friend? The former seems to receive more recommendation…

You express exactly what has kept me from doing webdev with Clojure, despite my (now perhaps irrational) love for the language. I will learn whichever language allows me to get my site/app done as quickly as possible at first. Later after I have refined and refactored enough to know what's up... then I may decide to change. Nextjs (despite the javascript), Rails (Ruby is great!... not Clojure, but pretty good), Djang…

As someone who tries to use Clojure everywhere I can, its very hard to beat Rails for pushing out a webapp (many long Clojure timers share this opinion). Clojure shines for web services that require lots of data processing in the server and for integrating with parts of the Java ecosystem.

Re: Using Clojure for Web Apps

#39

Some of my favorite Clojure libraries in this space: - instaparse: takes EBNF (and other formats) as a string and gives you a parser instantly (!!!) https://github.com/Engelberg/instaparse - re-frame: React-Redux alternative that IMO is much easier to work with https://github.com/day8/re-frame - reagent: React wrapper https://reagent-project.github.io/ - ring https://github.com/ring-clojure/ring - fulcro https://gith…

Metosin stuff is really nice too (compojure-api, malli, reitit). And while we are at it, ztellman's aleph and manifold are sweet too.

Re: Using Clojure for Web Apps

#40
post #21

What I'd really like to see is a full stack clojurescript framework like next.js or meteor. I think fulcro comes close but it uses JVM clojure on the server side, so it's not entirely possible to re-use code on either end.

The vast majority of business logic code is portable between Clojure and Clojurescript, and the cljc file extension allows the same source files to be used on JVM or in the browser.

Even asynchronous code with core.async is portable! In browser, it will be single threaded while on JVM it will be multithreaded, without any extra work from you.

Post reply on HN