Friday, November 2, 2012

Hunt for a web framework that works

Never Internet Explorer
Never Internet Explorer (Photo credit: Wikipedia)
I have this personal project I want to do that includes a web application and I want to learn something. So I'm on the hunt for language, environment and framework.

Other stuff

I did some PHP a few years back and definitely don't want to go there anymore. I also did some .NET and it's even part of curriculum here at FRI. But clicking on wizards in Visual Studio feels weird to me. Not like development should be done. And I also use GNU/Linux as my primary(and only) OS, so that's out of the water. I did read about java server pages and faces and even tried few things out. But luckily I didn't get to do this project I was preparing for and I didn't need it. It looked ugly anyway. I did some flirting with GWT, does that even count as a web framework? 

Node.js

I heard about nodejs quite some time ago but I put off looking into it because my js was really rusty. But recently I brushed up on my javascript skills(to do a "compiler" into js) and gave it a shot. Node is good. It's fast, it's agile, it makes you think in a different way. I was feeling empowered. I did some simple stuff and I liked it.

Static vs dynamic

Later I kinda got a job as Ruby on Rails dev. And I hated it. So I didn't take it. It would take up too much time anyway - I'm a student. Ruby is okay. Rails is okay. But problem was the size of the problem. Application we were buiding(a team of devs) was quite complex and I came into existing(moderate size) ruby code base. Learning ruby and rails as I go was fun, but navigating the project was pain in the ass. Of course documentation was non existent and IDE couldn't help me because it didn't know. So a lot of regex searching and walking around asking stuff. Also refactoring...Inevitable but hard. 
This cemented my opinion on static vs dynamic typing. (Static for everything but a short script, more on that another time).

Scala

Then I learned about the good parts of static typing through scala and haskell. Doing web in haskell seems a bit intimidating(I will give it a go eventually, I promise) so I roll with scala. I looks there are two big names here. Play! and Lift. I watched a few talks and read few blogs about both to see central points. 
Big difference seems to be their view on state. Lift goes for stateful, Play for stateless. Play kinda seems like it has a bigger community, but their documentation is stellar and they're now part of Typesafe stack. No brainer then. Play it is.

Play! framework

I dived into documentation. Reading samples and explanation about infrastructure and APIs. Samples really clicked with me - it felt like porn. No analogy, reading elegant scala sources for a web app for my first time felt like I was doing something naughty, like things shouldn't be that good.
Live reloading is great too. A friend of mine is a J2EE dev and he's constantly nagging about build and deploy times. I get that near instantaneous. And compile time checking of routes and templates? Oh my god, yes. Bear in mind, compile time is all the time. When I hit ctrl-s for "save all open files" I quickly see if compiler has any complaints, even before I refresh the browser. 
I just did some experimenting with features then...for a few hours. Everything feels so simple but powerful. Why nobody told me about this before?
Okay, it has to have some weaknesses but I didn't find them. Yet. And that's what counts.

Heroku

Now this is just a cherry for the top of my cake. It took me two minutes to deploy my hello world app, and that includes time needed to install Heroku's tookkit. You just create an app and push to remote git repo. Heroku detects it's a Play/Scala app and install dependencies. Rest is done by SBT. And it just works. Hassle free deployment for developers. Yay.

Now I have my stack and even a host. So I just need to write an awesome service and generate traffic. How hard can it be?
Enhanced by Zemanta

2 comments:

  1. Why did you chose Heroku for deployment? Have you thried also OpenShift for example or any other?

    ReplyDelete
    Replies
    1. Because it's easy.
      I made an OpenShift account too. Event talked to one of the guys from RedHat(Cerar I believe?) about the limitations of the infrastructure during summer.
      Anyway...Heroku has native support for Play. I did (literaly) one line of config and then "git push heroku master". Works. Add a database: "heroku addons:add heroku-postgresql:dev". Another line of config and a line in sbt(scala build tool) for postrgres driver dependency. "git push heroku master" and i have a postgres in cloud. Beat that!

      Didn't actually deploy anything to OpenShift(yet!) but as far as I undeerstand you need to provision a machine and manually put up a database. DevOps are cool, but at this moment I'd rather spend my time programming app logic. So heroku's plugins are WIN for me. It can get pricey if you get alot of traffic...but it's something like 30% more than EC2...and I believe fully managed architecture is worth it.

      Delete