Saturday, December 6, 2008

And after the break... we're back!

I realise only today, with a certain degree of sadness, that it's been a full year since my last post... so people may have wondered, whatever happened?

(or rather, they would if there had been any reader, that is....)

Google happened!

Yes, almost exactly a year ago, on 17 December 2007 I started working at Google and, although, this was great for all the right reasons, I got so swamped with stuff to do that no time was left to dedicate to this blog.

On the bright side, as the Engineering Manager of a team of extremely talented engineers, I get involved on a lot of exciting projects and technologies and I have been exposed to some pretty awesome stuff - only a small fraction of which I will be able to talk about here, but given the amount of code we open source regularly, I'm sure there will be plenty to blabber about to keep this blog flowing.

Over the last few months, I've also taken up again C++ (and, yes, sorry, Java types - it is faster than Java: a lot!) so hopefully I'll be able to tell you about it too.

My current line-up of preferred technologies (and I advise anyone developing in a resource-constrained environment to heed this advice) is as follows:

  • Google Web Toolkit + clever use of CSS on the web front-end
    (and if you use Google Chrome, that does pay handsomely in terms of user responsiveness and usability)
  • Back-end using either J2EE technologies (typically Spring + Hibernate; use JPA if portability is of value to you) or pure, blindingly fast, C++ 
  • Persistence layer using MySQL (we internally use BigTable, this is no secret, there are even papers about it and our MapReduce algorithms - in the open source world, Hadoop is a cool technology that we were using in my previous job and it looks like it would be a really good choice, but I don't know enough about it to really comment)
The beauty of all this is that, beyond being all open-source and freely available (unlike closed, proprietary, pay-through-your-teeth solutions, best left unnamed....) and happily running on Linux (Ubuntu is an awesome distribution, both the desktop and server editions are totally flawless), you can use all of the above with a reasonably low learning threshold and you don't need to limit its use for some mega-super-complex development: even if you are planning to create a simple website to allow people to share grandma's recipes, it's still worth doing and, by the time you're finished (if there exists such a concept in web development) you'll be very pleased not to have adopted some kiddie-scripting solution....


Monday, December 10, 2007

Ubuntu - is Linux finally ready for the desktop?

I've now been using Ubuntu on my laptop (a Sony VAIO - btw, the quality of the display is absolutely astounding: two years on, I'm still delighted by its brightness AND battery life) for quite a few months, and I must confess my perception of it has entirely changed.

As you can see from previous entries in this blog, I've been rather critical of Ubuntu and certain design choices - however, the more you get used to the `sudo` thing and the general approach that you don't really need to `su` to root to get stuff done, then it becomes pretty natural and, indeed, most stuff does get done.

However, the one thing that most convinces me that the folks at Ubuntu are definitely travelling down the right path, is the ease of use of the user interface (which looks way better than Windows) and also how easy has it become to add functionality.
Adding hardware has also come a long way from the times when even getting Linux to "see" a WiFi card meant compiling some drivers, editing scripts and all that nonsense that was so frustrating for all those, like myself, that saw using a Linux box as a means to an end (eg, doing development, running a web server, getting a database server up and running) as opposed to the end in itself (as it still to me seems the case with some parts of the Linux community).

Ubuntu definitely is a massive stride forward in making Linux a much more compelling proposition to the "computer savvy" professionals - developers, and IT experts - who are sick and tired of buggy, insecure and drab Windows; but at the same time don't have the time and desire to spend entire days and weeks trying to figure out why that particular kernel driver does not compile.

However, it is also important to say that Linux will really never become the OS of choice for the "great unwashed" - but this is no bad thing: trying to "dumb it down" would mean introduce technologies (such the infamous Universal PnP and suchlike) that make Windows such a security nightmare.

In other words: for those who can, Linux; for those who can't, Windows...

Saturday, October 6, 2007

Off-topic - about uselessness (and lack of testing)

Just had a taste of the "user error" disease...

