Category Archives: Cool Stuff

Getting Started With Meteor Tutorial (In the Cloud)

In this Meteor tutorial, I am going to show you how to quickly get started with the JavaScript Framework, Meteor, to develop a Meteor application completely from the cloud.

I’ve been pretty excited about Meteor since I first saw a demo of it, but it can be a little daunting to get started, so I thought I’d create a simple tutorial that can get you running in about 30 minutes or less.

I’ve included a YouTube video along with this blog post to help you get up-to-speed quickly.

What is Meteor?

Before we get started we should talk about exactly what Meteor is.

Meteor, or Meteor JS, is really more of a JavaScript platform than a framework. It’s built on top of Node.js and is based on the idea of creating a high-quality, reactive, web application very quickly.

Meteor is purely JavaScript. That means that the entire application is built using JavaScript. Part of it runs on Node.js on the server, and part of it runs on JavaScript in your browser.

Meteor basically provides all the plumbing for you to build a Single Page Application or SPA, without you having to wire everything up and worry about syncing data and updating templates.

What is a cloud IDE?

When I first heard of a cloud IDE, I didn’t really understand what it was–rather, I didn’t grasp how valuable a cloud IDE was. A cloud IDE will let you develop and run an application completely in the cloud with your browser.

This means that you can log into your IDE from any web browser and start developing your application.

For Meteor, this is really neat because you don’t have to install and run Meteor locally. You can utilize a Cloud IDE to run and develop a Meteor application completely on a Linux box in the cloud. You don’t even have to know much about Linux.

digital ocean   Cloud9   Google Chrome 2014 10 12 14 41 17 Getting Started With Meteor Tutorial (In the Cloud)

Now, I found that most of the Cloud IDEs out there were a bit sluggish when trying to run a Meteor application on them. I had almost given up, until I discovered that I could hook up the Cloud9 IDE with my own more powerful Linux virtual machine that is hosted at Digital Ocean.

This setup was so fast and impressive that it is completely worth setting up, so in this tutorial, that is where were are going to start.

Getting set up

The first thing you’ll need to do to get set up is to create a Digital Ocean account. Digital Ocean provides extremely cheap Linux virtual machines in the cloud. In fact, this website is hosted on a Digital Ocean machine that I pay $20 a month for (and it gets over 100k hits a month.)

Like I said before, you can just use the Cloud9 IDE by itself for running your Meteor app, but if you instead utilize a $10 / month Digital Ocean box, you’ll find everything to run about 3-to-4 times as fast–no joke.

The other alternative is to download and install Meteor on your own Linux box or Mac, but I like how easy it is to develop in the cloud–especially since you can do real-time collaboration with another developer.

If you want to use your own machine and don’t want to use a cloud IDE, just skip down to the section where we install Meteor and you can follow the same instructions, just on your own machine.

(By the way, the above link is an affiliate link–just wanted to let you know–so thanks if you sign up through it.)

Creating a Cloud9 account

Next, you’ll need to create a Cloud9 account. You can just sign up for the free account for now, but if you want more private workspaces, you’ll need to sign up for a paid account. I find the prices to be pretty reasonable though.

(By the way, the link for Cloud9 is not an affiliate link. They don’t have an affiliate program, but I still recommend them, because they are awesome–especially when hooked up to a Digital Ocean box.)

Connecting Cloud9 with Digital Ocean

The next step is to create a new Digital Ocean box that we are going to use SSH to connect to from the Cloud9 IDE. Don’t worry though, this is easier than it sounds.

Rather than repeating all the steps here, you can watch this excellent video that a Cloud9 developer put together that shows you exactly how to do it:

Installing Meteor

Now that we are all set up, we need to get Meteor installed. Fortunately, this is pretty easy. In fact, you can do it with a single command.

Just execute the following command at a terminal window:

curl | /bin/sh

This command will pull down and execute a shell script which will install Meteor in your environment.

Yes, it really is that simple.

If you want to test out your Meteor install, execute the following command to create an example application that you can play around with:

meteor create –example leaderboard

This will create an example Meteor application called “Leaderboard.” Now, execute the following commands to switch to the Leaderboard project’s directory and start the application:

cd leaderboard


If all is well, you should see Meteor start a MongoDB instance as well as itself. You can connect to your Leaderboard app by going to the IP address of your machine and port 3000.

If you are using a Digital Ocean box, just use the same IP address you used when you set up the SSH connection to Cloud 9.

Go ahead and play around with the Leaderboard example app and take a look at the code. To really see the power of Meteor, you’ll want to open up two browser windows, each pointing at the app and see what happens when you make a change in one.

The Meteor tutorial app we are going to create

Ok, now we are ready to move on to creating our own Meteor application.

The application we are going to create is going to be a very simple TODO list application that we’ll call “Spartan TODO.”

The application will have a very simple UI and have the following basic features:

  • Show a list of items to be done
  • Add a new item to the list
  • Click an item to toggle it to and from a “done” state
  • Double click an item to delete a done item (I’ll leave this one for an exercise for you to do on your own.)

A pretty simple application, but it will take us through a pretty good cross-section of what Meteor can do. So, let’s get started.

Creating the project

The first thing we need to do is to create a new Meteor project.

In order to do that we just need to go back a directory from the Leaderboard project and create our TODO list app project. In order to do that execute the following commands:

cd ..

meteor create spartan-todo

This will create a default “Hello World” project for us in Meteor that we can modify to create our own project. Let’s go ahead and start it up with:

cd spartan-todo


Ok, so here is something pretty cool about Meteor: The whole time we are developing our application we can just leave it running. We can make changes to our application and–without having to recompile or restart the application–those changes will be applied live. We don’t even have to refresh the web browser. This is pretty cool.

Point your browser to the address of your machine and port 3000 to see the application.

Go ahead and try changing some text in the HTML to see it update live.

What’s in the Meteor tutorial project?

Before we move on, let’s take a quick moment to talk about what is in the Meteor project we created.

If you look in the spartan-todo directory, you should see 3 files:

  • spartan-todo.css – the style sheet file for our entire application
  • spartan-todo.html – the main HTML file that will be displayed
  • spartan-todo.js – the JavaScript code that will execute on both the client and the server

Meteor is pretty flexible in how you structure your project. The default app template is a very simple project structure, which we’ll stick with for this Meteor tutorial.

With this structure, you can expect the HTML file to be rendered using Meteor’s templating language, Spacebars (very similar to Handlebars.js) You can define any templates you want your application to use inside this HTML file, or you could create additional HTML files that this main HTML file references. The name of the file doesn’t matter, Meteor will just look for all the HTML files in your project and will actually create a single HTML document to be transferred to the client. But, for the purposes of this Meteor tutorial, you can ignore that. We are just going to use one HTML file.

Another important thing to point out is that by default all the JavaScript files are run on both the client and the server. So, again, it doesn’t matter what your JavaScript files are named, all the code will be executed. You can see in the spartan-todo-.js file that there is some code that says:




We can use those functions to have code only run in the client or the server, if we need.

There is also a folder convention we can use that controls whether code runs on the client or server or both, but for now we’ll ignore that and keep everything in these three files.

You can find the exact details on how this works in the Structuring your application section in the official Meteor documentation.

Creating the user interface

Now that we have a running Meteor tutorial application, the first thing we are going to do is create a hard-coded version of the UI that we’ll be using in our application.

I always find it is best to start by just hard-coding all the HTML for a screen in an application, before going and adding real functionality. It makes things less confusing and you don’t waste time trying to change layouts and code at the same time.

