6 ms·
A Clojure web server in (less than) 100 lines of code
- albertcardona 19y agoI have just recently created a command line utility for making clojure scripts/plugins for ImageJ, from within ImageJ. Release details very soon at http://pacific.mpi-cbg.de/wiki http://pacific.mpi-cbg.de/wiki Clojure is an excellent language for extending any java application and using java libraries.
- icey 19y agoI think your last sentence illustrates why guys like me (unfairly) have issues with Clojure wrt the JVM. I don't do Java at all; I messed around with it back in the days of 1.2 and pretty much forgot about it. It seems like a most of the people using Clojure come from a Java background, and most of the things being done with Clojure dip heavily into the Java ecosystem. Now as I said previously, I think this is an unfair assessment, from me or from anyone else. I realize that Clojure used to also live on the CLR. It's just that it is incredibly easy to implement the functionality from Java (and I suppose it was this way on .Net as well), so that it feels almost like it's loose DSL written in Java, not a full language that just happens to live on the JVM.
- icey 19y agoOK, OK, so it's really a how-to use jetty from within Clojure, but it is an excellent look into how to consume java classes from within Clojure; which some people (like me) have a hard time envisioning from the docs on the official site.
- jrockway 19y agoI really like Clojure, but I have to say that the shit smell of Java still leaks through the clean Lisp coating. sigh.
- icey 19y agoThat's really been the sticking point for me. As time goes on though, it becomes a little less irritating. Rich Hickey has done a really great job of managing where the language is going so far. Initially, I didn't even want to look at Clojure due to it living on the JVM. However, this article shows that leveraging the JVM isn't entirely terrible - sure the setup of the structures is kind of ugly, but the actual usage doesn't look bad at all. If you reframe it as a Java FFI instead of a language living on the JVM, it's a little less... smelly.
- jrockway 19y agoI don't really care about the JVM. It's just that the code ends up looking like Java translated to Lisp. Lisp: (some-method instance) Clojure: (. instance (SomeMethod)) Yuck. But not as yucky as the real Java :)
- richhickey 19y agoClojure also supports this Lispier syntax: (.someMethod instance)
- brlewis 19y agoIs it too late for you to reframe this item that way? Your title suggests it's implementing a web server in 100 lines, when really it's creating a 100-line API for driving Java classes that implement a web server.
- icey 19y agoA) You're absolutely right. B) The title I used is the title from the blog. Aside from that, it's too late for me to make the edit.