Tuesday, 4 January 2011

Vim..a n00b's experience

Vim is an improved version of the Vi text editor which has been kicking around since 1976. After some initial scepticism I've found that is an incredibly powerful and useful tool. I'm just learning but all ready feel that my productivity is increasing.


Why Vim?

I never thought I'd feel excited enough about a text editor that I pony up the cash to pay for it. After all its just a text editor right? Well that's what I thought until I found Textmate for my Mac. This seemed to bring a whole slew of new features that made coding faster and easier. I'm sure that I wasn't even using a fraction of the available abilities. Then I moved to Linux and found gEdit which is just a plain old text editor. Now I spend a lot of time at work ssh-ing to unix boxes and if I need to view or edit a file my choices are limited. The commands used in less and more, translate to Vim so I needed to learn about more (bad pun intended) about it. I found that once you've learned relatively few commands you can navigate round a file in no time. I decided to see if Vim could be useful as my default editor at home as well. The Vim website has binaries available for installing gVim (a Gui based version) for Linux, Mac and PC so I didn't have to code inside a terminal window. I also downloaded an excellent 4 part video tutorial from Net Tut's called Venturing into Vim by Jeffrey Way. This series was very useful in explaining the basics (and some advanced stuff). If you're wanting to learn more I'd highly recommend this series.

So what's so cool about it?

When I work I prefer to have my hands on the keyboard as much as I can. I don't like to be continually moving my hand off to grab the mouse. Vim lets me not only insert and edit text but also to navigate without having to wave my arm around. This translates to faster input. Once you're familiar with the Vim way, most commands are intuitive and seem to be the logical way to do things. Even though its text based you can still use tabs or split the screen vertically or horizontally (and multiple times). You can carve up your workspace to make it however you want. Check out this screenshot.  I defy you to do that in your vanilla flavoured editor.
This is just one of the many flexible things you can do with Vim. Its not an IDE but its totally lightweight and can support syntax highlighting.

The trick with Vim is that it is like a language all on its own. Once you've become familiar with it, it will quickly become second nature. Part of the curve is that Vim has a number of different modes: command, insert and visual. Depending on what mode you're in, keystrokes will mean different things. For example, in command mode [shift] + g will move you to the end of the document, while in insert mode it will give you a capital G. By default you start in command mode and you choose to enter text by one of the many insert commands. For example i to insert before the cursor, o to insert on the next line, a to insert after the cursor, A to insert at the end of the line. The options are plentiful. Do a quick google and you'll find any number of cheatsheets and shortcut lists available for Vim so I'll not repeat them here. The thing to remember is that once you've finished in insert mode hit [esc] to go back to command mode. This is a lesson that's learned from experience as I seemed to finish my text files with :w!

You can change the colour scheme from the plain black and white to a number of provided colourful schemes. I'm using the quite dark "ron" scheme at the moment. If you want to set a scheme to load by default you can add a .vimrc file to your home directory. This can be used to customise your Vim with all sorts of things, such as line numbering, syntax highlighting (I've tested it with Java, Groovy and HTML) and auto indenting.

I'll post more about Vim as I learn but so far I'm thinking that if you can type Vim might be the editor for you.

Monday, 3 January 2011

Samsung NF210 Netbook Opinion

For Christmas 2010, we got my youngest daughter Em a Samsung NF210 netbook. She's a budding nerd and has been hacking away on some Python scripts and I really enjoy working on this together with her. She had previously been using a hand me down Powerbook but its best days are now long gone. I didn't want to spend a bucket of cash and she liked the funky shape of this particular model (girls really!!).

The hardware
This Sammy comes with a 1.66 GHz Atom process, 1 GB RAM and 250 GB hard drive. I'm not sure of the weight but it seems much much lighter than my Macbook. The screen is bright and battery life is quoted as up to 14 hours. Even taking out the usual marketing spin the battery life is awesome. Anything better than 8 hours is dynamite IMHO. In addition there's a built in web cam which is unnecessary for me but Em thinks its pretty cool.

The software
Ok so here's a bit of a negative, the shipped OS is Windows 7... Starter!! I had to hide my natural bias and told Em we'd see how it worked out. Em was excited because she'd be able to run all those programs that she couldn't run on the Mac. In actual fact, there really wasn't anything in this category aside from ridiculous smileys and other .exe malware. Em was disappointed that one of the unnecessary features removed from the Starter edition was the ability to change desktop backgrounds.
So within 24 hours, Win 7 Starter was gone and Linux had been installed. We tried a bunch of different flavours, Meego, Moblin, Smeegol, Mint (XCFE), Ubuntu UNR. Meego and Moblin in particular have a beautiful interfaces for portable devices. Initially I couldn't get wifi working as the netbook uses proprietary Broadcom drivers (although I'm told these are now open). After much mucking around I finally got the drivers installed and it worked really well. I'd have to say that one of the big pluses for Meego is the community. It took a long time to get the wifi problem sorted but there were people willing to help on IRQ and twitter. (Particular thanks here to Andy Bleaden @andybleaden for his assistance). However I needed to get VLC working before the young one goes away to grandma's house and this involved a whole new round of pain. We've settled on Ubuntu UNR as the best fit between usability and functionality at the moment. I'm not particularly keen on the Unity interface and we'll sure have another look at Meego in the future.
Ubuntu runs well but so far we've not found a solution for the non functioning brightness keyboard controls and the annoying trackpad which moves the cursor when bumped while typing. I'm sure there's a fix out there for that one somewhere though.

