Author: I wanted to consolidate some of the steps I did to get the basic functionality for Common Lisp web applications (CRUD, User Authentication, Domains, etc.) as its a big pain to keep revisiting and troubleshooting which step I did wrong.
So I saved these notes in guide form, hopefully its useful for others. The trick is to extend a lot of this, all the hard parts are here - the rest is just basic Lisp, HTML, JavaScript, building upon this platform.
Highly recommend Lisp for Web Development, its *much, much better* than any of the other frameworks out there! So easy to use. Do learn HTML, CSS & JavaScript though. Esp. JavaScript as you would want to offload some of the computation to client-side to reduce your server costs.
Big Thanks to u/linnilbobo on Reddit for his code on user authentication in Hunchentoot - that was one of the missing pieces for me.
There are many views on this (so please don’t take my word as gospel), but from my experience, Lisp gives the following benefits:
- A fantastic and easy to use open source web server in Hunchentoot
- Very easy integration into databases like PostgreSQL. Just looking at my guide shows how easy all this is (assuming you know lisp, but if you look at the number of lines of code - it’s not that much)
- Live debugging - I.e. I can recompile certain functions and don’t need to restart my web server! That’s a huge win in my opinion
- It’s hard to explain, but I find Lisp very transparent. With knowledge of JavaScript, HTML, CSS and Lisp, I am very comfortable building any web app. Whereas when I use various web frameworks like react, angular, etc, I have to spend so much learning it’s idiosyncrasies (which to me is a waste of time since these frameworks keep changing), and then usually I hit a brick wall somewhere. Other frameworks in my opinion obfuscate too much - they solve for easy wins (which they do), but anything more complex and you are fighting against the language, spending hours on Stack Overflow for solutions to what should be simple problems. In my opinion
I spent 1-2 weeks setting up a CRUD app with Angular and still don’t know the best way to use it. With Lisp, I did the same in one day. It was that experience that pushed to me to learning and using Lisp (I was a complete beginner at the time). For me that was enough proof
- Stuff like NPM I don’t like because there are so many dependencies (which break from time to time) and I’m worried somebody could be putting in bugs / trackers in these packages. I don’t like having many dependencies
- Ability to write DSLs (Domain Specific Language) where I can easily write macros to generate JavaScript and HTML for me from Lisp, increasing the cohesiveness of the whole program
All that said, Lisp by itself is not enough. HTML/CSS/JavaScript are much more important - Lisp is the magic server side plug for all of this, and in my opinion, better than server side JavaScript because Lisp is a very well thought and well featured language (JavaScript is as well, but I think Lisp, at least to me, is slightly more enjoyable to write in).
I find the issue with Lisp is that it’s not used much, so outside of some very good packages, there are many parts which are easier to do in other languages / frameworks with much bigger ecosystems. For me, web development is the exception, because all you need is HTML/CSS/JS and a good server side language.
Other languages are also very good, so this is just a personal opinion. If you like to invest your time in one core language, and not have to keep learning new web frameworks, I recommend Lisp.
It’s very good for solo programmers or small teams, but I do think it’s not suitable in larger teams as I do find lisp code can be a bit harder to read and also most people don’t use lisp.
So in my uneducated view - if you have spare time, if you like working from first principles and have a scientific / mathematical mindset, and if you are working alone or in small teams, I highly recommend Lisp for web dev.
If you are more business minded and want to scale your project quickly and hire more developers, then using an off the shelf package makes more sense.
If you are time poor, stick to what you know - the differences aren’t THAT great, and it’s better to build something now than to spend most of your time learning a new language (unless you have time to devote to it - in which I highly recommend learning Lisp :) It really makes me smile every time I code in Lisp :)
This is hand-wavy and bordering on woo, also not specific to web development.
In my experience, Lisp has this sort of brain amplification power. Whatever weird idea I have about how to think about a problem, I can kinda smush lisp into shape so it solves that problem. with language X, I have to think about how to I say what I'm thinking in X. It's kinda like spending some time working in C then jumping to python. It's far less hassle to get the idea out there. It's not exactly like that, but it has that flavor.
Two sort of related points.
Lisp is pretty transparent. If you need to think about pointers and stuff, you can do that and it'll mostly stay out of your way. But if you don't, you don't.
Lisp will let you represent whatever crazy notion you have in your head. You may understand why the code works, but explaining to other people can be tough, because your internal abstractions are probably not what other people intuitively think about when looking at the same problem.
Not saying any of the above is good or bad. It is different. With java or go or whatever, I tend to think a lot about how do I represent this in java or go or whatever. With lisp it's the closest I've ever gotten tot my idea out there, naked. That can be powerful, or scary, or both.
You might take a look at "Paradigms of AI Programming: Case Studies in Common Lisp". That shows a lot of tricky problems tackled in a pretty breezy way. Want to build a computer algebra system? Not that tough to get something working. Work through Norvig's approach and you can get something pretty good working pretty quick.
Nice points. Going through SICP and solving problems using scheme, I did experience the “brain amplification” sensation.
Once you flesh out the idea in lisp, it’s just a matter of implementing it in the language of your platform. It’s like doing ‘architecture’.. Lisp is about aesthetics and beauty
One major Lisp thing I've been musing about lately...
C programs don't understand other C programs. Of course the C compiler itself is an exception but in general you don't expect to be able to feed your compiled C .exe another C source file and do anything useful with it. That's crazy talk. Likewise with Java or C++ or Fortran or...
But Lisp programs understand Lisp programs. The compiler is always available even at runtime. And not just the compiler but the lexical analyzer, the parser, and the evaluator too. Output is also easy: You can write a Lisp program that builds Lisp data structures dynamically in memory and then prints them to a text file as Lisp source code. Which you can later read back in and execute as a program.
This kind of thing is so natural in Lisp that it opens up whole new ways to think about code. So why is this useful?
One example: In many programs you need configuration files. So you write configuration files for C programs in XML or yaml or JSON and then use a library function to parse them. Why don't we write configuration files for C programs in C syntax? Well, because C syntax is rather inconvenient for this purpose and because there aren't many C libraries that parse C syntax. Besides, how do you handle includes, compiled libraries, macros, linking, etc? Again, crazy talk.
Not so in Lisp. Lisp syntax is very convenient for configuration files (because it's s-expressions) and the parser is built-in. So you write configuration files in Lisp and parse them at runtime! If you change a setting at runtime, it takes not much more than one line of code to automatically print a new configuration file. Which you can then tweak with a text editor if you so desire.
Another example: Macros. Macros use this same principle but there's no external file involved. Macros change Lisp's syntax so you can write more advanced programming constructs and translate them to basic Lisp at compile time. It's the same idea as Typescript-- Typescript is a Javascript program that converts a type-safe version of Javascript into basic Javascript. But Typescript was a one-off major project--like building a compiler. In Lisp the toolkit for source-to-source translation is built-in and Lisp programmers use it every day.
So I saved these notes in guide form, hopefully its useful for others. The trick is to extend a lot of this, all the hard parts are here - the rest is just basic Lisp, HTML, JavaScript, building upon this platform.
Highly recommend Lisp for Web Development, its *much, much better* than any of the other frameworks out there! So easy to use. Do learn HTML, CSS & JavaScript though. Esp. JavaScript as you would want to offload some of the computation to client-side to reduce your server costs.
Big Thanks to u/linnilbobo on Reddit for his code on user authentication in Hunchentoot - that was one of the missing pieces for me.