Alex’s Notes

Alex’s Notes

Alex Reid  //  Software developer from Newcastle upon Tyne, UK. All of the dubious opinions stated here are purely my own and not those of my employer.

Apr 28 / 2:53am

Developers, eggs and baskets

I am currently handing over the system that I have worked on for the past three years. It is written in ColdFusion. 

I have noticed two things:

  • some developers are initially wary of something less familiar, while some are keen to embrace something new
  • an implicit assumption is made that you must be wedded to that platform you work in: "I am a .NET developer so you must be a ColdFusion developer."

In actual fact, I see myself as just being a developer.

Someone actually remarked that they were surprised that my new employer made use of ColdFusion. They don't, of course. Do developers get typecast? 

I develop in many different languages and frameworks. Java, mainly, but also C#, T-SQL, Python, Objective-C and Cocoa. Does this versatility make me a jack of all trades and a master of none? Some would say yes.

I just prefer to consider myself as someone who is not shackled to any particular platform. Us developers have transferrable skills which mature throughout our careers. Implementation languages and frameworks are only half of the story. I'm not saying that it is wrong to specialise and become expert in something. I am not saying it is wrong to specialise. I'm saying it's wrong to deny the existence of any other technology. 

I understand why management favour a unified and supported technology path. There's less risk. It makes sense. If you have a pool of .NET developers available, in theory they should be able to maintain each others code. 

It can, however, be a ball and chain, particularly in a mobile context. 

Successful companies and individuals will think outside their bubble and comfort zones.

It's simple economics. It makes sense to write software for the iPhone because it's huge at the moment. The tooling and documentation for the iPhone SDK are excellent.

Does this mean I'll burst into tears as Android's popularity continues to rise and the iPhone's popularity inevitably wanes and Apple go bankrupt (despite the billions) if we are to believe many of people I follow on Twitter? Will I have wasted my life in Xcode, typing square brackets? Not at all. I won't have called myself an iPhone developer. I'll still have been just a developer - developing for iPhone, Android, BlackBerry and ... whatever else.

Being a mobile developer in 2010 will be very different to being one in 2015, that's for sure.

Loading mentions Retweet

Comments (5)

Jul 13 / 1:54pm

GWT - it's not you, it's me

Having sung the virtues of Google Web Toolkit for well over a year, I did an experiment. I rewrote a section of a prototype GWT application using JavaScript and YUI. It took me less than two hours, including time to consult the excellent documentation. The YUI version was deployed this afternoon.

Those of you who follow me on Twitter will be used to my occasional rants about web development. I love my job, but almost every day think that there has got to be a better way to do things, particularly on the client-side.

As we all know, the web started out as a way of displaying documents, regardless of computer type. This collection of hyperlinked documents somehow managed to become the runtime of the 21st century. It doesn't matter if you run OS X, Linux, Windows - a vast amount of what you do on a computer these days is in a web browser. Fact. Don't believe me? Unplug yourself from the network - turn off your wireless card. See how long you last.

Due to our reliance on the browser, JavaScript has become the world's most popular language.

Douglas Crockford, creator discoverer of JSON and author of one of the few decent JS books excellently sums up the misinformation and understanding that surrounds JavaScript. "...JavaScript has more in common with functional languages like Lisp or Scheme than with C or Java. It has arrays instead of lists and objects instead of property lists. Functions are first class. It has closures."

So why on earth did I attempt to write a web front-end in an arguably inferior language: Java, with the Google Web Toolkit?

I'll hold my hands up. Despite being able to churn out a lot of JavaScript code, I guess I didn't know JavaScript.

When Google released the Google Web Toolkit sometime in 2006, I was intrigued. I had dabbled with creating AJAX-y front ends of my own but almost consistently had ended with very brittle code. $$ and $A and $ functions made me feel unusual. Debugging was impossible. Things would stop working - yet no error messages would be given. With this in mind, GWT made perfect sense. A good UI widget library, strong typing, a compilation step to catch errors early, debugging, excellent IDEs, optimized code for each browser masking quirks and behaviour variation..... oh my, I was sold.

I enjoyed the rigidity of working in Java for client as well as server-side work. Using Eclipse I was soon refactoring frequently, being forced to define interfaces, unit testing, creating mock objects, using dependency injection, creating components, thinking in terms of events rather than forms and URLs... the list goes on and on.

