Saturday, November 21, 2009

Moving from Linux to Mac OS X

I got a Macbook Pro last week. Just to give you some background, I have been a happy Linux user for about the past 10 years or so, starting with Redhat 5.3 (back when there was no Fedora/Centos split) to Redhat 8, then moving through the various Fedora versions with a brief dalliance with Ubuntu (6 I think). My old laptop (a Fujitsu Lifebook) ran Fedora 9. My desktop at work runs Centos 5.

Why a Mac?

A rational question at this point (if you are a Linux user), is why not buy a cheap PC laptop and load Linux on it? After all, with Mac OS X, you are back into a closed-source situation where you have to pay for every OS release. And besides, the raw Mac hardware is grossly overpriced compared to a PC - even if you factor in the cost of the Windows OS that you are forced to pay for a PC. And Linux has come a long way from the old days, nowadays its almost painless to get Linux up and running.

My main gripe with my previous laptop was its abysmal battery life - when new, it would run out in approximately 1 hour and 20 minutes. This was fine in the beginning (my commute is 55 minutes one way), but about a year ago, it started running out in about 10-15 minutes. So I got an external battery pack, and that lasted me about another year, and I was back to the 10-15 minute battery life. The Macbook Pro promised a whopping 8 hours of battery life, so that was my initial draw to it.

I also wanted something light, since part of my commute involves walking about 1.2 miles (I can also take a bus, but I have been trying to exercise a bit lately), so that was another driver. I also wanted something that would be future-proof (as future proof as a computer can be) - so assuming that my 8 hour battery would last 3-4 years before it hit the 10-15 minute mark, I wanted something with a decent amount of memory (by standards 3 years from now), something in the region of 8GB or so - and the Macbook Pro was the only one that allowed me this - I looked at Toshiba and HP, both of them required me to buy a monster 18" laptop to get 8GB, something I did not want to carry around when I was walking.

There were also some minor annoyances, such as not being able to project the screen onto an OHP (Overhead Projector), because (I am told) I did not have the closed-source version of the ATI Radeon driver - since I rarely do presentations, that was not such a huge priority for me, until I actually needed it.

So anyway, that was why I got a Mac.

You would think that since both Linux and Mac OS X are Unixes, the move would be relatively painless. Not so. I've spent the last week, getting various tools (or finding their Mac OS X equivalents) that I have come to depend on over the years and installing them. I describe them here. If you are also a Linux user, your suite of tools are likely going to be different from mine, but there may be some that are common - in any case, if you are considering a similar move, the post may give you some indications of what to expect down the road.

The Base Package

The machine detects wireless networks when you start up, so its network ready. It switches over to a wired connection if you give it one. Perhaps this is not as impressive as I make it out to be, since recent Linuxes and Windows both have similar functionality, but as recently as two Linux releases back, I had to do quite a bit of fiddling to get wireless to work.

The machine also comes with Java preloaded. The current Java version is set to 1.6 but it also has 1.3, 1.4 and 1.5 for people who need to code against legacy platforms. It also comes with Ant (1.7) and Maven (2.0.9). I am told that Tomcat and Apache are also pre-installed, although I haven't tried them out yet.

My other major language, Python (2.6), is also preloaded. Most of the Python libraries that I use are also preloaded. I did have to install PyExcelerator, Pygments and NumPy for my scripts. I did this with "python setup.py install".

These are all rather nice touches, probably the reason why so many Java developers seem to be sporting a Mac recently. But the problems start when you start looking to put in stuff that was not pre-installed.

OS Tools

Dia

Dia is a diagramming editor similar to Visio for Windows. I use it to draw flowcharts, system diagrams and such. There is no free equivalent available under Mac OS X as far as I know (Mac users please correct me if I am wrong). To get that, I first had to install Darwin Ports, a tool and repository similar to yum or apt-get.

With the port command, I attempted to do a "sudo port install id", but then discovered that OS X does not come with the "make" command, which port requires to build the package locally. Looking around on the Internet, people said it comes with the system-tools package on the OS X disk, but installing that did not help either - I ultimately had to sign up for an Apple Developer Account to download the XCode package, which contained gcc and make. In my opinion, this is a huge oversight on Apple's part - they sell me what basically is a Unix and don't include the basic tools for me to build downloaded packages - and make me go through a registration hoop to get them - definitely not something that will endear Linux users to Mac OS X.

In any case, once XCode was installed, I had to make some more changes to the die's plist file as described here, and I was done. Definitely not a smooth install, but it works now.

GnuPlot

Gnuplot is a graphing library with a built in scripting language and a Python interface. I use it to draw graphs (of course). Installing it through the ports command was painless.

MySQL

