My next LCD TV, possibly?

My current Samsung TV is working fine.

But one of these days, I think I’ll replace it with the gorgeous Sony Bravia KDL-32S3000 LCD TV pictured above.

It’s beautiful, it’s feature complete (HDMI, 720p and Widescreen) and is currently being sold at around $900 in the US.

The only slight issue is the lack of high definition content in Mauritius. As indicated in the TV’s manual (which I’ve, of course, downloaded and read cover to cover), the TV accepts the following HD signals:

  • Over-the-air broadcasting via HD-quality antenna. MBC broadcasting HD signals?!? Forget it.
  • HD cable subscription. Not available here.
  • HD satellite subscription. I am not too sure that this is a priority either from Parabole Océan Indien or Canal Satellite. I have a Parabole Maurice subscription and I don’t have access to films in English. I am forced to watch (mostly) everything in French which is crap as I tend to watch a lot of American and English movies. So if they don’t feel that having two audio streams is important I doubt they’ll bother with an HD video stream which is bound to use a much higher amount of bandwidth. My guess is that we won’t have HD satellite programs here for at least 2-3 years.
  • Blu-ray Disc player or other external equipment. I don’t think I’ll buy a Blu-ray or a HD-DVD player soon (but who knows?). I don’t also intend to buy a PS3 or an XBOX 360. So there is only the Apple TV left. I am thinking of getting one to host all my media files (audio, photos, videos of the family and some movies) but I’ll have to convert all my video files to H264 first… which I’ll have to do as I fear that the (cheap) DVD-R I used to store my home videos won’t last for ever.

Seem a little bit limited for the time being, isn’t it?

Functional programming to save the world

I’ve just come across an excellent article on eWeek titled Programming Superstars Eye Parallelism where some of the brightest computer scientists ever discuss on the Next Big Thing (TM).

James Gosling, creator of Java at Sun, Anders Hejlsberg, creator of Turbo Pascal at Borland and C# at Microsoft and Bertrand Meyer, creator of Eiffel reflect on “”What will you do with a 4,000-core machine?”

Multicore processors

Most of us buying computers now have dual-core processors like the Intel Core Duo I have on my MacBook. The same company has communicated on its Tera-Scale research program and has announced that 10-cores processors will be ready in two years. Intel is even experimenting with 80-cores processors…

Sun Microsystems already sells an 8-core processor with 4 hardware threads per core = 32 threads. It is, of course, the UltraSPARC T1 (Niagara) processor. It even has a successor called T2 which has 8 hardware threads per core i.e. 64 threads…

So the future is going to be massively multi-core.

The problem

Anders Hejlsberg says that “the models we have today for concurrency don’t work. Developers need to move an abstraction level up and he sees a resurgence of functional programming and its influences.” And the others agree.