The Verdict
Its terrific and I want one. The screen is small but perfectly usable for web surfing on knocking up a script or two. While its no desktop replacement its perfect if you're on the road or want to have web access with you wherever you are. I've not used an iPad but can't see why you'd want an iPad when you could get one of these for so much more bang for your buck.

Thursday, 30 December 2010

2011 New Year's Bucket List

Last year I got excited and said I'd try to blog once a week to make sure I stayed on track. But as you can tell from the listings here, I didn't make it very far. Aside from the controversial post about Linux there really hasn't been too much action at least in the last 6 months anyway. Just like everyone else I'm really busy and finding the time to learn and experiment can be difficult. However with so many cool new and not so new technologies to play with, how can I not dabble. So with that in mind, in no particular order here's my bucket list for 2011:

  • HTML5 (looks so cool!!)
  • Python (my youngest daughter aged 12 is inspiring me here)
  • Grails
  • JQuery
  • Vim (I did say cool not so new technologies)
  • Scala
  • Android
In 2010, messed about with Linux as an OS (and found it fantastic), with Grails and JavaFX in the language space but didn't get to apply either to anything very substantial. Time management is a massive issue for me so I'll need to be pretty organised and set some specific goals. I've got a couple of projects in mind to apply some of this stuff to, so follow along and we'll see what we can learn.
If you've got a suggestion for a cool technology let me know.

Wednesday, 14 July 2010

Lazy, stupid or insane?

There's never enough time to do all the things I know I should. Life is constant juggle to get stuff done. Work is the perfect example.. ridiculous deadlines tend to overtake the development process and (sometimes) code you're less than proud of gets out. So you'd think I'd learn when working on my own side projects.. right?

Currently myself and another a likeminded dude are working on a grails based football (that's Australian football in case you're wondering) tipping application. The idea had been kicking around (bad pun intended) for a while. We were feed up with the main AFL site which is based on flash. It does the job but each year they provided 'enhancements' which are unnecessary or just don't give us what we want. Anyway enough complaining, we'll build our own. We've given ourselves a very generous timeline to get this done so that it will be close to perfect at release.

Herein lies the problem. Grails makes it so easy to get from "hey let's do this" to "wow look what I just made" that all my good intentions to do the right thing are forgotten. I've read enough material by learned people (like this and this) to know that I should be writing tests for my stuff. Preferably before or during development. However after being distracted by a couple of other side projects, I went back to the tipping project today only to find that the last great feature I'd implemented had busted some core functionality that had been working on early in the project. Lazy, stupid or insane... take your pick.

So now that I've learned my lesson I'm off to install the grails cobertura plug in and see if I can get that percentage up and avoid future problems.

As a side note what do people think is reasonable test coverage? 70%, 80%, (gulp) 100% ??

Monday, 7 June 2010

Version Control

Up until recently I've basically worked on my side projects on my own. I only ever needed version control to keep track of my own changes. Although I use CVS at work (don't laugh some of us have to use ClearCase) I decided to use something different. GIT was my weapon of choice. Fast cheap branching.. too easy right? Ok so its (mostly) command line.. there's no drama with that. Most of what I'm doing is as simple as git branch, git merge, git status.. nothing too drastic at all.

Recently I've started working with another bloke who, like me, is used to using Eclipse with CVS at work. I pushed (no pun intended) Git as I've had good experiences so far and didn't want to go setting up a CVS or Subversion repo on a separate machine. To be honest as much as I wanted this to work for us, we struggled. Making small changes then waiting while he pushed those to master and then I pulled them down only to find a bunch of clashes became tedious quickly. We've argued about what system to use:
CVS? Subversion? Mercurial? Continue with Git?

In the end we've decided to give Mercurial a try. It gives a chance to continue with the distributed mindset but importantly there is good tooling support in Netbeans. (I know there's a plugin for git but I couldn't get it to work on my machine). So far the extra tool support has been positive. We've moved our project to BitBucket from GitHub (higher storage limit for the free account too) and we're able to work collaboratively even in the free account.

In the process of making this post I've had a couple of tweets reminding me that there is git support in Netbeans (and Eclipse). I had been using Netbeans 6.9 RC2 on 64 bit Linux and couldn't get the plugin to work. All good with mercurial so far.