Was reading a post on the Eclipse Magazine (no hyperlink here by design, you go and waste your time there, if you really want to - but use Google, I won't be complicit in this endeavour).

Early on, they managed to prove themselves less than proficient in web design with the less than friendly way of accessing the PDF of the magazine and password management; but I put that down to the typical hiccups one encounters early on in deployment / roll-out, and, anyway, managed to get past them.

Today, however, after reading a reasonably informative blog entry, I decided to post a comment - and, being the thoughtful, insightful, informed and well articulated individual that I am, I spend considerably more than the 30 seconds your usual blog-commenter does (being generally of the "well put, mate" or "total rubbish, you loser" variety) to do so.

To avoid bot-posting and spamming, I presume, they have a 'Verify' box, which is the usual kind you see pretty much everywhere these days: you are presented with a picture of letters an asked to type them up in a box and submit.

After going through the process a couple of times and getting nowhere (well, it's early Saturday morning, I thought maybe the caffeine hadn't hit the spot yet) I started to guess it might not be me after all...

I tried every combination: all lowercase, all uppercase, one letter at a time... nope - niet - nada: it just says "Not verified! . Please try again" [punctuation sic]

To make matters worse, they have Javascript that 'disables' the text box, so one cannot even copy & paste the comment for later posterity (or re-use elsewhere) - that's it, you've completely waste your time, dude, and tough luck!

Now, bearing in mind that this is a website dedicated to Eclipse users (so one would assume, somewhat versed in the use of Java and coding in general) that they would be familiar with the concept of 'testing' - but, alas, apparently not.

PS - feel free to post comments here: it's safe, we don't verify and, if we do, it does work.
How do I know? well, I do have comments on my blog (unlike Eclipse Magazine) :-p

Sunday, September 23, 2007

GWT rocks!

I have recently been experimenting with the Google Web Toolkit, and it really rocks!

In less than a couple of days' work I was able to create a full featured demo app, with toolbars, menus, help pop-up's and other bits and pieces - essentially a true Rich Internet Application (RIA).

A few points that I think are worth for the novices, like me:

  • if you don't know CSS, learn it fast - it is an inseparable component of GWT and enables one to do all the formatting, positioning and styling that would be virtually impossible from GWT alone;
  • use Eclipse for the development / code editing - there is an excellent integration from within GWT, although, in my view, it could be better;
  • it is worth considering the use of ant for all the build, deploy and run tasks - GWT applicationCreator will generate some simple scripts to do that for you, but using ant gives much greater control and flexibility to the whole process; especially if you are deploying to an instance of Tomcat that is not the one that comes packaged with GWT (which is the most likely situation in a real-life environment);
I am using "GWT in Action" (R. Hanson, A. Tracy) which, if a bit verbose and too light on details, seems like a good starting point - definitely better anyway of the very limited amount of information one finds on Google Code.

One thing I do not understand is Google's choice of their somewhat weird choice of not using Javadoc to document GWT classes - quite apart from the fact that makes it harder for us all to figure out where things are (for example, the lack of an 'All Classes' options, leaves us wandering around packages to find out a class' description), it also turns out that some methods's descriptions are missing, whilst others are actually not correct.

But those are very minor gripes - the speed at which one can craft a fully-featured RIA, even for someone who has very limited knowledge of Javascript, is a priceless feat: thanks, Google!


Saturday, May 19, 2007

Ubuntu fixed (sort of )

Ok, so I decided that (a) a laptop without the "Suspend" / "Hibernate" was only marginally more useful than a door-stopper and (b) that I could do it, if I really wanted.

I'd also discovered that, out of the box, Ubuntu would not support an external monitor - which was a bit unsettling, as I was due to give a presentation the next day (to no less than Google folks!) and was planning to do so from the laptop.

Fire up Google, search for "Ubuntu dual head" and up pops HowTo: Dual Monitors a very well written article, with plenty of detail.

It turns out that the source of so much misery were the missing nVidia drivers - installing them following this How-To was a piece of cake and that also had the nice side effect to enable the external monitor.

One thing that still troubles me is that I have been thus far unable to find a way to make Ubuntu recognise the special function keys (you know, the ones that allow you to change brightness, volume, etc. and, critically, switch the LCD/External monitor) so to have the external monitor to work, one has to re-start (Ctrl-Alt-Backspace) the X server.

I have so far been unable to make Twinview work and I am using Xinerama instead - although, apparently, Twinview was designed exactly for nVidia cards, my (admittedly, feeble) attempts to make it work have miserably failed: I decided that life is too short and can live quite happily with Xinerama.

A more general consideration is that it took me the best part of a Sunday afternoon and several trial and errors (for God's sake, whatever you do, make a backup of xorg.conf at each and every step - trust me, you'll need them!) - to achieve something that Windows gives you straight out of the box (and, to be fair, most Linux distros): I am still quite unsure whether choosing Ubuntu was as clever as I thought it was.

On balance, I'd recommend Suse Linux: I have v. 10 installed on my other laptop (a much older one that I use as a staging server for my Tomcat Java apps) and it is much easier to manage, configure and, generally, use.

Also RedHat's Fedora Core felt a lot easier to use, although much less "flashy" than Ubuntu.
I used to run FC4 on yet another laptop as a development/testing box - had all sorts of servers and tools running on that one: despite years of abuse, I never really managed to crash it: the same, sadly, can't be said of my Windows dev PC, that recently enjoys crashing on me rather spectatularly): I can only assume that FC6 is even better (and FC7 is about to be released).

