Java Magazine, Sept/Oct 2017
ORACLE COM JAVAMAGAZINE SEPTEMBER OCTOBER 2017 72 jvm languages ns demo hello compojure def get user by id id str getting user for id id defroutes my routes GET user id id get user by id In this example I use Compojure to set up a route for a web server on user 1 If I request this resource using curl or a web browser Ill receive getting user for id 1 Indeed you should replace get user by id with something more substantial but this shows the power of macros the ability to write a lot of code using an expressive shorthand The web server I use here is Ring which is a Clojure HTTP server abstraction Most of my experience with Clojure has been web focused and Ring has been my abstraction of choice It has been around for a long time and it has had support and commits from many members of the Clojure community Conclusion Considering the syntax and the languages strengths Clojure has proven to be a wonderfully powerful language that I love writing in Theres so much more to cover and this article touches on only a few points that I think make an enticing argument for you to try the language If youre interested in learning more about Clojure you can find out more about the language at its home site the free online tutorial that got me started or in my writings article Brad Cypert is a software engineer living in Louisville Kentucky He has a passion for Clojure EdTech and the JVM Cypert has worked for large scale tech companies such as LinkedIn and Carfax In his spare time he works on his own project Porios a Clojure and TypeScript web application that aims to provide a better experience for listening to podcasts
You must have JavaScript enabled to view digital editions.