Why You Should Learn Go

I’m pretty excited about Go, the new programming language from Google. It’s been my obsession over the last few weeks, and I think if you’re a programmer, you should learn it.

Why did I start? Out of respect for its creators, Rob Pike and Ken Thompson. They helped create and popularize Unix, C, UTF-8, Plan 9, and many other things. It may seem like they’ve been under the radar lately in their research wing at Google, but I think they’ve just been building up a foundation of code and ideas.

Why is it exciting? It seems to have solutions for concurrency, compilation speed, and safety, while still looking somewhat familiar. You can run hundreds of thousands of concurrent goroutines. The entire Go library compiles in ~5 seconds. Go code runs almost as fast as C, without even being optimized yet. It’s type-safe without being too verbose.

It’s not as high level as Ruby or Python, but it can be more mentally satisfying in an OCD geek kind of way. It’s C without the pain.

Sure, it took ideas from Alef, Limbo, Newsqueak, and other languages (watch this then this for proof, and for enlightenment) – but how else can you make progress? Go has the momentum those languages never got.

And I, for one, am glad that the legacy of Bell Labs lives on.

Continue Reading »

10 Ways to Get Inspiration as a Programmer

Sometimes I fall into the trap of reading about programming and not programming. I can’t always find an interesting project to work on, even though I know there are a sea of opportunities. If you have the same issue, here are some tips that might help.

  1. Hang out with other programmers. This is the best source of inspiration because, naturally, they’ll have ideas that you won’t. It doesn’t matter if it’s just some coder friends, a programming group, or even a conference. The mixing of all those ideas is sure to give you a fresh perspective.
  2. Hang out with non-programmers, too. First of all, it’s healthy to be around people that make you happy or challenge your thinking, whether or not they code. Second, they can give you inspiration from a user’s perspective. What frustrates them about their computer? Can you come up with a solution?
  3. Have a dedicated workspace. If it’s not possible to have a dedicated space, at least make sure it’s quiet and you can focus on the computer. Make it your cave. Make sure your chair is comfortable and supports your back. Make sure you don’t have to get up too often – have a drink handy. The more incentive you have to stay at the computer, the more likely you’ll be to stay and be productive.
  4. Have a good development environment. The software version of the previous tip. I don’t care which editor you use (though I recommend vim) but make sure you’re using one that gives you some power and flexibility. Always use source control – in particular, I recommend you learn git because of the concepts it will teach you. Always back up your work. All of this will prevent the massive demotivation you will experience if you don’t use them and you lose your work.
  5. Keep your ears open. Read the twitter feeds and blogs of the programmers you respect. (Look at my twitter feed if you want – it’s mostly programmers.) RSS aggregators, such as Ruby Inside, or the old-school Planets, can be great sources of news because they add prominent new programmers without you having to search. Pick a few blogs on topics you wouldn’t normally read, and subscribe to them too.

    Yes, this can get you sucked into the trap of reading code and not writing it, but being plugged into the larger coding ecosystem is good for you and can be the source of many ideas.

  6. Read good code. Think of some software you love and look at the source code. What problems did they have? How can you learn from it, or better yet, how can you improve that software? There are many sources of good code, but GitHub has to be one of the best. The GitHub Rebase series on the GitHub blog lists a number of notable new projects if you want some specifics.
  7. Continue Reading »

Backpack Goodies

I’ve added a page for Backpack Goodies, i.e. utilities and scripts I’ve written for Backpack. The first is Hide Backpack Page Warning, a greasemonkey script which does just what it says! When you’re at your page limit, it fades away the annoying yellow warning box.

Span 0.2.1 Release

Today is a great day, for it marks the release of Span 0.2.1. The only visible changes are that terminal resizing is now handled gracefully and automatically, but behind the scenes there was a lot of code cleanup, and a ton of documentation updates. (namely, I documented it.) Not a vital upgrade, but nice to have – especially if you want to look at the code.

Span 0.2.0 Release

I hereby give to the good people of halffull Span 0.2.0! Along with some general fixes, I added full network play. Someone runs as a server with the -s switch (and optionally -C(x) for the number of clients to accept). Then, your friends can join in with any number of players they want – the server manages the remote players seamlessly while you play along. Hell, you could even have an internet AI-battle by just shutting off the human players.

Actually… that’d be great, having people write their own Span AI and having internet tournaments to see who’s the master programmer. I’m getting ahead of myself though – enjoy the game!

Span 0.1.0 Release

I’m proud to release Span 0.1.0 to the general hungry public. I’ve added AI players and a real command-line interface in the past week. In other words, it’s actually playable now! The actual usage should be pretty self-explanatory. Enjoy. You just might like it.

Introducing Span

SpanI’m not a blogger. This isn’t a blog. I write well, I just can’t write. That probably explains how when I try to write, it turns out like this.

I hereby introduce Span! It’s a Connect Four-alike game in ruby/ncurses that I wrote while bored at work. I’m about ready to post the first numbered release, but for now it’s nightly-style. All the basics of gameplay are in, the next step is a command-line interface and some AI.

Enjoy!

The Object Oriented Office (with Duck Typing)

It seems to me that modern offices have a bad model of operation. They usually involve a strict hierarchy of employees with orders given directly down one level. Information filters down when needed, and flows up when requested. Changing the hierarchy itself is a very slow process, and has little to do with the type of information that moves.

Allow me to geek out a moment. Object-oriented programming is a Good Thing because it abstracts out some messy details from other types of languages. Rather than having a function like do-something(with, some, values) you get object-with-state.do-something(another-object). This is important for several reasons:

  1. It’s often easier to think about objects and interaction than processes with specific inputs and outputs. For example, you kick a football. It makes more sense to say you kick it [you.kick(football)] than to say there is a kick occurring, with you and the football being primary participants. [kick(you, football)]

  2. Objects abstract away ugliness. A lot of things in a program can logically be thought of as objects. Say you’re getting information from the web. The site is an object, the receiving computer is an object, (perhaps the stream is an object) and all these objects interact nicely. Each thing knows how to deal with its own information, each thing can exist alone or it can accept input from others. A football object knows to slightly deform and rocket away when it’s kicked. The kicker doesn’t have to know that. If everything had to do every job, it couldn’t be as efficient. Abstraction creates efficiency.

Object-orientation isn’t a one-size-fits-all solution, but it’s often a godsend.

Duck Typing is a concept from Ruby, or at least it was popularized by Ruby. Type systems in general determine how a language deals with different types of objects or values. Static typing systems bind variables to specific data types, whereas dynamic typing allows a variable’s type to change. Duck typing, on the other hand, doesn’t care what type a variable is – if it responds to certain signals of a type, it is that type. If it walks like a duck and quacks like a duck, it is a duck. (thanks Dave)

Where am I going with all this? These models are a perfect fit for an efficient office.

Continue Reading »