MySQL is available in PKG format, which involves downloading the PKG file (a zipped file, similar to an RPM) and double clicking it. Unlike on Linux, it does not install mysql to your path, but you can get around it by adding the bin directory to your path, or defining an alias.

To copy over data from my old MySQL database, I used mysqldump. You can find detailed instructions here.

Open Office

Open Office is an office suite, similar to the Microsoft Office suite. You can get Microsoft Office for Apple, but it costs money. I am not a heavy user of the office suite, mostly I need to be able to read documents and spreadsheets created by other people, so Open Office works fine for me.

Open Office is delivered in yet another packaging format, the DMG (or disk image) format. You download it, and OS X automatically mounts the virtual disk for you - in the case of Open Office, you drag the folder off the virtual disk into your Applications directory and that completes the installation.

There is also Neo Office, which is a fork off Open Office, which seems to be more popular among the Mac users I know. Heres a feature comparison between the different office suites.

IM Software: Adium

I need to be able to IM with Yahoo, AOL and GTalk users, so I need a multi-protocol client. On Linux I have used Pidgin (aka Gaim), but the IM client that comes standard with OS X does not include Yahoo. So I had to download Adium, a free multi-protocol client similar to Pidgin. I believe it came in DMG format.

SSH Tunnel Manager

I connect to my work desktop using VNC over a SSH tunnel. I have grown used to the convenience of the GNU SSH Tunnel Manager, and happily, there is a OS X equivalent, which I downloaded and installed. The configuration screen appears to have some bugs, but that could have been my unfamiliarity with the Mac keyboard.

VNC Client: JollysFastVNC

OS X has a built-in VNC client, which is quite good. But I installed JollysFastVNC, because my target viewport is much larger and I found the spyglass effect quite convenient for this setup.

Unison

Unison is a bidirectional file synchronization tool I have been using for about 4 years or so now, to sync files between my laptop and desktop at work. It works like a champ on Linux, but unfortunately I could not make it work on OS X. From the command line, it complains about leaking memory in text mode and just hangs in graphical mode. It seems to be a known problem with no obvious solution, so I have decided to roll my own script based on rsync (an improved version of the one I described here).

pwsafe

Like Unison, pwsafe is a nifty little tool I have been using for quite some time to generate and remember all my passwords for all the various sites I visit. Mac OS X provides built in tools (KeyChain) to do the same thing, but its going to be a pain to transfer all that stuff over, so I just decided to build this from source. I found out later that it is also available as a Darwin port, available using the port command.

Installation was not completely painless, but workarounds are documented in the INSTALL file, and they work.

Firefox

Mac OS X has the built-in Safari browser, which is quite nice. But I am used to Firefox, and most of my development work targets Firefox, so I installed that as well. Its a DMG download, and like Open Office, requires you to drag and drop your application into the Applications folder.

gedt

I tried to use the Apple TextEdit but I missed gedit, so I decided to download it using Darwin ports. Big mistake. From what I could make out from the logs and subsequent behavior, it ended up downloading most of gnome and then built a huge (static?) executable out of it - the install took around 1.5 hours with about 50 minutes of it spent compiling, at which time the CPUs were both pegged at over 90%. Launching edit results in a very ugly window (not Mac like) and out of memory messages on the console.

I later figured out how to use TextEdit (I am using it now to write the text for this post) for text files, and this is equally effective.

Scripting Languages

Jython

I tend to use Jython mostly for writing scripts that target Lucene or databases (MySQL and Oracle). I used to use PyLucene, cx_oracle and MySQLdb for these with Python, but I dropped PyLucene when moving to Lucene 2.4, and writing against the zxJDBC driver built into Jython is simpler than having to install multiple specific drivers for each database.

In any case, installation simply meant running the Jython installer and downloading its contents into my /opt directory.

Scala and Clojure

I don't use either Scala or Clojure regularly, but I want to learn these languages more fully, so I decided to have these around. Installation is simply a matter of expanding the tarballs into the /opt directory, and changing your profile to point to it.

I also want to install SWI-Prolog, another language that I want to understand and use more fully, but so far, haven't had the time to install and test it out.

IDEs

Eclipse/MyEclipse

I use Eclipse for all my Java development. To install, I used the MyEclipse 7.5 all-in-one bundle since it was available on the MyEclipse site. It comes in DMG format, but contains an installer which you have to double click to install Eclipse and MyEclipse together.

Netbeans

I use Netbeans for all my non-Java development, i.e., my Python, Jython, Scala, Clojure and Prolog stuff. For this, I first installed Netbeans 6.7.1, then used its update plugins feature to download and install the Python plugin. For the Clojure and Scala plugins, you need to download the NBM files and install using local update. This is not much different from what it is in Linux, except that the Netbeans IDE is in DMG format.