However, in the last week I came to the realization that, with a bit of discipline, I could apply identical development approaches when using plain old JavaScript and YUI. For every perceived advantage of GWT, JavaScript had an answer. Unfortunately, GWT brought disadvantages of its own. 

  • The built in widget library - calendars, drop down menus, trees, etc - whilst comprehensive, was fairly basic and hard to skin with CSS. Remember the promise of being shielded from browser quirks and variations? Forget it. Any web front-end library is all about the widgets. YUI (and others) are arguably superior.
  • Compiling five versions for each supported browser proved to be very slow: 20 seconds on a 2.26Ghz MacBook Pro for a very small app. This may sound like a minor thing, but it did slow the development process down considerably. The rapid edit-refresh-edit development model of the web is extremely productive - live in-browser CSS and JavaScript editing are now also becoming common place. Some advantages of the compilation step can be matched by using a tool like jslint. jsunit also allows in-browser unit testing of JavaScript code.
  • Eclipse is a fine Java IDE and the Google plug-in is an excellent addition. Code generation, hinting and completion were all welcome additions having come from a text editor. Refactoring GWT code within Eclipse was something I did frequently - although ultimately my use boiled down to a semi-intelligent search and replace. My time with GWT reminded me how important refactoring is. 
  • Debugging within Eclipse only worked when running the Java code - you were not debugging the compiled JavaScript. There were differences between what happens in hosted mode and what happens in the browser. In addition, native JavaScript debugging within the browser has come a long way - particularly in recent versions of Safari and Firebug.
  • Browser speed. It was easy to forget that one is targeting a web browser. It is natural to think in terms of components, event listeners and forget about the crazy HTML that is being produced somewhere. Although this is the logical assumption to make when using GWT, it is a mistake - the result is extremely slow code. Whilst this isn't such an issue in modern browsers, it is if you want your code to run well in Internet Explorer. For instance: a complicated list of objects took 20ms to render in Safari and 4000ms to render in IE7. 4000ms is unacceptable. The solution?  Render HTML in a stringbuffer (or on server) and use element.innerHTML = ".." to inject it onto the page. You throw away all the object-orientated/component/event goodness. The issues with speed are no doubt due to the slowness of DOM manipulation routines in certain browsers which aren't GWT's fault. Regardless, this low-level work around defeats the purpose of GWT to my mind.
  • The event bus pattern I previously blogged about is trivial to achieve in JavaScript with a lot less code. Events are core to JavaScript within a browser. Custom event models are extremely easy to implement with a good library such as YUI or prototype.js. Whilst the GWT HandlerManager worked fine, I felt a disproportionately large amount of code was needed. 
  • JavaScript can be fabulous. It has closures. More can be done in less code. A callback object can be defined inline, in literal form: { onSuccess: function(e) {}, onError: function(e) {} }. I intend to elaborate on this further with some some side-by-side GWT vs YUI code comparisons in a future post.

Maybe I'll be back in a future post saying that I didn't understand GWT (or Java) well enough. GWT will continue to evolve and Google Wave, which is built using GWT, will no doubt be a seriously impressive web front-end. 

GWT, particularly the Java-JavaScript cross compiler, is a stunning feat of engineering. Maybe the coolness of the hack is what attracted me to GWT in the first place. But like so many tools made by developers for developers, the beauty lies within - in this case the API and the compiler. The over-engineered end result just doesn't do all of the effort and cleverness justice.

There is much I like and admire about GWT. I may use it again. Regardless of whether I use it in future projects, I have GWT to thank for forcing me to apply proper software engineering approaches to web client development. 

Loading mentions Retweet

Comments (17)

Jun 25 / 11:22pm

Internal developments: watch out

Bespoke developments for internal use can fall into many traps. 

Technically, it is harder to justify refactoring or behind the scenes code improvements to your client or internal customer -- the completely reasonable arguments being "it works (albeit slowly); we cannot risk instability; we need new features". As a result, there is a temptation to write, or build upon poorly structured code to get things done.

From a user interface perspective, people are trained to use the system. They are a captive audience who cannot go off and use something else so often internal system UIs are fairly abysmal. The hideousness of the SAP web-front end proves this point. This is inexcusable - if people are being forced to use a system as part of their job for hours every day, extra effort should be made to ensure the system is user friendly and works with them in doing their job. A bit like having a comfy office chair that doesn't give you backache after half an hour.

Functionally, internal systems risk becoming blunt swiss army knives - they try hard be all things to all users yet end up doing nothing well. Even if you don't plan to commercialise or sell your software, I have learnt that it makes sense to consider every change request as if the system was being developed with real, paying customers in mind.

It sounds obvious but actually putting a price on tasks, considering the ROI and the number of users who would benefit makes it possible to plan changes more effectively. Competitive commercial edge, even if imaginary or indirect, is an important driver in ensuring a system moves forward.The early adopters of the system often get confused as to why their 'order' of a few feature is not implemented. An internal system with five users is a different prospect to one with several hundred. 

Users are the lifeblood of a system should be listened to, but it can be dangerous for them to be in charge. Did you see what happened when Homer Simpson's brother let him design his dream car?

 

Loading mentions Retweet

Comments (0)

Jun 24 / 1:43am

Code shouldn't be sat on

When a software project is ready to release, there is a temptation to keep polishing and refining, rather than releasing it for consumption and inevitable criticism. A bit like a hen who doesn't want their eggs to hatch.

Bad similes aside, it is wrong to perpetually incubate work where it is out of harms way, under the pretence of being a perfectionist or having exceptionally high standards. In reality this could be indicative of a lack of confidence in what is being produced.

It is vital to set high standards. However the "release early and often" rule is still a good one. I have found that when code is put out there scrutiny it improves rapidly. This is obvious. Attention is paid to the right places, not where developers think the improvements need to be made. And when the code does go live to the world, it can be done so with utmost confidence.

Loading mentions Retweet

Filed under // development web development

Comments (3)