Version Control is something some people get passionate about. I'm not proposing one is better than another just that for us this time Mercurial has been a better experience. As we get more used to the distributed aspect I guess we'll be better able to adapt to GIT. But if Mercurial is doing the job why change?

Wednesday, 26 May 2010

Auscert 2010

So much for blogging once a week! Work has been totally hectic and unfortunately I've got a bunch of cool projects that have been bumped to the backburner. However I'm not complaining because I've just back from my first conference which was the security focused AusCert 2010. If I had to summarize in one word... awesome!!

But for those who want more details

So not having been to one of these before I wasn't sure what to expect. It was held on the beautiful Gold Coast at the lavish Royal Pines Resort. The basic idea was a number of speaking sessions to attend per day combined with vendors detailing their wares. Most sessions overlapped and you generally had a choice of about 4 different topics to attend each hour. The speakers spoke to varying subjects and I was determined to take a few notes to share things with colleagues. Interestingly I thought I'd rate my level of interest in speakers also and found that after each session I was writing "this was the best so far!".

For me the standouts were Roger Dingledine (Tor Project), Marcus Rannum (Tennable Network Security), Crispin Cowan (Microsoft) and Scott McIntyre (XS4ALL). These guys were passionate about their projects and terrific speakers. That's not to say that I agreed with everything they said but they really made me think. These guys were just a few of many great presentations. There were a couple of snoozers for me but to be fair these might have been more suitable to someone else.

The venue was beautiful, the conference was very well run with free wifi, food and coffee on tap, and I learned heaps. If I got the chance to go again I do it in heartbeat. Possibly next time I'd spend some more time networking with some of the other like minded people there. I was surprised to see so many 'booth babes' at a nerd fest like this. To paraphrase Marcus Rannum, its hard to imagine people being influenced to buy security hardware and software by scantily clad young women. Not that I'm complaining.

If you ever get the opportunity to get there, I couldn't recommend it more highly particularly if the speakers are as great as the ones I heard.

Saturday, 24 April 2010

Book Review: JavaFX in Action

To be honest I really only bought JavaFX in Action because I could get it cheap from Manning via their Twitter deal of the day. I'd tossed up a couple of Manning books and decided that UI app's would be an interesting diversion to the web app space that I usually play in. The book shipped quickly and the price was great ($AUD35 including postage) which included the paperback and the PDF version.
One small Manning criticism is the way they handle PDF's. I managed to delete the PDF twice as I skipped from OS to OS (I know I know I should be more careful). Manning make the pdf download link available for 5 days only which is ok until you lose the pdf. You can contact them to open up another 5 day link but I think some of the other publishing houses do it better with an online library that you can download whenever. I like the idea of being able to log in on the web and pull down my reading material regardless of the machine I'm on. Maybe they'll look at this in the future.
The pdf version comes with your name on each page to prevent piracy which is a good idea.

JavaFX

JavaFX is really the first graphical technology that I've started to play with other than say Swing. There seems to be a bunch of options.. Silverlight, AIR, Flex, Swing, and (yes Apple) Flash. Because I haven't done much with these its difficult for me to comment on how JavaFX compares but it seems to have a relatively easy learning curve if you're from a Java background and what you can build is very impressive.

JavaFX in Action the book

The book is an easy read and the author has a very relaxed style with good use of humour. It covers the basics of JavaFX before diving deeper. I wouldn't say its for programming beginners but those with some programming experience will pick it up quickly. I really liked the examples particularly later in the book where you get to build an Enigma code machine and a Flickr client. The examples are also very varied as you're exposed to the different areas that JavaFX could be applied to. The one criticism I would have of the examples is that it seemed to take quite a while before any more impressive than hello world was demo'd. There's only so much reading I can do before I want to be experimenting and I think I had to wait until Chapter 4 or 5 before I found something that excited me. Early examples and quick wins that demonstrated what can be done were one of the great things about Grails in Action which remains my favourite Manning title so far. Having said that when I finally got to them they were very impressive. Instead of the usual way of implementing new features to one project throughout the book, here you got to build different things in each of the advanced chapters. I guess this had to be done to demonstrate the power of JavaFX and the variety really kept me interested and keen to get onto the next chapter just to see what else could be achieved. There are plenty of "oh wow" moments as you build the examples.

Another issue for me was that the author tried to remain IDE agnostic throughout the book. Only at the end does he use an IDE for the examples. This is ok but really most of are using IDE's now and Netbeans is totally free, runs on all platforms so why not just encourage readers to download it to develop the examples. I notice on the author's forum there is mention of examples that won't run from an IDE but will from the command line due to package configuration. He replied that he was trying to keep the IDE complexity out but IMHO we're going to be developing our apps in an IDE so might as well broach it.

The verdict

The bottom line here is that I really liked this book. I think its easy reading style and good bang for coding buck examples encourage the reader to experiment with the technology. As mentioned the examples are varied and each one offers different tricks to learn. I'd certainly recommend this book to those interested in seeing what can be done with JavaFX.