Showing posts with label programming. Show all posts
Showing posts with label programming. Show all posts

Thursday, 12 November 2009

Google's Go Language First Impressions

Google recently announced the launch of a new programming language called: Go. Its creators are software heavy-weights like Robert Griesemer, Rob Pike and Ken Thompson. It's a C style language, it has garbage collection and claims to compile fast.

Its idiosyncrasies follow.
  1. Backward declaration: Instead of declaring a variable like "int a", you do "var a int".
  2. Type derivation with ":=". You can initialize variables and Go will derive its type for you. For example doing "a := 1.0" automatically initalizes "a" to a "float".
  3. Semicolons are not required at the end of each statement.
  4. The only looping construct available is the "for" statement. No "while" or "do-while".
  5. The parameters for the "for" and "if" statements don't need to be within parentheses (I'm shocked and crying)
  6. Unicode strings which are immutable.
  7. Pointers but no pointer arithmetic.
  8. Its compiler is currently not available for Windows -- only for Linux and Mac. Doubt if a cygwin port is available.
Maybe more later.

Friday, 9 January 2009

Junebug

On Dec 31st 2008, many of Microsoft's Zune music players started dying. The problem was in the RTC (Real Time Clock) driver code which didn't handle leap years correctly. The explanation is worth looking at.

Tuesday, 11 November 2008

A script a week

Amongst my many goals in life, I want to work less and automate more. There are many things which I do as part of my daily work/play which can be automated. So I have set myself a new goal: create a script, at least once a week, which takes one of the mechanical activities in my life and automate it. I am aiming at a variety of tools/languages: python, perl, elisp, powershell and ruby. I have few ideas already, hope I allocate the time and actually do it. Let's see how this goes.

Tuesday, 1 April 2008

Virtual keyboard

My latest fascination these days is to play music. I own and am learning the guitar, but I'm also interested to play the keyboard (musical). Few days back I came across "Virtual Keyboard", which is a flash application which lets you play few notes. The nice thing is that the notes on the musical keyboard are mapped to the keys on the keyboard connected to your computer. So for example hitting 'e' on your keyboard produces a 'D#' note. So I wrote a small program in perl which takes in the notes and converts them to keystrokes. Being a touch typist I can play the notes decently enough.

eg: Notes for Clocks by Coldplay:

Eb Bb G Eb Bb G Eb Bb G Db Bb F Db Bb F Db Bb FDb Bb F Db Bb F Db Bb F Db Bb F Db Bb F Db Bb F C Ab F C Ab F C Ab C

Converted to keystrokes:

e u g e u g e u g w u f w u f w u u f w u f w u f w u f w u f w u f a y f a y f a y a

Sunday, 30 March 2008

Simsharp

Around an year back because of a certain amount of boredom and curiosity, I started writing an 8051 simulator in C#. I called it Simsharp, and managed to convice the guys at sourceforge that it was worthy of being hosted. I worked on it an hour a day for two months and then, when it was almost done, I stopped.

Few days back a friend of mine, who wanted to use an 8051 disassembler, asked me for my project. I couldn't give it to him because I had never done a release. The only other alternative was to ask him to check out the source from SVN and build it, which of course was tedious. So, I apologized and asked him to look elsewhere.

Today, after almost an year after I started, I put together a pre-alpha release. The source and binaries can be downloaded from the downloads page.

The simulator is hidden underneath a debugger. A debugger which itself runs with the help of the Boo interpreter.

There is support for the following in the debugger:

1. Loading of intel hex files
2. Disassembling the entire code.
3. Adding/Removing breakpoints.
4. Reading the internal RAM.
5. Reading the registers.
6. Single step
7. Run

I hope its of use to someone (other than the college students who will make this their course project).

Sunday, 22 April 2007

NUnit + NCover

Deadly tools. Do use: NCover, NUnit. Usual recipe is to run your unit tests from within NCover and check how much code your unit tests are covering. This can even uncover silly mistakes where a test is not being run because you forgot to put the "[Test]" attribute.