5 ms·
My team switched to re-frame after about 6 months development, and our only regret is that we didn't do it sooner. It took about a week to switch over, and caus
by yogthos 9y ago
My team switched to re-frame after about 6 months development, and our only regret is that we didn't do it sooner. It took about a week to switch over, and caused minimal friction. The complexity it introduces is minimal, but it makes things more predictable when it comes to rendering, and it goes a long way to help with organization.
The big advantage of using re-frame in my opinion is that it provides really clean MVC semantics for Reagent. All the changes to the model go through controllers created with reg-event-db, and then the view observes the model via reg-sub subscriptions. With this approach, you can easily tell how the events update the model and interact with each other because they're all in one place.
You can see a real world app using re-frame here https://github.com/yogthos/memory-hole https://github.com/yogthos/memory-hole and I don't think it's any more complex than it would've been using plain Reagent.
- prodtorok 9y agoHow much Clojure was the team exposed to before the switch?
- preek 9y agoWell, they most probably have programmed in Clojure before. Because otherwise introducing re-frame doesn't make too much sense. Plus, you're speaking to the creator or the great Clojure Web framework luminus which I can recommend highly from personal experience in multiple projects. https://github.com/luminus-framework/luminus https://github.com/luminus-framework/luminus
- yogthos 9y agoMy team has been using Clojure for about 6 years now, but we only started introducing ClojureScript last year. Figwheel and Reagent workflow was what sold us on it.
- bpicolo 9y agoThe main thing preventing me from using Clojure on the backend has been that db libs (pgsql, mysql) seem to not be under particularly active maintenance/development, which also feels at least somewhat true for other libs in the ecosystem. HugSQL as recommended by Luminus hasn't seen any development in the last year. What's been your experience here?
- yogthos 9y agoAll the heavy lifting is done by the JDBC drivers implemented in Java. These are mature and very stable. Clojure libraries wrapping these drivers simply provide a more idiomatic API to them. I'm not sure which db libs you've looked at, but the most used one is https://github.com/clojure/java.jdbc https://github.com/clojure/java.jdbc and it's just a wrapper for the Java JDBC API. The Postgres/MySQL connections are managed by the official org.postgresql/postgresql and mysql/mysql-connector-java driver libraries. HugSQL hasn't seen much development, because it works well. I'm using it in all my projects, and it's been working perfectly for me. The library has a fixed feature set, which is taking SQL templates and generating functions that make JDBC calls based on them. Now that it's feature complete, the only time you'd see changes would be if the underlying API changed, or for a bugfix. The last commit actually happened 28 days ago, and it was a bump in dependencies. Just because the repo isn't active is not an indication that the library is abandoned. My experience with Clojure libraries, is that this is usually an indication that the library works well and most bugs have been ironed out. Looking through the issues is generally a better approach of checking the health of the project I find. If stability of database connection libraries has been your concern, I can assure you that it's misplaced.
- bpicolo 9y agoThanks for the reply! What would you recommend if I wanted something with a query-builder style API? In my head it seems like clojure would be a really great fit for that as a modular way to build statements.
- yogthos 9y agoI would recommend taking a look at https://github.com/jkk/honeysql https://github.com/jkk/honeysql that uses Clojure data structures to represent SQL statements. It's similar idea to Hiccup for HTML.
- likeclockwork 9y agoI notice that you recommend figwheel a lot, I wanted to ask you: Have you ever tried the boot tooling (boot-cljs, boot-cljs-repl, and boot-reload) and if so do you have any opinion on it vs leiningen+figwheel? So far I've personally found boot a lot easier to work with than leiningen and the cljs repl is easier to get going and integrated with CIDER.
- yogthos 9y agoI have very little experience using boot. The main benefit of Figwheel is that it allows you to retain the state while hot loading code. I find this makes a really big difference when working on complex UIs. I can get the application in a particular state, and then tweak the UI in that context. There's a https://github.com/boot-clj/boot-figreload https://github.com/boot-clj/boot-figreload plugin that adapts Figwheel for boot, but I haven't used it myself.
- likeclockwork 9y agoAh, I was just wondering if you had experience there. boot-reload[0] replicates everything figwheel does in terms of hot reloading the cljs. I started using boot because I wanted better tooling for cljs, which I think it provides. I wanted to ask if you had any experience with it because I know you have a lot of experience with cljs and was wondering if you had any insight into potential hidden costs. I agree that hot reloading is a huge upgrade over the old workflow, it saves so much time. 0: https://github.com/adzerk-oss/boot-reload https://github.com/adzerk-oss/boot-reload
- yogthos 9y agoAh I see, and yeah I haven't really used boot since I already got comfortable with lein by the time it came out. It sounds like they both work pretty well nowadays though.