Here i will post series of articles about how to make simple web app in Clojure. I plan to talk about how to start building web app, how to upload it to heroku, how to upload images, use ClojureScript and so on. I am not very experienced programmer and worked mostly with ror framework so any comments and suggestions are welcome.
These notes mostly for beginners like i am. Some day i decided to build prototype for my web project and try new thing like Clojure for it, that was pretty yeasy and joyful.
It took me about 2 weeks to build clojure web app.
You have many options to start web app now days. Some of my favourites:
- yii framework php
- play in scala
- ruby on rails
I worked with ror mostly and just tried to make very simple app with others.
They are fine frameworks and languges but all of them praise OOP paradigm. I have no big experience with programming but i can say that this concept is overcomplicated from my point of view. I even think that people just didn’t understand objects concept and started using it in another way, mostly wrong way. I could say that nowadays it’s Class programming.
“Classes orginize your code” ! I saw this phrase on some experienced programmer blog and it really is, that how most people think about this. You have to architect classes and hierarchies of classes to make things work but what about objects ? Any way you have to learn how this stuff works and it takes time, in some cases a lot of it.
Nowadays you can choose between complexity and simplicty. Long long ago was born Lisp. I don’t know why but it was mostly forgotten for years till these days. Clojure mostly reincarnation of this simple and powerfull language and concepts behind that. Now i understand why scheme is the language that people learn at computer since course in MIT. It simple and powerfull and it’s ideal for beginners.
You can learn most vital concepts in Clojure in a day. Syntax in an hour. And you can start doing things rightaway. So did i. I used only functions. No classes no variables no state no class hierarchies and thinking how this stuff works and why.
Clojure web app development. Starting point.
For simple web app i choosed “Noir web framework”. Most recent version 1.3.0-beta10 as of time this writing. It lucks good documentation and examples but is enough for start.
In order to compile and run your app you also need Leiningen. I used 2 version.
So what you need to do.
- install Leiningen
- make Noir web app via this command in console
lein new noir mywebapp
It using noir template for the project.
$ lein new [TEMPLATE] NAME # generate a new project skeleton
We get simple structure for our web app and can run it.