Primary IDE

Friday, February 5, 2010

Experience of Switching to Mac for Java Development

I decided it was finally time.
For a couple years now, I've been an extreme minority as a PC carrier in a sea of Mac wielders in virtually every Java developer-related gathering. I've come to the humble conclusion that they must know something I don't. It's not just the "cool kids"-- the young bucks fresh out of college, barely able to render visible facial hair; even the grizzled, battle-hardened gurus and leaders in our field are sporting Macs.
As an "Average Joe" developer, I'll admit the idea of straying from the development platform I'd painstakingly chiseled a comfortable cockpit out of was somewhat daunting. I began my Java escapade in Fall 1999 on Windows NT, bouncing back and forth between Microsoft J++ and VisualCafe. I jumped around IDE's when VisualCafe fell out of favor, trying in vein to stay away from the Swing-based GUI IDE's (NetBeans, JBuilder, etc.). Alas, circa 2002 Eclipse 2.0 arrived and I was instantly hooked. It gelled with me and I've been with it ever since. So it's been Windows XP and Eclipse, until this week.
I am fortunate enough to work for an employer and manager willing and able to invest in both education and hardware for its developers. I decided to take advantage of this generosity and put in an order for a MacBook Pro. I acquired my new machine on Monday, and spent the better part of this week getting oriented to the new machine and setting up my environment and tools. The following outlines the steps I took to get up and running doing enterprise Java development on my new Mac.
Let me first describe our development stack: JSF/RichFaces front end; mix of SEAM, Spring, and stateless session EJB's for the middle tier, JPA/Hibernate for DAO layer, running on Geronimo J2EE app server. Full open source stack, deployed on Red Hat, hitting a Postgres DB. Maven 2 is our build system. We are also using Eclipse BIRT as an embedded report generation engine. This was all perfectly manageable developing with Eclipse Ganymede and Galileo.
So, time to leave my comfort zone. Enter the Mac... Needless to say, it's a beautiful machine. But you already know that from the fan boys, the Apple marketing machine, and probably the kid sitting next to you. I'm going to talk about practical issues I faced as I re-tooled on this sleek machine, bearing in mind my Unix familiarity is just so-so, and I haven't used a Mac since my LC II got me through college. This was my plan of attack:
  • Browse system, Finder, etc. Get oriented.
  • Check system specs: 3.06Ghz Intel Core 2Duo, 8gb 1067Ghz DDR3 Ram-- yeah baby!
  • Install FireFox, FireBug
  • Install Java
  • Install Maven
  • Install Geronimo App Server
  • Install IntelliJ IDEA 9 (yep, switching IDE's too!)
  • Install Cisco VPN
Here are some notes:
  • The Finder is ok, nothing mind blowing. Pretty much the same as I remember. It is possible to customize the listings on the left of the Finder window, something I never figured out how to do on the similarly purposed Windows File Open dialogs. The default view is multi-columned, much like the default view for iTunes.
  • One of the first things I did was launch a console window. My machine was set up by a network administrator, and while I have admin privileges, I'm not "root", so I have to do sudo commands to write to certain directories like /etc.
  • One annoying behavior I'm running up against is the directories listed in the Finder do not represent the actual file structure found on the command line. The main issue is that many folders are hidden in the GUI. Perhaps this is simply a permissions issue and I'll be able to change some of these so they show up in the Finder. For instance, I can't see /tmp or /etc in the Finder.
  • Java comes pre-installed on all Macs. In fact, you can't even get it from Sun, er I mean Oracle. The JDK download page will instruct you to update your system software to ensure you have the latest Java software installed.
  • Maven is also pre-installed, believe it or not. Make sure the installed version is the one you require, otherwise install your own and don't forget to modify your PATH env var in ~/.profile or ~/.bash_login.
  • Speaking of setting environment variables, this I spent a little time on. The method prescribed by Apple is to set env vars in a special file called environment.plist. Instructions are Here. This will make the vars available in the command shell and in all apps. The one known caveat to this approach is that evidently the vars are not accessible in apps launched via Spotlight (a fancy desktop search utility). To address this issue, I found this post. Lastly, here is a nice little utility applet which allows edits to the magical environment.plist file from the System Preferences window, much like we do in Windows via System->Environment Variables.
  • I had to copy my maven settings.xml file over from my windows machine to ~/.m2/settings.xml. This points to our internal Nexus repository.
  • After installing Geronimo, I utilized a feature of OS X called Automator to create a keyboard shortcut for launching the app server startup shell script. Automator is a fairly elaborate macro builder for automating just about any conceivable series of operations on the machine. Here's an article explaining how to do this.
  • I'm not a huge IM junkie, but I liked using Pidgin on Windows, which is an open source multi-protocol chat client. I went to the Pidgin website to grab a Mac version, but it looked like their Mac support is not quite prime time; it uses some windowing platform other than GTK, and I had to build from source, so I said no thanks. I found a worthy alternative in Adium.
  • The multi-touch track pad on the laptop is very nice. It's very large, and it supports 1, 2, 3, and 4 finger gestures.
Parallels for Windows
I asked our desktop support team to install Parallels and Windows XP on my machine, both as a safety net and because we have a few apps which require Windows and IE: HP Quality Center (a hideous client-server desktop app ported to IE via ActiveX controls), SharePoint, and Outlook. Parallels is a virtual machine which allows the installation of another OS and even melds the Windows and OS X desktops into one if you want. It supports all recent versions of Windows. I don't know if it supports any Linux distros. Since my machine is fairly well equipped, it runs the VM with relative ease. The Windows OS looks absolutely native, and it feels almost native-- very slight lag dragging windows and such, but all operations perform in about the same speed as my newish Dell laptop. I highly recommend running Windows in Parallels if you are at all uneasy about switching to Mac. This at least offers you a gradual transition to Mac land.

Final thoughts
So here I am at the end of my first week on my new Mac, and I can honestly say I have no regrets. I'm still getting used to the slightly different keyboard layout, window operations, and file locations, but other than that I'm feeling relatively at home. I believe it's a good thing to leave one's comfort zone once in a while-- take on a new role, assume new responsibilities, or just try something different. It's not always a good time to leave one's comfort zone; your gut should be able to tell you whether it's ok or not. Butterflies are generally ok; nausea or ulcers mean you should probably wait ;-)

Sunday, September 20, 2009

NFJS Seattle Recap

Just returned home from a great weekend symposium in Redmond hosted by the No Fluff Just Stuff (NFJS) crew. This was the first conference of its kind for me and I have to say I was very impressed with the quality of the presenters and their content. The topics were all Java-related, and ranged from memory management to objective-j to clojure and on and on. All the presenters were serious experts in the field, all accomplished authors, consultants, and active contributors to various open source or similar industry projects. Is it just me, or do these guys (sorry ladies, but none of you presented this weekend) just impress the hell out of you too? I mean, some people appear to be just so productive and accomplish so much, where do they find the time? So seriously, these are the real deal-- true rock stars. I am truly humbled by these guys, and this feeling was my inspiration for launching this blog. Anyway, here are the topics of the workshops I attended, all of which I thoroughly enjoyed:
  • On Being a Software Architect (Mark Richards)
  • Common Anti-Patterns and How to Avoid Them (Mark Richards)
  • Groovy Testing (Scott Davis-- I bought his book "Groovy Recipes")
  • Architecture and Scaling (Ken Sipe)
  • Design Patterns in Java and Groovy (Venkat Subramaniam)
  • Open Source Debugging Tools for Java (Matthew McCullough)
  • Mastering Maven 2.0 (Matthew McCullough)
  • Iteration 0 (Ken Sipe)
  • Git Going with Distributed Version Control (Matthew McCullough)
  • Garbage-collector-friendly Programming (Brian Goetz)
  • Busy Java Developer's Guide to Advanced Collections (Ted Neward)
My key takeaways from these sessions are:
  • Doing unit tests in Groovy is super cool, especially when coupled with "easyb". I can't wait to show my buddies at work this stuff.
  • Groovy is great for implementing some common design patterns.
  • Get familiar with distributed version control, using either Git or Mercurial. Matthew was so excited about it he nearly passed out from neglecting to inhale. I think he's a little too excited about it (I'm worried about him). One of the million things he mentioned was that Git support was just brought on as an official initiative of Eclipse, so watch for that.
  • There are many debugging tools I should be taking advantage of, most of which are already included in the JDK.
  • There are many functional programming-esque techniques related to the java collections API which can be leveraged to create more thread safe and multiprocessor-friendly collection-related code. Check out apache commons collections or google collections for some pre-built examples.
  • Functional programming is all the rage, and I don't think it's going to go away anytime soon. Most of the gurus are touting Scala, with Howard Luis Ship leading the Clojure charge. I myself am cozying up to Scala, but I think it will be a tough sell in my current organization (Groovy is more likely, at least in our test suite). Learn a functional language, preferably one which runs on the jvm.
If I can get my momentum going on this, I will follow this post with more detailed info and experiments with some of the topics above and perhaps others. Most likely my ambition will fade and this will be my first and last post on this blog, but you never know when I'll actually stick with something (hey, I'm still married, and I'm still a java developer after 10 years...). That's about it for now; I've got to get to bed. I'm not one of these over-achievers who stays up half the night cooking up new programming languages and launching companies like the guys I just spent the weekend with. If any of the NFJS guys are reading this, I'd like to thank you one more time for a great symposium. And to all the other Average Joes I met there, it was a pleasure meeting and chatting with you. Jeff, thanks for the ride back to Seattle. Mark, good luck in your move to Tacoma. To the clan of Canucks, hope you made it across the border ok. Good night!