Open up your spartan-todo.html file and replace its contents with the following code:

This will create our basic user interface for our application. If you switch to your browser, it should auto-update and you should see something that looks like this:

hardcoded ui Getting Started With Meteor Tutorial (In the Cloud)  

Using templates

The next step will be to go from having a completely hard-coded HTML page to an HTML page that uses hard-coded Spacebars templates. In Meteor, we can define templates in our HTML files in order to break up and abstract away parts of our application as well as allow for our HTML to be generated based on data from our application. For now, we are going to keep things pretty simple. We are just going to break apart our HTML into a couple of templates. Replace the contents of your spartan-todo.html file with the following code:

When you go back to your browser, you shouldn’t see anything different, but now we are utilizing templates–just not very well.

Populating data with templates

The next step is to make it so the templates are actually being populated with data from our application. We are going to start off by hard-coding the data, in the application, but making it so the templates use that data to render the HTML.

Again, I like doing this baby-step approach–especially when starting out.

What we really want to do is make it so that the <li> elements we have in the HTML are not hard-coded, but are generated by some data that defines the items in our list.

We can do that in Meteor by utilizing the #each syntax in the Spacebars template.

Replace the content of your spartan-todo.html file with the following code:

What we’ve done here is replace the hard-coded list items with some templatized code that tells Meteor to loop through some collection of things called items and for each thing in that collection to write out a list item and a field from that item called “description.”

So, in order to get this template to work, we need to provide the template with a collection named “items” and the items in that collection need to have a field named “description” that has the description of the TODO list item we want.

In Meteor, the simplest way to do this is to utilize what are called template helpers. We can create a template helper in our JavaScript file that will define the data that will be returned when the template looks for “items.”

Replace your spartan-todo.js file with the following code:

This code defines a helper for the template named “list” called “items”. That “items” helper contains a function that returns a hard-coded list of items in the form of a JavaScript array. Each of the items has a description field.

When Meteor renders the template, it will utilize the helper method to fill in the data the template needs.

After you’ve made this change and saved the file, your browser should automatically reload the changes, and you should see the new TODO list items we created.

Now, the data is still hard-coded, but it is coming from the actual application itself.

Populating data with collection

We still are hard-coding data and we have no way to add new items to our TODO list, but before we can fix that problem, we need to move the data down just one more layer and introduce an important concept in Meteor called “collections.”

Remember how I said Meteor uses a MongoDB as a document database for your application? Well, that is where we ideally would like to store our TODO list items.

In order to do that, we need to define a collection in our Meteor app, which we can use to populate our MongoDB and query it later to get TODO list items back out of it.

In Meteor, by default any collections we define on the server are also available on the client. What this means is that in your browser, you can actually interact with the application’s MongoDB instance as if you were writing server code.

Meteor does this by creating a MongoDB proxy on the client side that forwards data down to the server. This MongoDB proxy is also kept in sync with the server instance by default. So, that means any data that exists on the server, can be accessed directly from the browser. (This is the default behavior, which you’ll want to eventually turn off in your application and specify manually which data to sync, but for the purposes of this Meteor tutorial, we’ll take advantage of this.)

Replace the contents of your spartan-todo.js with the following code:

There are two things we did here. First, take a look at line 1. Here we declared a new Meteor collection called items. Since this code is outside of the client and server blocks, it will be run on both the client and the server. We don’t have to write the same code twice. This code will define a MongoDB collection we can use in our application. With a document database, like MongoDB, we don’t have to declare what fields are on the collection or anything else.

Next, take a look at lines 13 through 22. What we are doing here is populating some default data if the MongoDB collection is empty. This will just give us some seed-data to work with. We could leave this code out, but if we did we wouldn’t be able to tell if everything was working.

Finally, take a look at line 6. Here, we have updated our helper function for items to cal Find() on the Items collection to get its data instead of using the hard-coded values we had before. If you switch over to your browser, you should see the TODO list with the default items we added to the collection. Now that our application is being driven by real data in a database, we can add some actual real functionality to our Meteor application.


Adding items

The first real bit of functionality we are going to implement will be to add new items to our list. In order to do this, we just need to add new items to our Items collection and Meteor will take care of the rest for us.

We’ll need to utilize template events to execute some code when someone clicks the add button to add a new item to our list. In Meteor, we can define events on a template, just like we can define helpers. You can really think of these as event handlers, since we’ll be writing code to handle different events that occur inside the template.

What we want to do is to define an event on the controls template that will be triggered when the form is submitting. This could happen when someone clicks add, or when they hit enter on the keyboard. In our event handling code, we’ll want to cancel the default action of submitting the form to the server, since we’ll handle everything in our client code.

Then, we’ll want to get the description of the item from our text input and insert a new item into our Items collection. Meteor will know that there is a change in our collection and will respond by rerendering the affected part of the DOM in the browser. Meteor templates are by default “reactive” in this way and constantly watch for changes that would affect the HTML they rendered.

Replace the contents of your spartan-todo.js file with the following code:

Take a look at lines 10 through 17.

What we are doing here is adding an event handler for the “submit form” event. Whenever the form is submitted on the page, this code will be executed.

In this code, we are first canceling the default action, which is to post the form to the server.

Them, we use some JQuery to grab the value of the newItem text input and store it in a variable.

Finally, we insert a new object into the Items collection with the proper description.

After you save this code, you can go ahead and try it out. Add a few items to the list. You can also try opening a second browser and watching how the data is synced between both clients.

Marking items done

The last step we want to do in this Meteor tutorial is to make it so that we can mark items as done by clicking on them and unmark them by clicking a second time.

Again, we will need to use events to do this.

The basic idea will be to create an event handler that will respond to a list item being clicked in the list template that will toggle a “done” field on the item to indicate whether or not the item should be marked as done.

We’ll use a CSS class that will apply a line-through to the list items marked as done.

Let’s start with the CSS class. Just add the following line to your spartan-todo.css file:

.done {
text-decoration: line-through;

Next, replace the contents of your spartan-todo.js file with:

Let’s start by looking at lines 25 through 30.

What we’ve done here is created a new event handler for the list template that will trigger when a list item is clicked. This event handler will simply update the item in the Items collection by setting a “done” field on it to the opposite of what it was. This will result in the done field being set to true the first time it is clicked and from then on toggle between the two values.

How do specify which item we want to update?

Every object in our collection automatically gets a special field named “_id.” We can use this field to uniquely identify each item. But, how do we get a reference to the item?

You may have noticed the “this” keyword being used in this code. Whenever we are executing event handling code in a template, the this variable always points to the data that triggered the event. We automatically get the correct context, so when we refer to “this._id,” we get the ID of the object that represents the list item that was clicked on.

Notice also the special syntax we have to use to update an item and set a new field value in MongoDB. It might seem a little bit strange, but that is how it is done in MongoDB.

Next, take a look at lines 8 through 13.

Here we are defining a helper function called “doneClass” that will either return the string “done” or an empty string, depending on whether or not the item being evaluated when this helper is invoked in the template.

We can use this code to make it so the list template can assign our “done” class only to items that are marked as done.

In order to do this, simply replace line 15 in your spartan-todo.html file with the following code:

<li class=”{{doneClass}}”>{{description}}</li>

Save everything and open your browser and you’ll find that you can now click on items to mark them as done and click on them again to mark them as undone.

The template calls our helper function “doneClass” to determine what text to insert into our class statement on each li element.

Deleting items

Ok, now it’s your job to implement deleting items in our Meteor application.

I’ll give you a bit of a hint. You can utilize the “dblclick li” event to make it so that whenever someone double clicks a list item it is deleted. See if you can figure out how to implement that functionality in the Meteor app.

Meteor tutorial wrap up

So, there you have it: a very simple TODO list application in Meteor. I’ve actually created a screencast you can watch to follow along, if you’d like. You can find it below:

If you happen to be in the Copenhagen area or are planning on attending the At the Frontend conference on Nov 4th 2014, I’ll be there doing a “Getting Started With Meteor” session where I’ll be creating this TODO list application and going over a little more about Meteor.

If you found this tutorial helpful, please share it with anyone who you think might be interested.

Also, join over 5,000 other developers who are part of the Simple Programmer community by signing up here. You’ll get weekly emails with career tips, tutorials and other practical advice for software developers and special discounts on Simple Programmer products.

Some additional resources

Also, if you are looking to dive a little deeper into Meteor, I’d recommend starting out with this excellent book that you can get for just 99 cents, “Your First Meteor Application: A Complete Beginner’s Guide to the Meteor JavaScript Framework.”

And, I have created a Pluralsight course called “Meteor.js Fundamentals for Single Page Applications” that covers Meteor much more in-depth.

Software Developer Gifts (And Other Tech Geek Gifts)

Software developer gifts aren’t easy to find.

Buying gifts for software developers can be pretty difficult for a few reasons:

  • Software developers already buy what they want before you get a chance to buy it for them.  (I know I am guilty of doing this myself.  I’m a bit impatient to wait for a gift.)
  • Developers often are very picky about a specific keyboard or headphone or gadget, so you can’t just pick one—it has to be the right one.
  • Non-software developers and non-tech people don’t understand anything about our world, so it is hard for them to know what we like.

I’m creating this list not only for gift givers who happen to stumble here through Google, but for you.  That’s right, to give yourself the gift that your friends and family failed to give you, because they just don’t understand you like I do. wlEmoticon winkingsmile Software Developer Gifts  (And Other Tech Geek Gifts)

This isn’t exactly my Christmas list, since I already have many of these items, but some of the tech type of stuff that I like myself.  (No particular order)

Turtle Beach Ear Force Z300 Wireless Amplified Stereo PC Gaming Headset

I actually just bought a pair of these headphones, and I like them quite a bit.

The audio quality is really good.  The battery life is great, and they are super comfortable.

z3001 Software Developer Gifts  (And Other Tech Geek Gifts)

I really like the idea that this wireless headset has both Bluetooth and dual band Wi-Fi wireless.  This feature makes it very versatile, because I can use it for gaming, but I can also use it for listening to music on my phone or iPad and for Skype calls.

I thought about getting a wired headset, for a bit better sound quality, but I prefer the versatility instead.  If I were going to get a wired one, I would get the

Audio-Technica ATH-M50’s though.  After quite a bit of research, it appears those are the best value for your dollar in terms of wired headsets.

ath m501 Software Developer Gifts  (And Other Tech Geek Gifts)

Netduino or Arduino

I’ve got an Arduino as well, but I haven’t really played around with it that much yet.

Both of these are basically small programmable micro-computers that you can use to build all kinds of things.  They are basically programmable circuit boards that you can attach all kinds of sensors and actuators to in order to create your own gadgets or experiment with programming machines that actually interact with the physical world.

The Arduino is programming using a C-like language and the Netduino, is programmed using C# or another .NET language.

When I bought my Arduino, I made the mistake of buying just a barebones one, so I didn’t have many projects to get me started with.  (Although this barebones one does make a very good budget gift, since it is so cheap.)

I’d really recommend for Arduino, getting a kit like this one.

516WfICIppL1 Software Developer Gifts  (And Other Tech Geek Gifts)

For the Netduino, this kit looks pretty awesome, although a bit more expensive.

netduino1 Software Developer Gifts  (And Other Tech Geek Gifts)

The nice thing about these gifts is that the price can be as high or low as you want.  The cheapest barebones boards are very cheap, but you can buy a kit or add on to the board with accessories to up the price if needed.  Also, great future gift possibilities.

Rosewill Mechanical Keyboard

I’m not a huge keyboard geek, but I do love typing on a mechanical keyboard.  It reminds me of the days when I first got into computers and most keyboards were mechanical.

I have a Rosewill myself, and I really like it.  It just feels good typing on it.  Not sure if I type faster or better, but I have much more fun doing it.

There are a few different kinds of switches, I’d recommend reading this post to understand the differences.  (There are some nice animated GIFs, if you don’t feel like reading the whole thing as well.)

rosewill1 Software Developer Gifts  (And Other Tech Geek Gifts)

If you are really hardcore, you can go with the Das Keyboard.  I have heard great things about it as well, and I know Iris Classon just got one that she loves.

61RtEiq9WNL. SL1500 1 Software Developer Gifts  (And Other Tech Geek Gifts)

Plugable UD-3900 USB 3.0 Universal Docking Station with Dual Video Outputs

Ok, this thing is awesome, but it is a bit confusing.  Let me explain what it does.

Basically, you connect this to a USB 3.0 port on your PC, or, more likely, laptop and it acts like a docking station that gives you a bunch more USB ports, a couple of audio ports, wired networking (gigabit), and TWO—yes, that is right it is not a typo—TWO HDMI or DVI connections to connect two extra monitors.pluggable1 Software Developer Gifts  (And Other Tech Geek Gifts)

What does all this mean?

It means that you can take your laptop, connect it to this bad boy and hook up 3 external screens to it in addition to the laptop’s screen.  (One of these screens would come from your laptop’s output.)

What do I use it for?

I have a Mac and PC laptop, as well as a PC desktop.  So, I can switch between all three of them and have all three of them share the same keyboard, mouse, microphone, etc.

The price is extremely cheap for what it does as well.

SwissGear Computer Laptop Backpack

I’ve got one of these backpacks, and I really like it.

It has lots of compartments to hold all my electronic devices and it feels like it is made very well.  Mine is also very comfortable to wear.

All of the SwissGear line is also very reasonably priced.  You can find better backpacks at higher price points, but as far as bang-for-buck, I’ve found the SwissGear backpacks to be hard to beat.

Here is the most popular and highest rated one on Amazon:

backpack1 Software Developer Gifts  (And Other Tech Geek Gifts)

Even if you don’t get a SwissGear backpack, a backpack is a great developer gift, because most of us are always carrying around a laptop and several other tech gadgets.

Fitbit Flex Wireless Activity + Sleep Wristband

Since I’m into fitness, you know I’m going to recommend at least one fitness related gift idea, and the one I’d recommend now would have to be the Fitbit.

I’ve got a Fitbit Flex and I love it.  The thing I like most about it is that I can basically just leave it on all the time and forget about it.  It also wirelessly syncs with its app on my phone, so I don’t need to dock it or charge it to get its data wherever I am.

The battery also lasts a pretty long time, (about 4-5 days,) which makes it much less of a hassle than the old version I used to have.

I haven’t tried the newer version of the Flex that has the display yet, but it is a bit more expensive.

Great way to keep track of your activity to help you develop a habit of being active.

fitbit1 Software Developer Gifts  (And Other Tech Geek Gifts)

Fujitsu ScanSnap iX500 Scanner

This one is a bit more expensive, but totally worth it.  I’ve got the competitor to this product, the scanner that comes with NeatDesk, but I’ve been wanting to switch to the SnapScan, because it is wireless and can scan directly into Evernote.

I’ve been scanning all my documents for several years now and it really cuts down on clutter.

Best of all, since everything is in Evernote, I can find anything I need instantly, no matter where I am.

61kbLXYapNL. SL1500 1 Software Developer Gifts  (And Other Tech Geek Gifts)

Raspberry Pi

Many people get this one confused with the Arduino and Netduino, but this is a completely different thing.  The Raspberry Pi is a super cheap computer on a chip.  Not just a processor, this thing runs a real operating system and you can use it for all kinds of things.

This is a great little toy to hack around on and create a web server or tiny gaming box (MonoGame actually runs on this thing.)

And the price is extremely cheap for the starter version, but I’d recommend getting a kit like this one:

raspberry pi1 Software Developer Gifts  (And Other Tech Geek Gifts)

i.Sound Portable Power Max Rechargeable Battery with 16,000 mAh

I like this portable power charger, but there are other alternatives that are a bit lighter as well.

Everyone should have some kind of portable power charger though—especially if you travel quite a bit.

This thing will really extend the life of your phone or tablet and is great in an emergency situation when you are out of power.  I used to get backup batteries for my phone, but this is a much more versatile option.

This particular charger also allows you to charge up to 5 devices and it can charge at 2.4 Amps, which will give you the fastest charge for a device like an iPad.  (Really important to know about, because not all USB chargers charge at the same rates.)

charger1 Software Developer Gifts  (And Other Tech Geek Gifts)

Kindle Paperwhite

It feels strange to recommend this one, since I am always talking about how I just use the Kindle app on my iPad or phone now, but I just recently realized why the Paperwhite is so awesome after I got my wife one.

feature goesbeyondabook. V357570964 1 Software Developer Gifts  (And Other Tech Geek Gifts)

A few big reasons:

  • Battery life.  Yes, I can read on my phone or iPad, but when travelling it is a pain to charge those devices over and over each and every day.  The Kindle lasts a really, really long time compared to a phone or tablet.  If you travel, and bring a Kindle, it is pretty likely that you’ll never need to charge it the whole trip—this is nice.
  • Weight.  This thing is light.  This matters when you read quite a bit, especially in bed.  My iPad Mini is pretty light, but the Kindle is still much lighter.
  • Sleep.  I recently discovered that looking at my iPad before going to bed, (which is what I do since I am reading,) actually disturbs my sleep.  Without getting into all the technical details, it basically causes you to produce less Melatonin.  Melatonin is essential to getting good sleep.  Anyway, the Kindle doesn’t have that same sleep stopping light as a brightly lit screen.

I’m actually wanting to get one of these for myself now after seeing my wife using hers.

Anything I left out?

Whew, didn’t mean for this post to be that long.  I could probably keep going, but I’ll stop here.  Anything major I left out that you’d recommend?  Let me know.

Oh, and it goes without saying, but I’ll say it anyway, if you click on the links in this post and buy something, something will go in my Christmas stocking—which of course I appreciate, because that helps me keep writing this blog and producing the content I produce.

Seiki SE39UY04 39-Inch 4K Ultra HD Review (3840 x 2160)

Update: Apparently the monitor is now $400 on Amazon! Holy crap that is a hell of a deal!

A couple of weeks ago I tweeted about how I bought a 3840 x 2160 resolution monitor for $700 $400 and I promised that I would provide a review for it, so here it is.

If you know me, you know that I am a huge fan of having as many pixels as possible. I actually replaced my four 1900 x 1200 monitors with this single Seiki 4K display—and, although I hate to ruin the surprise—I couldn’t be happier.

It is a huge relief to go from a bulky four monitor setup to a single monitor that has almost the same resolution as all four of those monitors combined, and actually makes me more productive. (I’ll explain why this is the case a little later on.)

110613 1317 SeikiSE39UY1 Seiki SE39UY04 39 Inch 4K Ultra HD Review (3840 x 2160)

The stats please

Before I get into my actual experience with the Seiki 4K display, let me start off by giving you the technical details of what we are dealing with here. This is no ordinary monitor.

The Seiki SE39UY04 is actually called an LED TV, but you and I both know that this thing is really meant to be a monitor.

It actually comes in 3 sizes.

  • 39 Inch
  • 50 Inch
  • 65 Inch (looks like this one isn’t available yet.)

I opted for the 39 inch for both economic and space reasons, but I’d imagine the 50″ or 65″ would be nice as well—if you have the budget.

So, the big thing about this monitor is the resolution, which is 3840 x 2160 pixels. This means that is it basically the same resolution as four 1080p displays.

110613 1317 SeikiSE39UY2 Seiki SE39UY04 39 Inch 4K Ultra HD Review (3840 x 2160)

You can imagine this monitor as equivalent to having a 2 by 2 grid of 1080p resolution monitors.

It also comes with built in speakers which aren’t all that bad, 3 HDMI in ports, a component input and a VGA input – although I can’t imagine why you’d hook up a VGA input to this monitor.

110613 1317 SeikiSE39UY3 Seiki SE39UY04 39 Inch 4K Ultra HD Review (3840 x 2160)

This monitor indeed seemed too good to be true, giving me 8 million pixels at $700 $400, but it is indeed the real deal.

Well, with one catch.

The monitor has a 120hz refresh rate, but only when hooked up to a 1080 source. If you hook it up to a 4k, or Ultra HD source (same thing, just means 3840 x 2160 resolution,) it only runs at 30hz.

This is mainly due to the limitation of HDMI 1.2 to deliver the bandwidth needed to push 8 million pixels down a wire that fast.

What this practically means for you is that you will see some slight ghosting if you have images moving fairly rapidly across the screen. So, if you are planning on playing 3D games with the monitor, you’ll probably feel the difference between 120hz and 30hz, but if you are using it to run an IDE, open 2 chrome browsers and create a blog post all at the same time, you probably won’t feel a thing.

If you want to see exactly what the difference between different refresh rates is and how they are affected by motion, check out this site that lets you simulate different scenarios.

My experience with the SE39UY04

So, you are probably wondering what I thought of the monitor overall.

I’m very impressed with it so far. So much so that I am considering getting another one and having dual 4k displays for my desktop machine. (Ok, that might be a bit crazy, but hey I never claimed to be sane.)

In all seriousness, this monitor delivers exactly what I wanted and more for the $700 $400 price tag. Equivalent monitors easily go for $3k or more and are still saddled with some of the same restrictions of HDMI 1.2 that this monitor is, (although some of them get around it by utilizing two inputs, which in my opinion isn’t really a good solution.) With HDMI 2.0 coming out and through the use of display port, I imagine this kind of problem won’t be a problem in the future as well. But, for now, for $700 $400, you can’t really get a better deal on a monitor, in my opinion.

I found the monitor to be super bright, but the color reproduction and contrast was not quite as good as some of the high-end 1080p displays that I had seen and used before.

Regardless though, it is pretty amazing to see a 4k monitor in action. I tested out some 4k videos on YouTube and Vimeo and I was blown away. Remember the first time you saw an HD TV? Seeing a 4k TV for the first time is about the same experience, but even better. Now HD looks like crap to me. I am ruined.

I also found that running my PC at the max resolution of 3840 x 2160 didn’t make the text too small. It seemed to be just about the right size where I could still read everything and make use of the extra space. Although, I will admit that I think the extra size of the 50″ version would make this experience even better.

One quick tip I’d recommend to get the most out of this monitor is to use a tool like Display Fusion to divide your screen into 4 logical screens. I use Display Fusion to create four 1080 displays out of my monitor so that I can maximize windows in those four quadrants as if I had four 1080 monitors. But, unlike having four actual 1080 resolution monitors, I can choose to maximize a window on two of the four quadrants or even all four if I wish. So, I have the ultimate flexibility with this monitor and no annoying seams between the displays.

Oh, and if you do any kind of video editing, like I do, it is pretty amazing to be able to edit full 1080 video and only have it take up a 4th of your display. You can actually see the full resolution video and the timeline at the same time. I don’t think I’ll ever be able to go back after this experience.

Video cards

One thing you should be aware of when purchasing this monitor, or any 4k monitor, is that you will need to have a video card that will support that resolution.

The general rule is:

  • Any AMD ATI card in the 7000 series or above will support 4k output.
  • Any NVIDIA card in the GTX 600 and GTX 700 series should support 4k output.

If you want an ATI card that isn’t too expensive, start with the HD 7700.

For NVIDIA, check out the GTX 660.

Final thoughts

Overall, for me, buying this monitor was a no brainer. My biggest fear was that there was some kind of mistake and that the resolution really was not 3840 x 2160 or that some graphics card wouldn’t be able to power that kind of a display, but I found that not only were most modern graphics cards able to power the display, but it also was indeed the real deal.

Now, I realize that not everyone has a $700 budget to spend on a monitor. But, did I mention this thing is actually a 4k TV as well? $700 $400 for a 4k display television is not a bad deal at all, especially if you can convince your spouse to let you put it in the living room. I also did the math and found that if I wanted to purchase four 1080 displays, the mounting arm to hold them, and the extra video card to power all 4 monitors, it would cost quite a bit more than the $700 $400 for a single Seiki SE39UY04 and take up quite a bit more space.

So, if you’ve got the cash and you are looking to be drowned in pixels, go for it, you won’t be disappointed unless you are planning on doing some serious heavy duty gaming with it, (even then I thought it looked plenty good enough for my tastes.)

Introducing The Get Up And Code Podcast!

I’m very excited to announce a brand new podcast Iris Classon and I have put together called “Get Up And Code!”

ep1 image thumb Introducing The Get Up And Code Podcast!

I’ve always wanted to do a podcast, but I’ve been looking for the right topic and right co-host and I believe I have finally found both.

Get Up And Code! (Developer Podcast About Fitness And Nutrition)

Podcast website:

iTunes link:!/id646958161logo300x300 Introducing The Get Up And Code Podcast!

Even though I spend a lot of time talking about code and programming, fitness and nutrition are a big part of my life.

I’ve been lifting weights and running for about 18 years.  Over the course of that time, I have learned quite a bit about gaining muscle, losing weight, running and many other topics—mainly from my own mistakes in those areas.john fit Mobile thumb Introducing The Get Up And Code Podcast!

Iris Classon, my co-host, is clinical dietitian and international personal trainer who also does bodybuilding (on the fitness scale), ultra running and extreme sports.  But, if you are reading my blog, you probably know her as that pink haired coder and Telerik evangelist.iris classon fitness Mobile thumb Introducing The Get Up And Code Podcast!

We decided that our shared love for all things code and all things fitness is probably also an overlap that many other programmers and IT professionals have as well.

So, we decided to do something that hasn’t been done before—create a fitness and nutrition podcast targeted at the IT industry.

An experiment

Neither of us hosted a podcast before, although we’ve both been on Hanselminutes and I’ve been on The Tablet Show a couple of times.

This will be a bit of an experiment and things might be a bit rocky at first, but I am sure we’ll find our way.

If you’d like to support us in our efforts, please spread the news, follow @GetUpAndCode on twitter and like our Facebook page!

Time Traveling To The Future Of User Interfaces

I really dislike using a keyboard and a mouse to interact with a computer.

keyboard thumb Time Traveling To The Future Of User Interfaces

Using a mouse is a more universal skill—once you learn to use a mouse, you can use any mouse.  But, keyboards are often very different and it can be frustrating to try and use a different keyboard.

When I switch between my laptop and my desktop keyboard, it is a jarring experience.  I feel like I am learning to type all over again.  (Of course I never really learned to type, but that is besides the point—My three finger typing style seems to work for me.)

laptop thumb Time Traveling To The Future Of User Interfaces

When I switch to a laptop, I also have to contend with using a touchpad instead of a mouse, most of the time.  Sure, you can plug in a mouse, but it isn’t very convenient and you can’t do that everywhere.

I also find that no matter how awesome I get at keyboard shortcuts, I still have to pick up that mouse or use the touchpad.  Switching between the two interfaces makes it seem like computers were designed for 3 armed beings, not humans.

Even when I look at a laptop, it is clear that half of the entire design is dedicated to the keyboard and touchpad—that is a large amount of wasted space.

I’m not going to say touch is the answer

You may think I am going in the direction of suggesting that tablets solve all our problems by giving us a touch interface, but that is not correct.

Touch is pretty awesome.  I use my iPad much more than I ever thought I would.  Not having the burden of the keyboard and mouse or touchpad is great.

But, when I go to do some text entry on my tablet or my phone, things break down quite a bit.

On-screen keyboards are pretty decent, but they end up taking up half of the screen and the lack of tactile feedback makes it difficult to type without looking directly at the keyboard itself.  Some people are able to rely on autocorrect and just let their fingers fly, but somehow that seems dirty and wrong to me, as if I am training bad habits into my fingers.

touch thumb Time Traveling To The Future Of User Interfaces

Touch itself is not a great interface for interacting with computers.  Computer visual surfaces are flat and lack texture, so there is no advantage to using our touch sensation on them.  We also have big fingers compared to screen resolution technology, so precision is also thrown out the window when we relegate ourselves to touch interfaces.

It is completely silly that touch technology actually blocks us from viewing the part of the screen we want to touch.  If we had greaseless pointy transparent digits, perhaps touch would make the most sense.

Why did everything move to touch then?  What is the big thing that touch does for us?

It is pretty simple, the only real value of touch is to eliminate the use of a mouse or touch pad and a keyboard.

Not convinced?

I wasn’t either, till I thought about it a bit more.

But, consider this… If you were given the option of either having a touch interface for your tablet, or keeping the mouse-like interface, but you could control the mouse cursor with your mind, which would you prefer?

And that is exactly why touch is not the future, it is a solution to a specific problem, the mouse.

The real future

The good news is there are many entrepreneurs and inventors that agree with me and they are currently building new and better ways for us to interact with computers.

Eye control

This technology has some great potential.  As the camera technology in hardware devices improve along with their processing power, the possibility of tracking eye movement to essentially replace a mouse is becoming more and more real.

There are two companies that I know are pioneering this technology and they have some pretty impressive demos.

TheEyeTribe as an “EyeDock” that allows for controlling a tablet with just your eyes.

2013 03 03 13 31 09 thumb Time Traveling To The Future Of User Interfaces

They have a pretty impressive Windows 8 tablet demo which shows some precise cursor control using just your eyes.

Tobii is another company that is developing some pretty cool eye tracking technology.  They seem to be more focused on the disability market right now, but you can actually buy one of their devices on Amazon.

The video demo for PCEye freaks me the hell out though.  I don’t recommend watching it before bed.

But Tobii also has a consumer device that appears to be coming out pretty soon, the Tobii REX.

tobii rex le picture montage backfront619x220 thumb Time Traveling To The Future Of User Interfaces

Subvocal recognition (SVR)

This technology is based on detecting the internal speech that you are generating in your mind right now as you are reading these words.

The basic idea is that when you subvocalize, you actually send electrical signals that can be picked up and interpreted.  Using speech recognition, this would allow a person to control a computer just by thinking the words.  This would be a great way to do text entry to replace a keyboard, on screen or off, when this technology improves.

NASA has been working on technology related to this idea.

And a company called ambient has a product called Audeo that is already in production.  (The demo is a bit rough though.) You can actually buy the basic kit for $2000.

technology promo thumb Time Traveling To The Future Of User Interfaces

Gesture control

You’ve probably already heard of the Kinect, unless you are living under a rock.  And while that technology is pretty amazing, it isn’t exactly the best tool for controlling a PC.

But, there are several other new technologies based off gesture control that seem promising.

There are two basic ways of doing gesture control.  One is using cameras to figure out exactly where a person is and track their movements.  The other is to use accelerometers to detect when a user is moving a device, (an example would be the Wii remote for Nintendo’s Wii.)

2013 03 03 13 34 37 thumb Time Traveling To The Future Of User InterfacesA company called Leap, is very close to releasing a consumer targeted product called Leap Motion that they are pricing at only $79.  They already have plans to sell this in Best Buy stores and it looks very promising.

Another awesome technology that I already pre-ordered, because I always wanted an excuse to wear bracers, is the MYO, a gesture controlled armband that works by a combination of accelerometers and sensing electrical impulses in your arm.

two rings thumb Time Traveling To The Future Of User Interfaces

What is cool about the MYO is that you don’t have to be right in front of the PC and it can detect gestures like a finger snap.  Plus, like I said, it is a pretty sweet looking arm band—Conan meets Bladerunner!

Obviously video based gesture controls won’t work well for mobile devices, but wearable devices like the MYO that use accelerometers and electrical impulse could be used anywhere.  You could control your phone, while it is in your pocket.

Augmented reality and heads up displays

One burden of modern computing that I haven’t mentioned so far is the need to carry around a physical display.

A user interface is a two-way street, the computer communicates to the user and the user communicates to the computer.

2013 03 03 13 36 29 thumb Time Traveling To The Future Of User InterfacesSteve Mann developed a technology called EyeTap all the way back in 1981.  The EyeTap was basically a wearable computer that projected a computer generated image on top of what you were viewing onto your eye.

Lately, Google Glass has been getting all the attention in this area, as Google is pretty close to releasing their augmented reality eyewear that will let a user record video, see augmented reality, and access the internet, using voice commands.

Another company, you may not have heard of is Vuzix, and they have a product that is pretty close to release as well, Smart Glasses M100.

Brain-computer Interface (BCI)

Why not skip everything else and go directly to the brain?header set thumb Time Traveling To The Future Of User Interfaces

There are a few companies that are putting together technology to do just that.

I actually bought a device called the MindWave from NeuroSky, and while it is pretty impressive, it is still more of a toy than a serious way to control a computer.  It basically is able to detect different brain wave patterns.  It can detect concentration or relaxation.  You can imagine, this doesn’t give you a huge amount of control, but it is still pretty fascinating.

I haven’t tried the EPOC neuroheadset yet, but it has even more promise.  It has 14 sensors, which is a bit more intrusive, but it supposedly can detect your thoughts regarding 12 different movement directions, emotions, facial expressions, and head rotation.

So where are we headed?

It is hard to say exactly what technology will win out in the end.

I think we are likely to see aspects of all these technologies eventually combined, to the point where they are so ubiquitous with computer interaction that we forget they even exist.

I can easily imagine a future where we don’t need screens, because we have glasses or implants that directly project images on our retinas or directly interface with the imaging system in our brains.

I easily see us controlling computers by speech, thought, eye movement and gesture seamlessly as we transition from different devices and environments.

There is no reason why eye tracking technology couldn’t detect where our focus is and we could interact with the object of our focus by thinking, saying a command or making a gesture.

What I am sure of though is that the tablet and phone technology of today and the use of touch interfaces is not the future.  It is a great transition step to get us away from the millstone around our necks that is the keyboard and mouse, but it is far from the optimal solution.  Exciting times are ahead indeed.

If you like this post don’t forget to Follow @jsonmez or subscribe to my RSS feed.

The Most Complex Program of All Time

What if I told you that there is a program so complicated that is the source responsible for all other programs ever created?

Give me your most complex program and I will trump it by presenting you with the program that was responsible for creating the human who created that program.

If you haven’t figured it out by now that program is human DNA and that masterful programmer is the Creator Himself.

dna 500 thumb The Most Complex Program of All Time

Doesn’t matter what religion you are

It is pretty difficult to fail to recognize that a program as complex as a human being’s genetic code was created, not randomly assimilated.

As programmers we have a unique perspective in life.  We are able to truly understand God’s masterwork in the creation of human life.  We are able to grasp loosely the ungraspable magnificence of a program so complicated, yet executed so simply.

We also have the unique position of fundamentally understanding that complex programs could never be created by random chance, regardless of time.  We can look at a piece of code or functioning computer program and we can understand that its creation required an intelligent creator.  Other people and professionals do not have this insight that so many of us are fortunate to have.

Qualities of the code

We’ve been treating data like code recently in C# with the introduction of Lambda expressions and other languages have been doing it for much longer, but the ultimate example of this practice is right there in our own DNA.

DNA is data, a message, and code all together at once.  Just like a data structure in the memory of a computer executing a program, it lacks meaning without the context of the cell that it is in.  Amazingly though, this data is recombined in different ways that are dictated by two separate and different instances of itself to produce a third separate instance of itself that still makes sense.

Just to give you an idea of how insanely complex that idea is (despite the simple execution of it), it would be like if you wrote a webserver that could spawn new instances of itself by contacting another, but different copy of your webserver and getting 1/2 the source code payload from itself and the contacted server, then actually combining that code to create a new copy that is different, yet still passes all of your unit and integration tests.

One of the qualities we often look at for our code is the size of the code in relation to what it can accomplish.

A decent estimate is that the human genome is about .35 gigabytes of data.  That data is stored on such a small space that we can’t even see it with the naked eye.  There is no more compact form of data in the universe that we know of.

Not only is this data compact, but consider how much functionality is built into this small .35 gigabyte package?  If you had to write acceptance tests for the human body, you might spend several lifetimes doing it.  If you had to write acceptance tests for just a single cell in your body, that feat itself could take years and still not be complete.  Imagine trying to write a program that took up .35 gigabytes of data, yet contained millions of acceptance tests worth of functionality.

We certainly could go on and on about the qualities of the human code, but I want to point out what perhaps is one of the most unique and amazing… the ability for the code to create its own hardware.

In actuality the code and that hardware are much the same.  DNA replicates by a chemical reaction that causes the entire molecule to unwind and split.  RNA inside a cell is created from specific portions of the DNA in order to create different protein chains which are used to construct little machines that will replicate the DNA and cells and in turn create machines capable of doing the same.

The process is very complex and not wholly understood, but in effect the end result is that DNA contains the instructions inside of a cell to create the machinery to host another copy of itself and execute that code.

Easter eggs

Let’s not forget the little Easter eggs that have been thrown in by the designer of our codebase.

How about a hiccup or a tear?

Sadness or laughter?

There are some “evolutionary theories” as to why these things exist, but in reality they serve no specific purpose for either our survival or well being.

In my mind these are clearly Easter eggs left by the designer to show His handiwork.

Why am I writing this post now?

I didn’t want to go completely off subject and boast about my wonderful daughter that was born on April 17th 2011 at 2:33 PM, since this is a professional blog. 

0417sophiasonmez favs 16 thumb The Most Complex Program of All Time

But, there you have it.

The amazing birth of my first child reminded my of the incredibly complex code that keeps us all breathing, procreating and living life that we seem to take for granted each and every day.

Welcome to the world Sophia Grace!

As always, you can subscribe to this RSS feed to follow my posts on Making the Complex Simple.  Feel free to check out where I post about the topic of writing elegant code about once a week.  Also, you can follow me on twitter here.

Published My First Course on Pluralsight

My number of blog posts in the last couple of months has definitely been a little lower than I like, but I have a pretty good reason.

I just got my first course published on Pluralsight!

logomedium thumb Published My First Course on Pluralsight

The course is called Android Development for .NET Developers and it covers most of the basic knowledge you would need to go from knowing nothing about Android development to being able to create a fairly simple application and publish that application to the Android Market.

If you haven’t checked out Pluralsight, it is a really good site for a wide variety of developer training videos.  They really managed to get some very good content on the site and there are videos on just about every .NET topic you can think of.

I have also really enjoyed working with the guys that run Pluralsight, they are all very friendly and very knowledgeable.  Thanks to David Starr and Fritz Onion for all their help getting my course ready and published.

You never really learn something till you teach it

teacher point thumb Published My First Course on Pluralsight

This simple truth became more apparent to me than ever during the process of making this course.

I thought I had a pretty good understanding of the Android fundamentals, having published a fairly complex application, PaceMaker.

What I became quickly aware of is that there is a huge difference between having knowledge and having understanding.

I equate knowledge as possessing a formula to be able to do something, but lacking knowing why or how to make modifications to the process.

Cooking provides an excellent example of this.  There are many people in the world who know how to cook a large number of dishes.  But many of these people only have the knowledge of cooking.  They have a large collection of recipes which they can follow to produce the desired result.

A professional chef on the other hand, has a true understanding of cooking.  This person might have knowledge of many recipes, but they also understand why the particular ingredients are used and can make modifications to those ingredients and steps.  They may even create something without preset steps because they understand what they are doing, not just have knowledge about it.

It was great to have the experience of creating these videos because I was able to acquire an in-depth understanding of Android development, not just a knowledge of what to do.

If you ever have the opportunity to teach, I definitely recommend you take that opportunity.  Even if you don’t think you are qualified to teach a subject, by the time you have prepared what you are going to teach, you will be qualified.  Trial by fire perhaps, but well worth the outcome.  Plus you’ll be helping others in the process.

Much harder than I thought

I do have to admit though, recording training videos is definitely much harder than I had originally anticipated.

In order to get 40 minutes of video, it might take 6 hours worth of work or even more depending on the prep work involved and how much editing after getting the raw footage.

I really expected that it would take about as much time as it takes to record something to produce that something, but I definitely learned that is not the case.

I often found that I had to draw a line and stop trying to refine a video because you can literally spend an unlimited amount of time editing and tweaking a video.

Another revelation that might be apparent to everyone else, but was quite an epiphany to me was that you can edit “umms” out of video very easily.  You can’t even notice where they are cut out!  My first video, I didn’t even realize I could edit anything, and I ended up taking like 50 cuts until I could get it right.

Overall though, great experience, lots of fun

I felt like I’ve been stretched in a different direction, as I had never done any video or audio recording before and had never really spent much time in a room talking to myself pretending to talk to other people, but it was a good kind of stretching.

I really actually enjoyed the process and I will definitely be doing more of this kind of work in the future.  Probably going to take a bit of a break before I start my next course though.  I want to make sure I take some time to get a good retrospective of the process and sharpen my saw a bit so my next videos can be even better.

As always, you can subscribe to this RSS feed to follow my posts on Making the Complex Simple.  Feel free to check out where I post about the topic of writing elegant code about once a week.  Also, you can follow me on twitter here.

Objective-C Here I Come!

Have I blabbed enough about the PaceMaker app I released for Android yet?

First month of sales are over, and it was much better than I had expected.  About 75 purchases in the first 30 days.  Not a huge amount, but that is almost with no advertising, most people who found the app found it in the market.

So what is the next step for PaceMaker?

Well, with the iPhone coming to Verizon this month, I think it is pretty obvious that it is time for the iPhone version.

Only problem is…

I know nothing about iPhone development!

Well I didn’t last week, but I am slowly learning.

iphone thumb Objective C Here I Come!

I bought my first Mac ever last week, a MacBook Air.

I have to say, the operating system on Macs has come a long way since I last used one.  (Did I mention I also don’t even know how to properly run a Mac?  But I know Unix, so I should be ok.)

I feel like the Mac interface is so much more polished and uniform than Windows, but it is pretty scary inside when you consider all the low level C and Objective C code.

Then again you have to consider that the wonderful .NET CLR is written right on top of a really crusty win32 API layer which is a bunch of scary C code that is about 20 years old.

So I am setting out on a brave new quest to learn Mac, iPhone and Objective-C and somehow port my application over to the platform.

Objective-C is kind of like an alternate universe

I was trying to think how I would describe Objective-C and here is what I came up with:

Objective-C is like one of those movies where there is an alternate universe where the same people exist as in this universe, but in some areas their technology is really advanced, but in others it’s really ancient.  Like a bunch of people flying around in flying cars, but their weapons are still bows and arrows.

I used to be a C++ programmer, so not too many things scare me, but some of the magical constructs in Objective-C are very frightening indeed.

I was just reading about a strange construct today that allow you to basically create the equivalent of a C# interface, but in Objective-C it is called a “Protocol.”  This seems fine and normal until I read the paragraph that says you can define some of the methods as “Optional.”  What?

Let me put it in C# terms so you can understand it.  In C# it would look like this:

public interface ILovePuppies
   private void HugThem();
   private void SqueezeThem();

   perhaps Corpse KillThem(); // Implement this one
                              //only if you feel like it.


This is not a joke.  I still can’t quite figure out what this is for, but it is kind of interesting.

Another thing I found interesting is Objective-C has this thing called a “Selector.”  It is not a function pointer, it is a variable that references the name of a method.

How is this different than a function pointer?

It is actually the name of the method being referenced.  So if you have a class Dog that has a method “Wag” and you have a class WildGuesser who has a method “Wag”, passing them the “Wag” selector will cause very different results.  How bizarre.

It’s weird to get sucked into the Mac world

It’s actually kind of funny.  Here were all us Java and C# programmers off basically doing the same thing; creating our interfaces and arguing about dependency injection and mocking our unit tests and these Mac geeks with their bow ties and designer jeans were going a totally different direction.

It was only by random chance that our two parallel universes should violently collide.  The iPhone came out and suddenly all these strange “Mac boys” were teaching us this new old language and reminding us to free up own memory again.


But, I have to admit it is actually kind of fun.

Sometimes a change of pace is refreshing

I don’t mean my harsh language to be derogatory towards you Mac heads out there.  You know you are cool, your boy Steve is leading this century’s computing revolution.

I honestly mean that.  Good job guys, you may just take over the world.

I’m actually enjoying this experience and beginning to think that if I come out alive, I will have gained some very valuable insights into programming in C# and Java.  It is good sometimes to view something from a totally completely different perspective.

Who knows maybe I’ll get to write that Objective-C vs Java vs C# post I’ve been dreaming of.

But what about…


Meh.  If I am going to program for a platform, I am going to program for that platform.  I’m not going to half learn how to program for the iPhone and learn on the C# crutch.  I didn’t do that for Android and I’m not going to do it for iPhone either.


Because I am stubborn and cranky?  Partially, but I actually have a few sensible reasons also:

  1. MonoDroid and MonoTouch both implement another layer over the phone’s framework.  Adding this additional layer makes it harder to do low level stuff, and with something as low level as a phone, doing low level stuff is often important.
  2. You are still using the underlying framework for either Android or iPhone.  It is not like using C# code behind the scenes allows you to write a Silverlight UI that you can use on any of the mobile platforms.  You still have to learn the entire phone development framework, which dovetails into point three…
  3. It is much easier to get help and find resources for raw Android or iPhone development than for MonoX development.  Not trying to bash the Mono projects here, but most of mobile programming is spent googling for how to do things.  By sticking with C# you are really limiting yourself in terms of finding answers.
  4. Change and learning different things is good.  I’m not sure you can fully appreciate the design of a framework or platform unless you develop against it the way it was designed.  I could be wrong, but I think there is a potential “lost in translation” problem in using C# on the iPhone or Android platforms.

After I learn iPhone development, I might try MonoTouch and see if it makes my life easier, but I need a good baseline first.

Well, I’m off on my journey.  Going to head on to the back of the wardrobe in the “Spare-Oom.”  I have to meet Mr. Tumnus, we are having tea with Mr. Wozniak and Mr. Jobs.

mrtumnus thumb Objective C Here I Come!

As always, you can subscribe to this RSS feed to follow my posts on Making the Complex Simple.  Feel free to check out where I post about the topic of writing elegant code about once a week.  Also, you can follow me on twitter here.

Using Var + As, a Neat Little Trick

Perhaps this is something everyone already knew about, but I recently came across this little C# combo that solves one of my major outstanding issues with the var keyword.

I consider var to actually be quite a useful language feature to reduce repetition and make your code slightly more flexible for refactoring, but I’ve always had one little problem with it.

What if I want a base class type or interface?

I most often run into this problem when I am working with lists.

Have you ever written some code like this?

var myList = new List&lt;int&gt;();


The problem with this code is that we are stuck with the concrete List implementation for our variable myList, because we don’t have a way of specifying that we actually want an IEnumerable to be our reference type.

The solution is so simple that I am a bit surprised I didn’t think of it earlier.

I had always assumed that I just couldn’t use var there and would have to declare the type like so:

IEnumerable&lt;int&gt; myList = new List&lt;int&gt;();


But we can actually just use as to keep our var in place if we want to.

var myList = new List&lt;int&gt; as IEnumerable&lt;int&gt;


So it’s actually a little more verbose, but I think it is a bit more clear, and it is more consistent if you are using var everywhere else.

There has to be a better use

I’ve been racking my brain trying to come up with more useful ways to use this little combo, but I can’t really seem to come up with anything.

It seems like there has to be something else you could use this combo for.

What do you think?  Any ideas?

A Simple Wrapper To Make Things More Fluent

This post is really a continuation from my last post on using a method that takes an Action to address cross cutting concerns, like logging, without having to go to a full blown AOP implementation.

Someone mentioned in the comments that it wasn’t very clear exactly what was going on with the final code.  I tend to agree that this:


… is not very clear.

Really, there are two problems with this code that I can see.

  1. It is not clear what this is going to do or whether or not LogOnError or Cook is the method we are concerned about.
  2. It’s not very self-discoverable at all.  If we had a library of useful wrapper methods like these, we wouldn’t have a good intellisense way to know what they are.

I can solve both of those issues, but doing so starts to move us into a weird zone where I am not quite sure I feel comfortable.  But, nevertheless, in the name of science…

wrapped thumb A Simple Wrapper To Make Things More Fluent

Let’s start backwards

Liking fluent interfaces, here is the kind of syntax that I would prefer to be able to use:


It is a little bit longer syntax, but I like it for a few reasons:

  1. It clearly indicates what is going on here.  We are wrapping a method call using a wrapper.  We are wrapping with a method called LogOnError.
  2. You get intellisense all the way.  The correct implementation of this, should let me Type With + ‘.’ and then see a list of all the possible wrapping methods I have implemented.  This makes the wrapping set of methods self-discoverable.

I really like the idea of being able to easily change the functionality of the wrapping just by changing the last part of the line.  For example, if we had implemented a wrapping method that was LogAndAbortOnError(), we could change our code to use that pretty easily.


If we implement this correctly, intellisense will give us our options.

Making it so

Creating a fluent syntax in C# can often involve quite a bit of magic and voodoo.  I always like to gather my reagents before embarking on such a journey.

So grab a live chicken, a stapler, and a sharp knife and let’s go!

First step, let’s simplify this.  The With is nice, but it is just for flow, we don’t really need it.  So let’s figure out how to implement our syntax without the With and add it in afterwards.


First the easy way.

  1. Create a static Wrapper class with a Wrap method that takes an Action and returns an Action.  (We’ll use this to convert whatever we pass in to an Action, so that we can use a Lambda expression or any method call there.)
  2. Create a static extension method that operates on an Action.  Call it LogOnError.
public static class Wrapper
    public static Action Wrap(Action action)
        return action;

    public static void LogOnError(this Action action)
        catch (Exception exception)
            // Log the exception here


Not too bad.  Not a large amount of magic going on here.  Just using an extension method.

But, we already have a problem.  Using a plain old Action is going to give us too many choices in the intellisense drop down.  It could make it hard to know what our real options are and when we try and add the With syntax later we will need to use a property off of an object we return from the Wrap method.

Making it better

We can fix this by actually wrapping the Action with a custom type that we can add our methods to.

Instead of Wrap returning an Action, it will return a WrappedAction.

public static class Wrapper
    public static WrappedAction Wrap(Action action)
        return new WrappedAction() {Action = action};

    public static void LogOnError(this WrappedAction wrappedAction)
        catch (Exception exception)
            // Log the exception here

    public class WrappedAction
        public Action Action { get; set; }

Looking better.  Now when we put a ‘.’ at the end of our Wrap call we only see LogOnError as an option.

We can be sure now that if we create an extension method for a WrappedAction, we will make sure that method is self-discoverable.  Before, the generic Action extension method could make our method show up places that we don’t want it to and can get lost in the other methods on Action.

Making it done

The last thing we need to do is add the With.

Ideally, when we hit the ‘.’ on the end of the Wrap method, we want to see With as an option.  When we hit the ‘.’ on the end of the With property, we want to see LogOnError as an option.

In order to accomplish this we need to:

  1. Add a With property to the WrappedAction.
  2. Have the With property be of a new type (WrappedActionTarget) so that we can add our extension methods for that new type.
  3. Change the extension method to operate on the new type.

Here is what we end up with:

public static class Wrapper
    public static WrappedAction Wrap(Action action)
        return new WrappedAction() { Action = action };

    public static void LogOnError(this WrapperMethodTarget target)
        catch (Exception)
            Console.Write(&quot;Logging this error&quot;);

public class WrapperMethodTarget
    public WrappedAction WrappedAction { get; set; }

public class WrappedAction
    public Action Action { get; set; }

    public WrapperMethodTarget With
            return new WrapperMethodTarget() { WrappedAction = this };


Now we can use the syntax of:


We can move that LogOnError method out to another class, or create new extension methods somewhere else.  I just put it in there to avoid creating another class.

Is this really practical?

I don’t know.  To be honest, I was playing around with creating extension methods that work on Actions and I came up with this way to use them.

I could see making a wrapping library that had different kinds of ways you would wrap method calls built into it.  It could allow you to specify how you log in a configuration and then you would get all of this common stuff automatically.

Even if it is not practical, it’s pretty fun, and it demonstrates the power of Action, or rather functional programming in general.