12 ms·
Using Clojure for Web Apps
- kgwxd 7y agoHere's the video: https://www.youtube.com/watch?v=dzGuaO38XDw https://www.youtube.com/watch?v=dzGuaO38XDw
- claytn 7y agothanks!
- nickik 7y agoPretty 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 introduction to Web development in Clojure overall.
- dmcgillen 7y agoI would have thought integrant would have been the choice over component these days.
- dotemacs 7y agoYou do have alternatives to the `component` library. This new library, `clip`, might sit better with you: https://github.com/juxt/clip https://github.com/juxt/clip
- dkersten 7y agoClip looks interesting, although my favourite 'component' alternative is Integrant[1] -- your config can be just EDN and your start/stop functions are added as multimethods. Its beautifully little ceremony. Incidentally, the Duct[2] framework which builds on top of Integrant is my favourite way to get complex applications running. Currently using it for a number of different services and its a very pleasant experience. (I'm sure clip is too, Juxt do good work) [1] https://github.com/weavejester/integrant https://github.com/weavejester/integrant [1] https://github.com/duct-framework https://github.com/duct-framework
- nickik 7y agoI use 'integrant' for my projects. I have not yet tried 'clip'.
- ilikehurdles 7y agoWhat a surprise that the stateful edges of the application are the most complex! I didn't mind component in the past but we just started a project with mount and I really dislike working with that. Seems like there are a lot of ways to shoot your own foot with any of these libraries because there is no "one true way" to integrate them into an application. I haven't tried integrant yet but everyone and their dog seemed to be using it at the 2019 Conj. I would totally start a project with pedestal today though.
- dm3 7y agoOut of curiosity - what are the pain points related to Mount?
- ilikehurdles 7y agoIts composability is a bit of a double edged sword. While it leads to a more declarative style of state management, I've found our implementation of it to lead to confusion about when /where/which states are swapped in or out. But honestly I think anyone can have a great or cruddy experience with any state management library depending on how it's weaved into the code, and I don't blame the library so much as I blame our implementation thus far.
- minikomi 7y agoFrom my experience with mount, smaller blocks composed in higher order functions which except/use parts depending on config maps etc. are key to leveraging it. It's amazing to have an app built up of composable dependencies which just click together depending on your codes dependency tree though. I found the win was thinking about what exactly was needed for each part of the app and then not fighting but embracing that tree.
- faitswulff 7y agoNavigating that slide deck was surprisingly frustrating. Clicking forward 10 times to get through a single slide must have been really annoying to present, too.
- dominotw 7y agoarrow keys seem to work ok.
- Roboprog 7y agoNot on my tablet, trying to skim it at lunch. Future consideration...
- passthejoe 7y agoHuge no.
- jgoodhcg 7y agoIs pedestal a better experience than luminus?
- dana321 7y agoHere is a link to the website of the library that they use, its pure chance that i was watching a talk with one of the creators of this library before i saw this at the top of hacker news. http://pedestal.io/ http://pedestal.io/
- elamje 7y agoIf anyone is interested, there is an up and coming Clojure web framework called Coast, https://coastonclojure.com/ https://coastonclojure.com/ For those that aren’t as familiar with Clojure - there isn’t a rails or Django for web apps, so Coast is trying to fill that void.
- wry_discontent 7y agoI'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?
- dvcrn 7y agoIMO 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
- goostavos 7y agoAfter 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 recommendations as of late, whereas the latter has more activity on github. These are not the problems I want to be solving when building something. I love the language, but the quality of Clojure's web ecosystem is... questionable. If I were to build another webapp in Clojure, I think I'd just use something widely installed like Jersey for actually interfacing with the outside world. It'll be crufty Java, but it has nice things like StackOverflow activity, massive docs, giant userbase, etc.. etc..
- juskrey 7y agoWe 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.
- lgessler 7y agoI'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?
- juskrey 7y agoProjects 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/ http://book.fulcrologic.com/ has great general SPA insights. Three pretty serious apps with fulcro so far.
- kccqzy 7y agoWe used om before om.next was a thing (back in 2014). Seeing the abandoned state of om and om.next and how it even had trouble keeping up with the latest React releases, and after maintaining a fork for a few months we switched to TypeScript. Burned once; not again.
- mnm1 7y agoWhat made you choose pedestal over compojure/compojure-api or other alternatives? Similarly, why fulcro3 over something like reagent/re-frame. I have used the latter choices and am considering switching for the my next project.
- 7y ago
- mscasts 7y agoHonest question, does anyone actually gain anything from reading slides without hearing the actual talk?
- defined 7y agoHonest answer: I feel like I did.
- bloopernova 7y agoI've been slowly learning Lisp to hack on Emacs, org-mode and org-babel. Main goal being to turn AWS JSON data into org-mode headings and org-babel data to do further work on. Very much a side project and I'm a bear of very little brain, so it's taking me a long long time. Seeing Clojure and other Lisp stuff in the wild gives me hope that I can lean on enough people's documentation and source that I can eventually learn what I need. I know some folks sneer a little at Lisp, but I really enjoy trying to learn it. I haven't felt as motivated to learn a coding language since about ten years ago when I used Perl to transfer/munge data from different LDAP systems into Zimbra. So, thank you for sharing, this is fascinating stuff.
- defined 7y ago> I know some folks sneer a little at Lisp I wonder why. Some developers I know and hold in high regard have almost venerated Lisp, so I've always thought there must be something to it. I just thought it wasn't something you could actually use IRL, but I was wrong. I found this out when I was recently motivated to learn Clojure, and now I am starting to grok their admiration.
- blunte 7y agoIt will depend on whom you talk to - perhaps how old they are, and certainly where they come from (experience wise, education wise, etc.) The usual easy excuse is about parens, but that complaint has been put to rest so many times that it's not worth replying to anymore. (And people said the same thing about Python whitespace, but now Python is at or near the top of the pile.)
- knubie 7y agoWhat 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.
- fnordsensei 7y agoI don’t think Fulcro knows how it is being served. I don’t see why you couldn’t serve it from Node if that’s your thing.
- dantiberian 7y ago> 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.
- hellofunk 7y agoThe 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.
- currentoor 7y agoThere are several commercial users of Fulcro using Node JS on the backend. I am one of them.
- knubie 7y agoI had no idea about that, guess I need to dive deeper into the fulcro docs, thanks!
- lgessler 7y agoSome 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 https://github.com/Engelberg/instaparse - re-frame: React-Redux alternative that IMO is much easier to work with https://github.com/day8/re-frame https://github.com/day8/re-frame - reagent: React wrapper https://reagent-project.github.io/ https://reagent-project.github.io/ - ring https://github.com/ring-clojure/ring https://github.com/ring-clojure/ring - fulcro https://github.com/fulcrologic/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.
- mping 7y agoMetosin stuff is really nice too (compojure-api, malli, reitit). And while we are at it, ztellman's aleph and manifold are sweet too.
- subsaharancoder 7y agoI have to echo that Re-frame is superb!!
- dominotw 7y ago> desirable in most CS curricula. most of the alogrithms and datastructures that you learn in CS were developed using mutability. I am not sure that we can even develop immutable equivalents for most of them with similar time/space complexities.
- lgessler 7y agoSure, and we could argue about whether mutable code is necessary at systems layers. But at application layers (i.e., the ones most developers work at), cost of development is almost always going to come before performance, and I think it's clear by now that OOP, at least insofar as it has been instantiated by Java, C#, and friends, has not delivered on its promise to simplify application development.
- smnplk 7y agoAfter some time with Clojure, I can not bear to look at any OO code. It's like I developed an allergic reaction to class-based programming.
- tombert 7y agoEven if you decide to do OOP code, it's better in Clojure, I think. Being able to use Protocols and Multimethods and `extend-type` allows to write OOP code in a much cleaner and clearer way than something like Java...at least I think so.
- serpix 7y agoEven worse is having been through the enlightenment and then witnessing people talk about Javascript or Scala like it is still 1990. You just want to yell to them "You're all living in a cave!"
- pinopinopino 7y agoI am more of Scheme guy and always feel Lisp is pretty overwhelming, but this looks quite clean. I like the little language for writing HTML.
- pinopinopino 7y agoBut this looks like a sql injection awaiting to happen: (defn inc! [id] (kc/exec-raw (format "UPDATE articles SET count = count + 1 WHERE id = %s" id))) (From https://github.com/tbsschroeder/clojure-webshop-app/blob/master/src/metro/components/db/articles.clj#L27 https://github.com/tbsschroeder/clojure-webshop-app/blob/mas...) You don't need format it seems: https://github.com/korma/Korma/blob/master/src/korma/core.clj#L518 https://github.com/korma/Korma/blob/master/src/korma/core.cl...
- hellofunk 7y agosanitizing SQL queries is just as simple in Clojure as in any other language (maybe more so), even if it wasn't done in this example.
- pinopinopino 7y agoIt looks like it is builtin even in the library he uses. So not sure why he chooses format.
- currentoor 7y agoI gave a talk on using Fulcro for building web apps with Clojure. https://www.youtube.com/watch?v=PMbGhgVf9Do https://www.youtube.com/watch?v=PMbGhgVf9Do
- abiro 7y agoI love Clojure and take every chance to use it, but unfortunately it’s very much behind the curve. Building web apps is more and more about tying together managed services with short scripts (aka serverless). This means that most app developers never have to deal with the hard technical problems that Clojure was designed to solve and Clojure’s slow startup time on the JVM makes it unfeasible for serverless functions. Clojurescript on Node could be a good contender, but last time I tried it, the development experience was very poor and the power of Clojure doesn’t really shine in serverless functions, so I just use Python for that which is a perfectly adequate scripting language.
- james-mcelwain 7y ago> Clojure’s slow startup time on the JVM makes it unfeasible for serverless functions GraalVM could totally change this.
- joobus 7y agoClojure uses too much runtime reflection. I tried many iterations of compiling different server projects with Graal and none worked. I could get simple programs to compile with an older clojure version, but nothing with recent code.
- james-mcelwain 7y agoI'd expect the tooling will improve over time. This obviously isn't an immediate solution for running Clojure in situations where cold starts matter, but in general I think many of the improvements coming to the JVM in the next few years will pay dividends for Clojure.
- smashedtoatoms 7y agoNot to mention provisioned lambdas if you're on AWS.
- abiro 7y ago
- jrobn 7y agoClojure and Elixir (Erlang) are my favorite languages. When you get to the point where the parens and brackets just melt away and you have this awakening. It makes me wish José (creator of elixir) would have chosen Clojure syntax instead of Ruby.