Other concerns

There is also a significant learning curve (probably couple of weeks, I am gradually getting the hang of this after about a week) on the machine itself. Mac OS X has a keyboard with 4 meta-keys (compared to 3 on a standard PC keyboard) and a 1 button mouse (compared to a 2 or 3 button mouse on PC/Linux mice). The various keys take getting used to.

There is also a heavy dependence on the spotlight tool (similar to the F2 command tool in Linux) to open applications. The menus are context sensitive to the application that is currently selected, so that takes some getting used to as well.

The directory structure is equally funky compared to a typical Linux installation. Applications are stored in /System/Library or /Applications and the directory structure is per application, similar to Windows. Its a bit hard to get your head around at first.

So I guess I am saying that you should be prepared for some loss of productivity in the first few weeks as you get the hang of the Mac.

On the hardware front, while the Mac is really sleek and beautiful and cool, it doesn't have the large number of different ports that PCs have, to connect to other devices. This isn't a problem for me, since I rarely connect to anything other than USB devices (and the OHP for which there is an adapter I can borrow), but if you do, you will need to buy the necessary (and expensive) Mac adapters.

Conclusion

Overall, I think the Mac is a decent machine as long as you don't look too deep under the covers. Unfortunately, as a developer who does anything outside of Java, you are very likely to do this, and consequently run into issues.

I also don't understand the motivation to completely reinvent the standard Unix directory structure. Of course, if you look deep enough, this is really a cover-up to make it "look" like a GUI OS, you will find symlinks that make more sense. My point though is that they could have done this the other way round - that way, people who are likely to look at the file structure directly would have to do less mental gymnastics, and people who are using a GUI would not care anyway.

Another gripe is the four different ways of installing files - using Darwin port, PKG format, DMG format, and from source. As a result of this "diversity", the only way to tell if a package is installed is to look at the Application folder through the GUI. Uninstalling involves dragging the application into the Trash can. One person I know hailed this as the "way software should be installed" - I think its a huge step backward - with Fedora, I can use yum to download almost any RPM I need, and I can find what is installed with a simple "rpm -qa | grep package". At my previous job, we also built our own RPMs and its really quite simple. A RPM GUI would have been a far more effective long term solution.

That said, its probably all a matter of getting used to a different way of doing things. Most of my issues have to do with initial setup (at least so far), and the little time I have actually spent using my Macbook has been quite pleasant, unless you count the learning curve of having to deal with the 4-meta keys, the absence of a Home and End key, and having to press the Control key to simulate a right button click.

9 comments (moderated to prevent spam):

Anonymous said...

Re: text editor, try text mate, its quite popular with programmers on OSX.

Anonymous said...

Just to share information, Samsung released a laptop that weights 1.27 KG and have a battery of 12 HRs.

Sujit Pal said...

Hi, thanks for the comments...

Regarding TextMate, I did check it out, it is quite expensive at $60/seat - its a bit weird to have to pay for this kind of stuff, coming from a Linux environment. Also it contains a lot more functionality than I will need - all I need is a non-terminal based editor which will always work with plain text. TextEdit seems okay mostly, except it tends to recognize and render HTML markup in the text and there is no way to turn it off.

Regarding the Samsung laptop, I think you are talking about the UL50 right? Yes, it seems like the right stuff.

Anonymous said...

Have you tried Text Wrangler? free and way better than textedit

Sujit Pal said...

Thanks, but from what I see on the website, it looks like overkill for me. I ended up using vim with pbcopy (for clipboard access).

Brendan said...

As you've made the switch from Linux to OS-X, you may be able to answer this question (still no answer from MacWorld forum)...

In Linux I use the symlinks in /Dev/Disk/By-Path/ to mount USB flash drives. The bespoke software is for test applications, where physical hub ports need to be referenced by the GUI for pass/fail information, so this approach has worked perfectly.

I now need to do the same on a Mac running Leopard, but alas there's no such By-Path directory with those informative simlinks.

Is there a way to extract the same type/level of information from OS-X? For the record we're using RealBasic as we can build application binaries for multiple platforms from a single project source, which (incidentally) can both issue shell commands and read responses directly if necessary.

With thanks in advance... and hope !

Brendan

Sujit Pal said...

Hi Brendan, not sure what you are asking, so I guess I will have to say "I don't know" :-). I do know that symlinks are supported in both Linux and Mac OS. One thing to note though is that Mac OS does not differentiate between case so /dev is the same as /Dev. Not sure if that is the problem here though?

skk said...

Thanks for the detailed description of your move from linux to Mac. I found it quite useful.

Sujit Pal said...

You're welcome, skk.