While possessions can be helpful in daily life, the more things you own, the more worries you have.
-- Dr. Stewart Bitkoff, A Commuter's Guide to Enlightenment
Monday, July 09, 2012
Monday, July 02, 2012
Monday, June 25, 2012
Monday, June 18, 2012
Monday, June 11, 2012
I want to be thoroughly used up when I die, for the harder I work, the more I live. I rejoice in life for its own sake. Life is no 'brief' candle to me; it is a sort of splendid torch which I have got hold of for the moment, and I want to make it burn as brightly as possible.
-- George Bernard Shaw
Monday, June 04, 2012
Monday, May 28, 2012
Monday, May 21, 2012
Monday, May 14, 2012
Monday, May 07, 2012
Monday, April 30, 2012
Friday, April 20, 2012
Wednesday, April 04, 2012
Earlier, I wrote about the programming language, Scala. I had planned to follow with a similar, somewhat academic discussion of the Lift Web Framework, which is based on Scala, and mongodb, a NoSQL database, before going into practical stuff like how to get started with this stack. But I can't help it but get my hands dirty, so here's how to get started. I'll go back and explain why I chose these components later!
First, the development environment. In my opinion, Mac OS X provides the most capable and powerful software development environments for all platforms that I've encountered, unless you're developing in .NET. I started programming at a Unix shell prompt, and call me old-fashioned, but try as I have, I'm just not feeling the love for IDEs. I'll leave that part of the environment setup for someone else to cover.
One missing piece of the OS X platform is a capable package manager. I chose Homebrew (http://mxcl.github.com/homebrew/). Installation is simple:
bash$ /usr/bin/ruby -e "$(/usr/bin/curl -fksSL https://raw.github.com/mxcl/homebrew/master/Library/Contributions/install_homebrew.rb)"Just follow the prompts. Then update so that the following installations are current:
bash$ brew updateNext, you'll need a build manager for your Scala projects. I chose SBT (Simple Build Tool - https://github.com/harrah/xsbt/wiki). SBT requires Java 1.6 or later, but I'll assume that you already have a suitable Java environment on your Mac.
bash$ brew install sbtMaven is another popular choice that might be more familiar to you if you're a Java developer.
Install mongodb (http://www.mongodb.org/display/DOCS/Quickstart+OS+X)
bash$ brew install mongodbInstall giter8 (https://github.com/n8han/giter8#readme). Wait a minute: Scala, Lift, and mongodb. You didn't mention giter8! What is it? It's a tool that lets you generate a local source tree from templates on Github. I'll use this later to generate source tree for a Lift, Scala, and mongodb app from a very nice template.
bash$ g8 eltimn/lift-mongo bash$ cd [your-project-name]Here, in your project directory, you'll find a README.md file that will walk you through configuring your new project. Here's a summary for convenience. Twitter Bootstrap is included via a git submodule, so after generating your source tree, you'll need to go to the project root directory and do the following:
bash$ git init bash$ git submodule add https://github.com/twitter/bootstrap.git modules/bootstrap bash$ git submodule init bash$ git add modules/bootstrap bash$ cd modules/bootstrap bash$ git co v1.4.0This will pull in the necessary files. Note that this template is built against Bootstrap 1.4. The current version is Bootstrap 2. I'm hoping that I won't have to upgrade anytime soon!
Next, configure mongodb. I installed mongodb locally for my development environment. If you do the same, you won't have to configure your application for mongodb; the Lift defaults will work just fine.
IMPORTANT: Due to a Mac OS/Java driver bug in which localhost:27017 is translated to <public-machine-name>/<public-ip-address>:27012, you will need to change the default mongodb setting and allow connections from everywhere (or at least from your local machine's public IP address) by commenting out the bind_ip line in /usr/local/Cellar/mongodb/2.0.2-x86_64/mongod.conf. Make sure you understand the security ramifications of doing this.
Then, start mongodb:
bash$ sudo mongod -f /usr/local/Cellar/mongodb/2.0.2-x86_64/mongod.confFinally, build and run the template app:
bash$ sbt > ~;container:start; container:reload /It will take a few minutes to build for the first time, because SBT will download and compile all of the dependencies. Subsequent builds are much faster. The app will start, and any time you change a source file, it will compile and reload automatically. It will be running on http://localhost:8080. Try registering and logging in.
So what did you not have to do in setting up this stack?
- Install an IDE, plug-ins, and lots of libraries
- Do a lot of database or other configuration
- Define or create a database schema
- Install Scala (Really? I'm not 100% sure, but I think SBT took care of this)
- Install Lift and Bootstrap (giter8 took care of this)
- Write any code (yet)
Pretty easy, right? I hope your experience is the same, and I really hope that I didn't forget any steps. Please give this a try and let me know how it goes.
Friday, March 30, 2012
A couple of years ago, after spending many years focusing on managing technology businesses, I decided to re-discover what first attracted me to technology and dust off my coding skills.
Of course, the world of software development has changed a lot since I last coded for a living. For instance, as much as I have tried, I have yet to become comfortable with IDEs, so I still tend to prefer working at a shell prompt, with command line tools. On the other hand, I thoroughly enjoy the availability of powerful, sophisticated open source projects, vibrant development communities, and lots of good, working sample code that can dramatically accelerate the development of sophisticated applications.
Over the last couple of years, I taught myself Python and played around Google App Engine, Hadoop, and Amazon Web Services. I taught myself PHP and developed some code that's actually being used in production. I appreciate the fact that, as an old-school C programmer, both Python and PHP somehow feel familiar to me.
I see a lot of great code being written in Java, Python, PHP, and Ruby, with many businesses achieving incredible scale on those platforms. But something was still missing for me, and I have yet to put my finger on it.
In looking for a software stack for my latest project, I stumbled on Scala. It sounded intriguing. Some really cool companies like Twitter, LinkedIn, Tumblr, and Foursquare were reported to be using it, and truth be told, I wanted to be cool too, so I started to dabble. The requisite "Hello World!" took just a few minutes to master, and I was well on my way to figuring out what a software stack based on Scala might look like.
But wait... I'm getting ahead of myself. I'll talk about the rest of the stack, later. More on Scala, for now.
The second notable fact about Scala is that it compiles to the same byte-code as Java, runs on the JVM, and interoperates with existing Java libraries. This means that it has all of the scalability and performance of Java, along with access to a the wealth of mature, feature-rich Java libraries that have been developed over the years. Further, many Java developers will find some familiar tools for developing in Scala like Eclipse, IntelliJ IDEA, Maven, and JUnit. Scala applications can also be deployed in familiar application servers like Spring. Together, these factors provide an incredibly vibrant ecosystem in which Scala can thrive, effectively mitigating many of the risks associated with Scala being a relatively new language.
The third notable fact about Scala is that it is open source (BSD License). The compiler, libraries, and all of the tools needed to build a feature-rich Scala-based Web application are available at no cost (though you can pay for commercial support if you need it).
- Supports both functional and object oriented paradigms. This is important because there are a lot of developers out there who are familiar with object oriented development but not so many who are familiar with functional programming (at least not that I am aware of). You can start off writing Scala code that looks a lot like your Java (or other OO) code and then ease yourself into FP.
- Static typing with type inference, reduces the need for explicit type declarations.
- Everything is an object.
- Traits allow you to cleanly implement cross-cutting concerns.
- Encourages immutability, which helps with concurrency and correctness when working with threads.
- Pattern matching lets you quickly and easily find the objects and data that you are looking for without writing a lot looping and comparing code.
- The compiler catches lots of mistakes and helps ensure correctness.
As a language, Scala is very concise. I haven't yet run across any instances where I needed to write a lot of the boilerplate that you need to write in Java, for instance. Pattern matching, traits, immutability, and type inference also help reduce the amount of code that you need to write, I've heard by a factor of two or three, compared to Java.
In conclusion, you can write good or bad code in any language. There is no substitute for good developers. But from my initial experiences, I believe Scala offers developers some compelling benefits, with few downsides:
- Rich ecosystem
- Familiarity to ease adoption
- Developer productivity
Here are some Scala resources that I found helpful:
- Official Scala Site
- Scala Documentation
- The official language reference docs.
- Twitter Scala School
- Written material from a series of lectures that Twitter to introduce experienced software engineers to Scala.
- Twitter on Scala
- Great, first-hand experiences from people who have built real, sophisticated, high-volume apps using Scala
- Engineer-to-Engineer Talk: How and Why Twitter Uses Scala
- More first-hand experiences.