sunnuntaina, tammikuuta 25, 2009

Why do I use Safari

During this weekend I have had a discussion on Twitter about Safari vs. Firefox. Well, in reality it hasn't been much of a discussion because it is hard to present a good argument in 140 characters. So I will elaborate here.

Why do I use Safari? Some people might have difficulty even understanding the question. 70% of Internet users surf with Internet Explorer. Many, if not most of them have never even heard of Firefox or Safari. But it so happens that I live in an environment filled with technically savvy nerds and literally everyone of my peers runs Firefox.

Except me.

Why?

I want to be different. For some reason I think there is something wrong with anything that is wildly popular. I hate crowded places. If everyone uses Firefox, I want to be different. I'm just wired that way. I also want to code in exotic, preferably dead languages: Forth, Lisp, Smalltalk, Erlang.

If I wanted to be like everyone else, I would run Firefox on Windows or Linux and code in C++ or Java.

I also have some practical reasons for preferring Safari:

Practical reason 1: Safari is smaller and starts up faster. This is important to me because my home computer is a 1st generation Mac mini, PowerPC CPU and 1 GB RAM. It normally has at least 3 users logged in, so memory is tight. I have developed a habit to quit the web browser when I'm done with the web pages or when I leave the Mac. If I were to run Firefox and keep it running, it would take ages to swap it in or out when switching users. If I always quit Firefox after viewing a web page, I will spend a lot of time waiting for Firefox to start.

This is much less of an issue on my work machine but I like to keep my work and home environment similar to minimize confusion.

Practical reason 2: Mac keyboard shortcuts conflict with Firefox Back- and Forward keys. Many are the web page forms where I have written a lot of text and hit cmd+left arrow to go to beginning of line. BOOM! Bad idea. Firefox immediately leaves the page and goes back in browser history. Never mind I had lots of unsaved text written on the page. Sometimes you can cmd+right arrow to go back and the text is still there. On some web services you get a blank page or an error. Safari is smart enough to interpret cmd+left arrow as beginning-of-line if the keyboard focus is in a text field.

Practical reason 3: I don't like tabbed browsing. Yes, I'm weird that way. Everyone of my peers has dozens of tabs in their Firefox. I don't understand how they manage. Tabs are essentially a two-way list. If you use the keyboard, you can only switch to the tab on the right or tab on the left. Those who remember the university Data structures and algorithms course will see this is the O(n) behavior. If you have a lot of tabs, you will spend a lot of time hitting ctrl+tab. The only random access available is to click on a tab with a mouse. But there's only about 8-9 tabs that fit in a Firefox window of reasonable width. The other tabs are hidden.

If you open new browser windows instead of tabs, you can use Expose (F10) to navigate them. Any browser window is within your reach with a couple of key presses or a flick of a mouse, especially if you set an active corner to invoke Expose.

Don't get me wrong, I do use tabs. I often open closely related web pages in tabs in the same browser window. So normally I have 4-5 browser windows and a couple of them have 3 or 4 tabs.

Now it is late. In the words of the immortal Forrest Gump: That is all I have to say about that.

perjantaina, tammikuuta 02, 2009

The best programming language

I have been doing most (well, pretty much all) of my professional programming in the C language. I'm beginning to really hate it. It is so difficult and error-prone to do string manipulation in C. It is easy to leak memory. There are no standard high-level data structures.

I have been looking for alternatives for a long time. The alternative should:
  • have good libraries
  • have good interface to libraries written in C
  • have support for threads
  • be small
  • have good performance
  • not have many dependencies to operating system libraries
  • it should be possible to make closed-source programs with it
I have looked at Smalltalk, Erlang and Python.

Smalltalk has good libraries and the Smalltalk virtual machines tend to have very few outside dependencies. The Smalltalk I'm best familiar with, Squeak, has no support for threads and seems to interface somewhat badly to the outside world. I was especially disappointed by its support for running subprocesses and controlling them. Also, it is pretty much impossible to make closed-source software with Squeak. All the source is included in the image or can be reverse-engineered easily.

Erlang is an even more niche language than Smalltalk. There aren't many other people using it. Erlang is difficult to extend with libraries in C. Apparently not many C libraries can easily live with the extreme parallelism and thousands of light-weight processes a typical Erlang environment looks like. OTOH Erlang has good support for running subprocesses and communicating with them. Erlang sucks particularly bad in performance, unless your problem parallelizes to the extreme and you have the hardware to support it. For the more conventional cases Erlang is probably not a performance booster.

Python is sexy but slow. Python is also mostly single-threaded. It has threads but only one of them can execute in the interpreter at once.

Java is very un-sexy and also very slow. It has good thread support but it is a huge bloated monster.

All the languages above are very big. I call it very big if the customer has to install 30+ MB of language support/runtime/virtual machine to deploy a piece of software.

At the moment it looks to me like C++ or Objective-C would be the solution. Also there is this thing called Haskell, but I haven't looked into it sufficiently to have any idea how it stacks up with the contenders above.