![]() There are still a lot of things I have no idea about and I hope I can find some time to continue learning. I wish I would have had more time to prepare the talk and work on the example. Hiccup still feels a bit weird to me, I am not too sure if many frontend developers are keen on working with it. There is a lot of ready made functionality available in the Ring middlewares. It was fun working on a new language and after grasping the basics of Clojure it is easy to get started with a webapp, mainly because of the Leiningen Compojure template that makes it easy to set up a new project. ![]() ![]() ![]() It contains a GET and a POST route for reading the list and adding a word and a Hiccup template. I wouldn’t say it’s production ready for now, one reason being that it stores all the data in memory only :) You can find the source code on Github. Once started you can see a list of vocabulary, add more words and look up translations. I developed a very simple application using those libraries: a tool for seeing and adding vocabulary. This is a simple example that creates one successful route and one function to handle paths that are not found. In the end a request hits the handler which transforms the request to a response.Ĭompojure can help you implement the routing for those handlers. for handling parameters, session or cookies. By default there are some middlewares configured e.g. Those are like filters in the Java servlet world and can be used to enhance the application. There is an adapter that use Jetty or another one that only relies on the Servlet API which makes it possible to deploy a Ring app to any servlet container. First there is an adapter that is used to map to an internal request/response representation and that adapts to an existing web runtime. Compared to the Java landscape there is a lot less choice, a very common combination is to use three libraries, Ring as the core library, Compojure for routing and Hiccup for templating. Building Web AppsĪs a general purpose language Clojure can of course be and is used a lot for building web apps as well. I imagine that it is difficult to decide which function is responsible for which data or task.įinally, at least to me, the docs can be confusing. It seems to be common to have a lot of functions in the same namespace. One thing that is still difficult for me is to decide how to structure programs in Clojure. For example those are all different ways to create a function, but for different purposes. It can be especially confusing that sometimes there are related but different concepts. But there are still many things to learn and when beginning it doesn’t matter that much if something is syntax, a macro or a library call. It is true that Clojure has a simple syntax that makes it easy to get started. All possible due to the efficient implementation of the data structures. Important: this doesn’t modify the existing collection – it creates a new one. Naturally many people seem to use emacs, besides that there is also Cursive (built on IntelliJ), Lighttable (an experimental IDE) and Nightcode (a very simple editor with built in REPL). Using the REPL and Leiningen alone will not be enough for you, you at least need something to edit files. Among other things it offers a simple way to build and run projects, standalone or in the REPL, a feature that is commonly used with LISP dialects. If you want to get started with Clojure it’s best to start with the very common build tool Leinigen. One aspect that I deem important as well: It seems to be a quite friendly community and I liked both of the user groups I attended, Clojure Berlin and the Clojure Meetup Singapore. while still being a general purpose languageĭue to some of its features like Software Transactional Memory (STM) and atoms it can be especially well suited for building correct concurrent applications.it is very different from all the C based languages around.I got mainly interested in Clojure because This allows for good performance even though maintaining immutability. One of its specialities are the immutable data structures that rely on structural sharing when appending or removing elements. ClojureĬlojure is a LISP dialect that targets the JVM, Microsofts CLR and JavaScript by means of ClojureScript. I’ll go into some details on Clojure, which libraries you can use to build web apps and how all of that felt to me. We were free to choose a topic so I chose something I thought I didn’t know enough about – what it feels like to build a web app in Clojure. A while ago I gave a talk at an internal event at Zenika Singapore.
0 Comments
Leave a Reply. |