Top 5 programming languages to learn

eWeek described the top 5 programming languages to learn (if you want a job) as:

  • PHP
  • C#
  • AJAX
  • Javascript
  • Perl

Not the most exciting list. My top 5 languages to learn (if you want to learn something) are:

  • Scheme — The essentials of programming without syntax. It also allows for some crazy metaprogramming.
  • C — It’s everywhere, has become the defacto syntax, and it forces you to learn about manual memory management, pointers, arrays, bits etc…
  • Simple assembly — Lets you deal directly with registers and interrupts. I learnt Z80 assembly but I would recommend learning PIC, AVR or MSP430 programming. It’s much more fun than it sounds and it makes you appreciate every other language out there.
  • Haskell — Pure, functional, lazy and strongly typed. A head-job but it will stretch your thinking.
  • Prolog — A declarative language, you describe facts and rules and hopefully Prolog does the rest.

The top 5 languages that I would like an excuse to learn are:

  • Erlang — A process based language with lots of interesting ideas.
  • Lua — An extremely light-weight and fast scripting language.
  • Objective Caml — A statically typed functional language.
  • C# — Java like but with some additional good ideas.
  • Squeak — A language with its own OS and GUI!

Scripting with JavaScript in Cocoa

Scripting with JavaScript in Cocoa is a brilliant way to add scripts and a language to your app. Even better it is extremely easy. My article is a great place to start. I’ve just updated it thanks to Jack Nutting who fixed a bug on Leopard.  

Scripting with JS
  

Demoing in India

Two quick photos of demoing the calculator in India at TechFest. An estimated 50,000 people came.

Queuing to see us Demoing in India

Content aware image resizing

The concept of content aware image resizing is to resize an image whilst preserving the important parts of the image. A very simple and neat method to do this was presented in a paper at this years SIGGRAPH, the superb results of which can also be seen in this YouTube video.

The trick involves removing least cost seams through the image instead of the evenly spaced columns or rows that scaling removes. All the details are in the very readable and clear paper. Unfortunately the idea was simply too neat to avoid tinkering with. Thus we arrive here. I’ve implemented the basics of the paper pretty much as is, using directional Sobel filters to calculate the cost of removing pixels.

The photo below is a good example of a photo that works with this technique.

Test scene

This resizes horizontally to:

Horizontally shrunk test2s.jpg

(content-aware vs. standard scaling)

and vertically to:

test3.png test3s.jpg

The content aware resizing creates much clearer shrunk images of the origninal preserving the houses on the right. Unfortunately this resizing doesn’t work well for most images, it works best for images with areas of detail and flat areas. Download it, give it a go and see what it can do. The application and source code (BSD Licence) are available for anyone to tinker with and improve.

There are obviously lots more possible things that could be done to this app. Including: suitability estimate based on the variance of the seam costs, image expanding, different weighting algorithms to choose for different images, pre-calculation and live resizing, and weight painting for areas of interest/disinterest.

If you find any nice examples or find a use for the source code let me know.

The writing process

The writing process

– Blue line: Total word count
– Red line: Edit position (bottom = end of document)

Path-traced box

Path-traced box

2D physics

2D physics

LLVM

I found WWDC a disappointment. It felt like half last years conference and half a web conference. I went last year and there are better places to learn AJAX. So it is nice to see Apple doing interesting things.

LLVM (Low Level Virtual Machine), which Apple is involved in, could be described as compiler infrastructure. That is it can be used to replace various aspects of compilers. It is very clean, neat and well designed system that provides optimisations at various levels, including compile and run-time.

Why is this neat? Well it provides very good optimisations. One comparison has the LLVM JIT performing 20% faster than gcc4.2 and 100% faster than gcc4.0.1 (which Apple currently ships) for one benchmark. For those that are interested I think the best way to learn about LLVM is to read the experiences of Reid Spencer’s implementation of creating Stacker which is a Forth-like language which compiles to an LLVM backend.

There is already a C/C++ LLVM frontend and Apple is working on a very nice new C frontend. Have a look at some interesting presentations. The presentation I thought was most interesting is Steve Naroff’s New LLVM C Front-end. Especially look at the error messages it can produce.

Apple also use it for GLSL just in time compilation to provide OpenGL shader support for features unsupported by video cards. Chris Lattner also presents an overview of the more technical side of this functionality.

Preface

I just got back from Apple’s WWDC and I’ve decided to start a blog. I think there’s room for at least one more. There are too many things I want put online that do not fit into an article format, thus this experiment. If I run out of intelligent things to say, I’ll try to stop.

The focus here will be on programming and user interaction, I intend to write intelligent things and as I am a user interaction researcher those are my areas of expertise.