There are a lot of ways to provide web content. Any major programming language out today has at least one web framework available that should help you in creating webservers or webapplications. For popular web languages such as Java, there are even so many frameworks with such a variety of pros and cons that it's a challenge in and of itself to choose and find a good one to use. Not to mention that this landscape keeps changing all the time too, so competitors come and go. This scene is very different from my “from scratch” approach I followed with PHP. It takes a good chunk of time to decide on a framework and then setting it up properly takes another piece, not to forget that you need to get accustomed to the framework's library and API. This was and still is pretty unappealing to me.
Yes, frameworks can take a lot of annoying stuff off your hands and surely provide a robust environment to create your application in. But TyNET is not just an application. Its core, which is the thing I'm most proud of, is basically a web framework in itself. Using another framework to build a framework would be a silly idea. So let's focus on languages instead.
The “top” languages for webapps nowadays are Java and PHP with a whole load of runners-up close by. As stated, pretty much every language has something for the web. PHP is obviously not a choice as I want to move away from that. Java is still my go-to language today as I have the most experience with it and its web-presence would surely be a large plus. But, that too is not what I want to choose, despite the many things that speak for it. The language I chose for v5 is Common Lisp. Why oh why Lisp, you may ask. It's not exactly a very well present language and you probably never heard of anyone using it for websites. The explanation for my choice is as follows.
I've been wanting to study Lisp for many years and only really started a couple of months ago (after a failed start last summer). The language has always fascinated me with its elegance and flexibility and its very interesting character that is just so distinct from all the other languages I've had contact with before. But swooning aside, I think it's a good choice as it still has the property available I liked most about PHP, which is rapid deployment. Lisp brings a bunch of other advantages, such as being able to attach a debugger at any time and resolve issues or modify functions while the site is still live, etc. Despite what you may think of Lisp's “liveliness”, it is still very much being actively developed for. There's a couple of webservers available for it as well as even Lisp→JS compilers and web frameworks. The beauty of Lisp is that, despite its set-in-stone ANSI standard, it is ready for any kind of new development in the software world. Not to mention that it pretty much allows you to incorporate other languages directly into the Lisp syntax, making the interweaving of technologies even more seamless. Using Lisp for a proper project would also allow me to practise it for a long time.
So I've been researching things that I could use to make TyNET possible in Lisp. For a webserver I've settled on Hunchentoot, which seems to be the most well received according to the things I've found online. The next part I need is a way to easily create HTML. Generally there seem to be two methods of “templating” HTML. One is the way similar to PHP, by adding special tags or structures recognized by a parser, that then execute or manipulate HTML. I find this quite pleasing, but it's far from optimal, as it mixes code and design/structure. The other idea is to provide functions to build the HTML. This is mostly interesting for functional languages, or Lisp in specific (since it has enough flexibility to not make this completely horrible). Having HTML in the form of code is far from appealing to me though as it would force me to get away from designing a plain HTML site first and going from there. I want to see HTML as HTML and code as code.
Luckily, I've stumbled upon a Clojure library Enlive that brings a fantastic solution to this problem: Using CSS selectors on a plain HTML file to modify it and generate the correct output. This basically means that you can have a pure HTML template and hide away all your logic in the program! But it gets even better than that! The fact that you can get data through CSS selectors (using classes or IDs), allows you to perform arbitrary functions on these elements and plan for that in the HTML. So f.e. if you have different tags that all need to be looped in a similar way, you could add a “loop” class to each of them in the HTML and only have to implement the looping logic once in your code for all blocks that have a “loop” class. Awesome! I love CSS selectors, so having something like this is just plain fantastic. I'm not only ready to use Lisp for this, but even eager to get my hands on it. As you might notice though, Enlive is a library for Clojure and not for Common Lisp. Luckily enough again, there's a basic port for it, so that's settled as well.
Now that the language and server side are done, there's two more things left to figure out: Database and client side. I'll talk about the database first. So far TyNET has been using MySQL, because that's The Thing To Use. Or rather, most web applications available for free use it or offer support for it. However, I've never been a fan of the SQL way of doing things and I've even imposed guidelines to limit the SQL-ness of TyNET: No constraints, triggers, procedures or any of that jazz, keep it as simple as possible, avoid joins where possible (why I'm against SQL-ness is a topic for another blog though). This sort of lead me to be interested in the No-SQL databases that have become quite noisy in the last years. They seem to be much more fitted for my simple “store only” approach of database usage. After some looking around, I picked MongoDB and I've already played around with it a bit in Kizai (my chat/helper bot). Not much to my surprise, there's also a library for Lisp out.
Finally, I've never really used much for the client side. All the JS, CSS and HTML is pretty much hand-made (except for JQuery and a few plugins). Tools that build UIs for me were never attractive, as they tend to produce unreadable garbage code and I don't want to wade through that. Not to mention that I never liked making interfaces by dragging stuff around. Still, having good JS integration is a quite central part of webdesign nowadays. I will take a look at the Lisp→JS compiler, but I'm not sure if I'm going to end up using it. I haven't actually done much research on the client side of things, as it isn't a pressing matter yet. There's a few things I want to check out though (Ember.js as an example), so there'll be an update on this some time later.
Summing up, the current loadout for technologies looks like this: Lisp, Hunchentoot (behind Apache), Caramel, MongoDB. Next up: Mission statement. Finding a philosophy and figuring out what v5 should even achieve.
Written by shinmera