Clojure Libs/Frameworks/Tooling for rapid web development

Hi everybody,

How are you?

Doing some research about Clojure, all over the net, a lot of people say it needs much less people to achieve the same results with a team of Java or C# developers.
I was wondering if this is possible only in the senior level of Clojure?

Is it true comparing Spring / Spring boot or .Net Core or Rails vs Clojure?

Can Clojure libs give the same tools/modules that Spring has?


http://www.developersbook.com/spring/spring-tutorials/spring-tutorials.php

How can I compose a similar scenario with Clojure?

Thanks.

This video might be relevant. (I’m not a real Coast user though…)

Coast is a full stack web framework… https://github.com/coast-framework/coast

1 Like

Clojure favors composable libraries over frameworks, so the general approach is to pick a library you like for each piece of functionality and wire them all up together.

A lot of what you show in that Spring diagram isn’t “relevant” to Clojure in that it doesn’t need most of those things because it’s “just” functions operating on data. For example:

  • AOP – tends to be just higher-order functions wrapping other functions – Ring middleware is a great example of cross-cutting concerns implemented as higher-order functions
  • ORM – we tend to interact with databases in terms of hash maps and sequences of hash maps – no objects means no ORM (yay!)
  • DAO – the simplicity of just reading and inserting hash maps mean no need for DAOs (and, again, no objects)
  • Context – mostly composition of simple, single-purpose libraries as needed
  • MVC – again, composition of libraries: choose Selmer for Django-style templates, Hiccup for HTML-as-data, and whatever other libraries you need in any given situation
  • Web – Ring is the keystone of nearly all Clojure web apps, there are various libraries for routing, and lots of a la carte middleware for “utility” stuff
  • Core – no objects means no bean factory, but some aspects of DI/IoC and start/stop lifecycyle still exist and libraries like Component, Mount, Integrant, etc handle that
2 Likes

Hi guys, thanks for the answers.

@seancorfield, building everything with libs, could create dependencies problems, right?

You really think, the libs approach and writing everything else by hand would offer a more flexible, better and quicker development than Spring, .net core?
I know the programmer, needs to learn the specifics of the framework besides the language, using libs only could have the same difficulties?

Specially for a beginner/intermediate Clojure user/programmer, would be able to build something like Spring with Clojure libs?

Thanks.

It could. But Clojure has an ethos of encouraging only accretive, fixative changes, rather than breakage, so picking the most recent version of any given library should work (and indeed that is the approach taken by the CLI / deps.edn tools).

More flexible? Definitely. Better? That’s subjective but I think so. Quicker? No, not necessarily. But there are any number of web app templates out there to get you started with whatever combination of libraries you prefer – and most of the work in “interesting” web apps is in the domain/business logic/processing. I think framework-based code is a lot more complex, inherently, than Clojure’s composition-of-libraries approach.

Re: frameworks vs libraries, in terms of learning – Clojure libraries tend to be small and focused so learning each is often less work than learning that same feature in a framework.

Some background: prior to Clojure, I worked in a lot of different languages that were pretty much all framework-based in their approach, dating back as far as Motif, and dealing with several proprietary frameworks (such as BroadVision – which started off in C++, then migrated to Java, and I think on to JavaScript?), as well as various C++ and Java frameworks. I’ve also designed and built open source frameworks over the decades. I can comfortably assert they are all much more complicated and harder to understand than any Clojure web app I’ve built with “just” libraries over the last eight or nine years.

When I first came to Clojure, because of that experience, I also looked for frameworks to “help” me. In fact, I even ported one of my own MVC frameworks from another language into Clojure, on top of Ring, Selmer, and Component. We even used it at work for a short while. The more I used it, the more I tweaked it to be more idiomatic and more “Clojure-y” and it didn’t take long before I could see that the framework was buying me so little value for all the code and conventions it was forcing upon my Clojure code. So I sunsetted the project. If you’re curious, I explained why here https://github.com/framework-one/fw1-clj/blob/master/README.md

As always great answers!! Thanks Sean, I will continue my studies with Closure and I hope I become a success case, Beginner to Ninja!! lol…

Awesome!!

I just read two relevant posts to this topic.

@ecsmix sorry to nitpick but it is Clojure, not Closure :slight_smile:

I know, I do apologize.

1 Like