The Python Scene, Accepting Javascript, and Lots of REST

Life continues at a breakneck pace.  Despite my best laid plans, the surest way of getting things done at the moment is in a sort of out-order manner.  However I did want to share a brief update on my journey into the Python and web application development world.  Instead of separate long form articles, I will briefly touch upon various topics.  (Note that this post itself has been in my work queue for over 3 weeks.  Mea culpae.)

The Python Scene in Toronto: Django Toronto and PyCon

I’ve now gone to two Django Toronto meetups and really enjoyed meeting with the Python community in Toronto.  The majority of web application developers in Toronto, deal with Java, Ruby or PHP (and of course Javascript).  However the Python community is there and growing.  They are very welcoming, and I have enjoyed each of the Django Toronto meetups I have gone to.  Also I feel like everytime I go there, I learn a lot and come back a better (or at least better informed) developer.  At the last meetup, I gained a deeper insight into crafting REST web services.  Something that I immediately applied to my day job the next day.  The one funny thing about Django Toronto, is that while the Django framework is an amazing platform, many Python developers move away from it once they scale up.  That is reflected in the meetups, since the topic of different platforms such as Flask come up.

The most exciting thing that is happening in the Toronto area for Python developers is PyCon.  This will be the first year that PyCon comes to Toronto.  I will definitely be there and I have been preparing by working on some real world Python applications.  If you will be there, I’d love to meet up with you!

How I Stopped Worrying and Started to Like Javascript

Javascript has been a language and platform I have avoided as much as possible.  If I can I try to stick to fancy tricks that one can pull off HTML5 and CSS3.  However one can only go so far without adding scripting to a web application.  Plain old Javascript still is a pain in the neck in a browser environment.  In other environments, it might be different as a scripting language.  However in such cases, I usually reach for Python rather than Javascript.  In a web app environment most of my experience has been with Sencha ExtJS.  While ExtJS is a remarkably powerful and flexible platform, it is problematic.  Aside from the licensing confusion of the original versions of ExtJS, I found that ExtJS contains a lot of automagic.  Building a ExtJS application consists more of configuring a number of components, and getting them to do more or less what you want to do.  Finding the right configuration has resulted in many stressful hours for myself and many other developers that I know.  Given all that developing with Javascript has left a bad taste in my mouth, until recently.

Two main things have changed my mind about Javascript.  Aside from the fact any sort of more advanced web application requires a full-on Javascript powered client, Javascript is not an entirely evil language for the web.  Doug Crawford (of JSLint fame) makes a good claim in his book Javascript: The Good Parts, that Javascript has some nice parts.  Yes, there are some ugly parts and needs a lot of love in the coming version.  But it is quite good for what is essentially a Schema-like functional/prototype language with Java-ish syntax.  Especially considering how quickly it was created at Netscape, it is not a terrible language.  If you are not convinced, I highly recommend watching the video below:

 

 

The other thing that changed my mind about Javascript is jQuery.  After fighting with ExtJS, the minimalist approach to Javascript development espoused in jQuery is refreshing.  I essentially learned the basics of jQuery overnight, trying to firefight a work project where office politics had gone amok.  (Aside: My take on politics in general is avoid it.  Get stuff done, not argue about it.)  Yes you have to know what you are doing with jQuery, and you don’t get a fancy MVC/MVT/etc. framework with jQuery.  But if you don’t fear writing Javascript by hand, and you want a library that abstracts the cross-browser stupidity, then jQuery is the answer.  For the next big web application that I am currently writing I will definitely be using jQuery.

Lots of REST and JSON

As mentioned earlier in the post, I have been dealing with a lot of REST service and JSON.  It is an infinitely nicer and simpler manner to talk with a server application, than via SOAP and XML.  (XML has its place, but it has been overused and abused in the Java world.)  When working with Java I’ve worked with Jersey and SpringMVC for building REST services.  Spring in general just works better, aside from its crazy arcane configuration.  In Python I’ve started working with Flask to handle building REST services, which I find a lot lighter than Django that sort of thing.  Also JSON is an awesome idea.  More people should use it for more of their data interchange needs. 🙂

IntelliJ IDEA Makes It All Better

Not to sound like a promotional campaign (since I work in what essentially amounts to the advertising industry, it happens more often I’d like) but one of the best decisions I’ve made recently is to switch IDEs.  I used to swear by Eclipse as the be-all-end-all of development environments.  Then I discovered PyCharm for Python.  Soon after that I got to meet Jessamyn Smith at a Django Toronto meetup.  While were talking about the joys of switching away from Subversion to Git–Jessamyn wrote a great article about her own experiences of migrating to Git–she convinced me to look into IntelliJ IDEA as it had a better interface for managing Git operations.  She was pretty convincing, as that is my primary IDE nowadays.  No more mucking around and wasting time with Eclipse’s temperamental setup.  Things.  Just.  Work.  Meaning I can do work.

