Web framework is more than routing/rendering. We need something to store data (relational please), generate validation messages and forms (internationalized), asset compilation for both js (or cljs) as well as css (or sass, garden). Maybe even throw a few "commonly used" js libraries you're going to use anyways. We also need something to manage database migrations and multiple environments (dev, test, staging).
I'd love to see a lein new _ exist that automatically created a full blown project with everything in it where I could remove/replace rather than add the rest. There's no excuse for a "rails new" option to not exist in the Clojure realm.
This framework/monolith phobia is what kills my favorite language from being practical in my day to day. I manage and work on the start through launch of 10-12 websites per year. Sometimes rails makes weird decisions (looking at you coffee script, turbo links) but I just delete those two lines in the gem file, type "rake db:setup" and praise the heavens ActiveRecord exists.
A lot of this is addressed by libraries, for example Luminus bundles bouncer by default. Asset compilation for cljs works out of the box as well. Luminus uses conman to manage a pooled database connection, migratus for migrations, and sets up dev/test environments out of the box when the project is generated.
I'd love to see a lein new _ exist that automatically created a full blown project with everything in it where I could remove/replace rather than add the rest.
That's pretty much what Luminus does actually. It sets up a project with batteries included, and you can build and deploy it right away. It comes with database config, migrations, tests, packaging, the works.
If there's a particular piece of functionality or workflow that's missing, then open an issue in GitHub and I'd love to work with you to resolve it.
Those libraries are good, but lacking when compared to the facilities that exist in frameworks in other languages. Compare bouncer to wtforms, for example; they both have similar validation capabilities, but wtforms gives you a ton of help generating HTML.
Migratus works fine, but with sqlalchemy+alembic or django or rails you can get automatically generated migrations, and full orm abstractions for your database. Sure, it's two conceptually separate concerns that are "coupled" gasp together, but maybe if I always want both of those things it's a net gain if the glue code is written and maintained by someone else.
Perhaps Luke is an architecture genius and has some way of addressing this without compromising the community's strong preference for small, single-purpose libraries. But in the more likely case, either some more comprehensive solutions need to appear, or we all just need to be OK with the fact of clojure bring a suboptimal choice for straightforward CRUD apps -- that is, 99% of web apps out there.
I think that Clojure libraries are still maturing, but also there's a difference in the workflow in a lot of cases.
For example, I predominantly use Reagent on the front-end, and HTML generation in a validation library wouldn't be of much help there. I do however appreciate the fact that bouncer cross-compiles and I can use common validation logic on the client and the server.
I've not really found ORM to be necessary in Clojure myself. I really like the HTML templating approach extended to SQL that Yesql introduced and HugSQL builds upon. My workflow for migrations is to use lein migratus create migration-name, write the migraitons, then run lein run migrate. Perhaps there could be a watcher that runs migrations automatically as they change, but I haven't really found it to be a huge burden so far.
The nice part I found is that I can run migrations and generate queries all without having to restart the app. I often run migrations, write the queries then reload them in the repl and keep going. Most of the time I don't even have any code in the db namespace since all the query functions are generated automatically.
So, when I write a CRUD app, I generally only have to write the compojure-api endpoints on the server. Perhaps it's the types of apps I personally work on, but I don't find this workflow suboptimal to anything else I've tried.
There's an argument to be made that the equivalent Clojure just has you writing the migrations directly in SQL and working with schema-less maps in your application code and is therefore equivalent.
But the Django model definitions are used to build so much more.
Forms can be autogenerated from them, for validation and rendering
The admin dashboard is wholly built on them (you might argue you could do this with Postgres, too, but NOBODY HAS IN ALL THESE YEARS. It's just too much of a pain.).
Third-party libraries for Django make creative use of them all the time. For instance, django-rest-framework uses the models to basically do all the server-side work that you just described.
Auth can be basically built-in, because the auth contrib modules have access to these features and can make a few tables of their own.
I just don't believe this is something that can be waved away as equivalent to SQL plus some helpers. Migratus and HugSQL do their jobs well, but they're simply not on the same level in terms of ease-of-use and rapid development, which I find strange because the latter is definitely something Clojure developers tend to value.
Actually the admin backend generated by django was the one thing that I wish we had in clojure. That's why I started working on closp-crud. It is nowhere near as far as django, but, if I have enough time I will at least get close to it.
That said I think it is useful already, as it generates migrations, db access layer, routes and html templates and integrates into closp.
5
u/jhirn Apr 18 '16
Web framework is more than routing/rendering. We need something to store data (relational please), generate validation messages and forms (internationalized), asset compilation for both js (or cljs) as well as css (or sass, garden). Maybe even throw a few "commonly used" js libraries you're going to use anyways. We also need something to manage database migrations and multiple environments (dev, test, staging).
I'd love to see a lein new _ exist that automatically created a full blown project with everything in it where I could remove/replace rather than add the rest. There's no excuse for a "rails new" option to not exist in the Clojure realm.
This framework/monolith phobia is what kills my favorite language from being practical in my day to day. I manage and work on the start through launch of 10-12 websites per year. Sometimes rails makes weird decisions (looking at you coffee script, turbo links) but I just delete those two lines in the gem file, type "rake db:setup" and praise the heavens ActiveRecord exists.