Now, if only I could get the little battery guy to see some sense ...
(although, I must admit it's got its amusement value: yesterday warned me of 5 remaining minutes of power as soon as I unplugged the power cable, after an entire day charging)

Monday, May 7, 2007

Ubuntu, NetBeans and Sun's Application Server (Glassfish)

I have recently read that Sun and the folks behind the Ubuntu Linux distro are getting some sort of strategic partnership and closer cooperation.

Well, not one day too soon, say I.

For the poor souls like myself that have been struggling to get Ubuntu to be a bit more co-operative and let the Sun App Server (SJAS) do its stuff, it's been quite trying.

For a start, although I may intellectually agree with Ubuntu's desire not to let root roam free and cause havoc, that is hardly helpful when people like myself spend 90% of their time on a Linux box doing exactly the kind of stuff root is supposed to be doing (set-up the server, install and remove stuff, create/delete/fiddle endlessly with configuration options, firewall, user access rights, and other highly amusing stuff...)

The novelty of having to type endlessly sudo/gksudo sort of wears thing after the 900th time you've done it in two hours....

However, having decided to endure it for a while and see whether that would lead to a better world, I made a fundamental mistake...

I installed NetBeans, SJAS and MySQL (server) as root

Now, isn't this what you are supposed to do?
As root, you install the applications, and then create 'safe zones' for the users (or, equivalently, assign rights to mysql users) so that they won't mess up with the installation and other users' data.

Well, if you do that, NetBeans, SJAS and MySQL won't love each other, in fact they'll loathe each other, the world and, most critically, you!

For example, SJAS will start (well, sort of), but NetBeans won't be able to figure it and will sit there endlessly until it times out (and, by the way, whoever set the timeout value must have a Buddhist monk, as it takes forever to do so!)

MySQL for its part will install and start well enough, but then won't let you create new databases and/or new tables on existing ones - unless, that is, you go manually in /var/lib/mysql and change (chown) ownership to the user.
Something I don't particularly like, but let's face it, who else is going to fiddle with that dir?
Hackers? never!

So there you have it: if you want NB, SJAS and mysql to happily talk to each other, the only solution I have found is to create a /development folder in which to install them - whose ownership is for the 'users' group, and install them both as one of the 'users'
As per mysql, it would seem that by keeping mysql:mysql as the user:group for /var/lib/mysql location makes it all work.

However, to be totally, honest, I'm rather sick and tired of Ubuntu: I have installed it on a Sony Vaio laptop (not exactly a rare or exotic choice of hardware) and almost nothing seems to work as intended:

  • I can't get it to hibernate / standby, as the display won't come back;
  • I can't get it to see the "special function" keys (brightness, function keys, external display, etc.);
  • the battery meter is a confused little guy (how for a battery meter that tells you that there is 63% left - correctly - and then goes on to state that "only 5 minutes " are left?);
  • sometimes, when the screen saver comes on, the display colours palette gets entirely messed up and the only way to get back a sembiance of normality is to log off and log back in (effectively, restarting the X server).
Apparently, you can update and rebuild the kernel to make it all work - but, as self-inflicted pain goes, I prefer a walk to the dungeon downtown to get whipped...

I mean, none of this is reason enough to go back to Microsoft Windows (one thing is not being able to hibernate, another is having to reboot every couple of hours or so, and having your server wide open to anyone who's bothering to hack into it) - so I've ordered Sun Solaris 10, one would hope that its integration with Sun's Application Server and NetBeans is slightly better.

Watch this space...

Dynamic Pages adds AJAX to your JSF pages

I was going through the "Adding Ajax to JavaServer Faces Technology With Dynamic Faces" tutorial, and it occurred to me that it would have been a much more AJAXy solution to have the check on the existence of the User ID to occur when the user moved to the next field (without the need to click on a button - which is so Web 1.0 !)

That is easily done, by removing the "Check for user ID availability" button altogether, and adding the Dynamic Faces action on the 'onblur' method for the user ID text field:


                
<!-- Dynamic Faces usage follows: -->
<h:inputText required="true" id="userid" autocomplete="off"
binding="#{Register_Backing.userid}"
valueChangeListener="#{Register_Backing.userIdChanged}"
onblur="DynaFaces.fireAjaxTransaction(this, {
execute: 'userid',
render: 'userIDAvailableMessage',
immediate: true});
return true;" />
<h:message for="userid" errorClass="ValidateError"/>
<br />
<!-- this is the element rendered by the AJAX request -->
<h:outputText style="{color: red}" id="userIDAvailableMessage"
value="#{requestScope.userIDAvailableMessage}" />
<br />


The userIdChanged method in the Register.java class simply calls the original checkUserIDAvailable method:

public void userIdChanged(ValueChangeEvent e) {
ActionEvent aev = new ActionEvent(e.getComponent());
checkUserIDAvailable(aev);
}

It is also worth noting that the installation instructions at the beginning of the article are particularly uninformative - in fact, it is NOT necessary to download and install the Sun Developer Web Pack (I found the idea particularly frightening, as apart from the installation process being particularly cumbersome, it also seemed like the shortest path to messing up my carefully crafted NetBeans / Tomcat / Sun App Server (GlassFish) settings).

In fact, jsf-extensions (Dynamic Faces) is likely to already be in your NetBeans installation (if you have installed the Visual Web component) or, equally simply, can be installed by downloading it from the Dynamic Faces Project page.