Hitting the Flask

Somethings die hard.  One of those things is my own insistence on having lots of control over my computing environment and development platforms.  This led me to using Linux late in high school.  After playing around with Django, and wanting to build my own applications I found myself hunting down various odd ways to get around Django’s defaults.  Do not get me wrong, Django has a ton of nice pre-build features and default that just work.  Unfortunately being a web application developer, I have my own experiences, expectations and assumptions.  They are not always right.  However I prefer frameworks that I can plug-and-play and give me a finer grain of control.  (Hence I prefer using Spring in my Java web apps.)  So I’ve discovered Flask, a great micro-framework for Python.  I like how it makes web programming easy, without making a whole wack-load of design assumptions.  It very much reminds of me of the best parts of Spring, and apparently it is very “Ruby on Rails” like.

Web Play Made Fun with ExtJS

At work I’ve started working with ExtJS for the user interface for the web application I’m helping develop.  I’ve always had reservations about using Javascript.  Or rather I’ve always hated dealing with inconsistencies in DOM handling in browsers.  Whenever I deal with CSS, I always hate dealing with cross-browser checking.  Fortunately with increased popularity of Gecko-based browsers (Mozilla Firefox) and Webkit-based browsers (Google Chrome), I have to deal with headaches of a browser incompatibilities less often.  However writing pure Javascript can be a bit daunting, and a library like JQuery or ExtJS comes in handy.  So I’m still not sold on the concept of building everything in a RIA (Rich Internet Application) context.  However using a Javascript library sure makes my website coding-hacking more palatable.

Web 2.0: Hype or Future?

I recently applied for a web designer job, and among the requirements was a knowledge of Javascript and this new thing, AJAX. Truth be told, I never loved (or love) Javascript and never really enjoyed most client-side based web gimmicks (applets, Flash, etc.). In a few cases, these technologies were beneficial to the site deployed. For the most part I just found them to be irritating and in the way. Not to mention browser incompatibilities (Heck, they can’t handle a simple idea like CSS correctly why should they a full blown scripting language).

Needless to say, I avoided Javascript through most of my career, and mostly used it to “authenticate” on the client side (if there is such a thing as security on the client). When I heard of AJAX, I thought oh know… another gimmick and now it wants to “grope” my precious server with its “XMLHttpRequests”. Then my good friend Dima mentioned Bindows. Interesting a full desktop-like application in a browser. Today at a web seminar by MySQL, they showcased Zimbra. An open source full communications suite in AJAX. Impressive.

So what is this Web 2.0? The idea is to get more interactive applications on the web. The goal is to integrate all the information floating on the web, condense it and present in a dynamic manner. Hence the use of AJAX (or Javascript) as the underlying front end for web browsers. Yet the idea is broader than that. Not only are computers with web browsers involved, but also the myriad of different network-capable handheld devices. An interesting and lofty goal but can it be achieved?

Technology wise, the extensive use of Javascript and XML is produces impressive results. The idea of finally separating the presentation layer from the business logic and data is commendable. Before anyone starts waving the flag of revolution and buys stocks for the Web 2.0 boom, here are a few thoughts. The use of Javascript is SO intensive there is a need for whole UI and layout toolkits. In the open source community there are around 30 right now. In the desktop realm there is maybe 10 UI development kits: Swing/AWT, Gtk, Qt, along with the native Mac and Windows widgets being the most popular. Some standards exist for linking the many parts together but they vary widely. As with any standard, every vendor has their own perspective of how it should be implemented. Microsoft who is the founder of this entire paradigm, is shifting their attention to .net, which will mean locking in the client to the platform. And a swift kick to the head for the community effort. Finally even what to expect from a Web 2.0 application is not set in stone.

My analysis is this: the current situation is a messy free-for-all. The standards will almost certainly be abused, and you can look to the usual suspects for that one. The toolkits are all over the place. Finally a known fact is that a project without a rigorous specification is going to go off on a tangent. Tangents like these cause what is called in my part of the woods “development hell”.

A case in point is CSS. The W3C has done in my opinion an amazing job of nailing down the idea of what a stylesheet should do, and how. The details are there, and the theory is beautiful. Now lets look at the vendors or what-my-web-browser-really-does side. The specification is rarely ever held to, and thanks to Microsoft’s Vader-like grasp on the browser market is abused terribly. The folks at Netscape and the Mozilla Foundation do a much better job but its not perfect. Just ask any web designer who wrote an aesthetic layout in CSS how many hoops they had to jump through to get it work on the majority of browsers. If we can not get something as simple as CSS right, then I fear other more complex technologies will simply break.

In the end, I think AJAX will benefit a few large companies. Web developers and designers will still groan and will dream of a better, simpler web. Web 2.0 will not finally get everyone on the same page. Then again, I might be completely wrong.