Simply said, the way we program today (with C/C++/Java/C#/whatever) does not work on massively multi-core processors. This is because of state being shared among the cores and, hence, the necessity to use synchronization mechanisms a lot. The immediate consequence is that it becomes impossible to write programs which are free from deadlocks and starvation as the number of possible interleavings is massive. Exhaustive testing is impossible.

Functional programming to save the world

Joe Armstrong, the creator of Erlang, has spoken eloquently on why functional programming languages, which can be defined as languages without variables, are much more suitable to write concurrent (and parallel) applications than imperative languages that we all use today (like C/C++/Java/C#/etc)

Basically (and I quote),

    No Mutable Data Structures = No Locks = Easy to parallelize!

Incidentally, this is one of the reason I’m teaching Concurrency and Parallelism: I so deeply want functional programming to succeed!

I have been using Erlang for a month now to teach concurrent programming and, in my opinion, my students have loved it (and I too!)

Conclusion

The future is concurrent and parallel. And, according to the best, the future is also functional (very interesting things are happening in research, for example, F# and Data Parallel Haskell). Erlang is already here and is beautiful (and powerful).

I knew those hours I spent learning Scheme when I was younger were going to be useful.

I’m happy.

The Logo programming language

The other day, while visiting the new Editions de l’Océan Indien bookstore (appropriately called The Bookstore) in Rose-Hill, I discovered its basement containing lots of old books at very cheap prices.

I bought 5-6 books at Rs. 10 each among which Logo for Beginners by J.W. Penfold.

As you can guess by the name of the book, it talks of the Logo programming language, developed by Seymour Papert to teach programming to students.

To be frank, I did not have a very positive opinion of Logo prior to reading that book. It’s only when I came across page 3 that I realized that Logo was something special:

“LOGO derives from a family of languages known as ‘list processing’ languages, and these are the languages of so-called artificial intelligence”

What??? LOGO is a derivative of LISP!?! I couldn’t believe it. As you have gathered by now, I am very very fond of LISP and its children: Scheme, Haskell, Erlang and Ruby.

Programming in Logo

Logo, when used to teach programming, is very straightforward. For instance, this is the body of a procedure, called square, which draws a square:

repeat 4 [forward 100 right 90]

The following code then draws the figure that you can see above:

repeat 72 [square right 5]

It’s not complicated and, arguably, can really teach the basic concepts of computation very easily. No wonder lots of schools (especially in the UK) still use Logo.

Of course, Logo being a LISP derivative, can be used to solve very complex problems. It has higher-order functions for instance and this opens the world of map and reduce (and even Google).

Where to get Logo?

There are many free implementations of Logo. The “standard” seems to be UCBLogo also known as Berkeley Logo which works on lots of different platforms (Linux and Windows for example). I did not use that one.

Instead I found ACSLogo which is a fantastic Logo implementation for Mac OS X. It’s so good that it even won a Mac OS X Innovators Contest award in 2003!

Final thoughts

Try Logo. I think you’ll be impressed. And, in case you come across that Rs. 10 book, buy it. Rs. 10 is so little to pay to access such a wonderful world…

Beware of type erasure in Java

This Java program I got from a blog does not compile:

import java.util.*;

class Egg
{
}

class Muffin
{
}

public class Breakfast
{
  private List<Egg> eggs;
  private List<Muffin> muffins;

  public void add(List<Egg> moreEggs) {
    this.eggs.addAll(moreEggs);
  }

  public void add(List<Muffin> moreMuffins) {
    this.muffins.addAll(moreMuffins);
  }
}

The error message is:

name clash: add(java.util.List<Muffin>) and add(java.util.List<Egg>) have the same erasure

I was amazed when I saw that. I finally found an explanation in this forum.

What is happening is that (I quote) “Parameterized types (aka Generics) are only to restrict the use to enter the right object into the collection. All the generic information is erased by the compiler.”

So that why I got a name clash error. Both add(java.util.List<Muffin>) and add(java.util.List<Egg>) are in fact the same method add(java.util.List)!!!

Generics in Java are only used at compile time. They don’t even exist at run time!

PS:

I am a fan of Erasure, the group. Vince Clark was the initiator of Depeche Mode after all…

How I became a programmer

It all started around 1986 (when I was 13) when my dad bought me a Sanyo MBC-16 PC. It had an Intel 8088 processor running at 8MHz (compared to the 2000MHz Intel Core Duo I am using now), 640kb of RAM (I now have 2,000,000kb) and ran MS-DOS 3.22.

One nice “feature” of that PC was that it came with two floppies only (it didn’t have a hard disk). The first floppy contained the operating system and the second one was GW-BASIC.

GW-BASIC (do you know what GW means?) was without doubt the reason I became a Computer Scientist (so, thanks Bill!). Remember, I bought that PC when I was 13 and the only way for me to play was to write my own games. So this is what I did. I wrote numerous Space Invaders clones and I wrote my own version of Tron with a very slow collision detection algorithm…

I had one friend at Royal College Curepipe who was also a computer maniac. I think his name was Harry and he died when we were still in college… Anyway, one day he gave me one floppy containing one executable: turbo.com

I went home and ran it. It was Turbo Pascal 1.0 and I couldn’t program anything as I didn’t know the Pascal language. I did what all good geek would do: I looked inside the executable and I found a data segment containing all the Pascal keywords (program, var, type, writeln, etc.).

I guess I tried all kinds of combinations for days until I became a fairly good Pascal programmer. I then wrote my own Mastermind game. I also fondly remember typing a maze-generating and -solving program I got from SVM magazine. Those were the great pre-Internet and pre-Google days where you really had to be motivated to learn something new…

This PC had two graphical modes: one was 320×200 with 4 colors out of 16 and the other one was 640×200 monochrome. This was the CGA standard.

As the color palette was so limited (4 out of 16 colors compared to the 16,777,216 we have today), games tended to look the same :-)

I fondly remember King’s Quest I by Sierra and Karateka by Jordan Mechner:

My next computer was a Commodore Amiga 500 but I’ll write about it in a future post…