Quantcast
Channel: Hacker News 50
Viewing all articles
Browse latest Browse all 9433

Article 37

$
0
0

Comments:""

URL:http://nuuton.com/blog/why_i_chose_go.html


Why I chose Go for Nuuton.

Building a search engine is no easy task. There are many problems that one has to attack. It is quite the challenge. Search engines attract the attention of hackers everywhere. Due to their complexity, and sheer difficulty. It is no wonder that Google aims to hire the best of the best. It is a tough problem to solve. One that needs its own programming language.

Google started developing Go for one simple reason: to simplify the act of writing search systems. They provide a very good explanation. But the truth is that they were mixing a bunch of different languages and getting mixed results. I went through the same ordeal. Nuuton was originally a pure Python system. I wanted it to be pure Python because I love Python. That is until I had to work with threads. After spending some time working with gevent, I decided to simply use another language to deal with that.

Lisp was the second language I chose. It has good support for concurrency, is compiled, and allows me to write my own domain specific languages (DSL). It had also been my sweetheart for a log time. For me, writing Lisp was like writing in God's own language. Yes, it was both a technical and personal decision. We are, after all, human. Yet, after a while, my love of Lisp started to go away. Things got complicated quickly. I was writing too much code to achieve simple things. Plus I was writing a lot of one-off code. I prefer to write as much reusable code a I can. Mostly because I'm lazy and I like to keep things simple.

So the mix of Lisp and Python was somehow working for me. The back end was working as its own system. Which the front end talked to through an API. Let me explain that a bit. The way Nuuton was setup is simple: The back end took care of all of the data (gathering, sorting, rating, processing, etc). The front end simply used an MVC (or MVT in Django) structure to serve the data and allow the user to interact with it (Nuuton allows the user to interact with the back end). It was a simple MVC application getting data served through an API. Why not a Javascript MVC framework? I'm not fond of the language.

Then one day I was browsing Hacker News, where a post about Go praised it. I was convinced that this was just a Googler sucking up to somebody. But for some reason, I decided to take the tour at the golang.org website. After spending twenty minutes playing around with Go, I realized that I was actually having fun. I was taken back 13 years, when I started learning Python. As a result, I decided to build something with Go. After some research, I found the Gorrila Web Toolkit. Two hours later, I had a working blog. Then I wrote an API. After that I asked myself:

Why don't I build Nuuton with Go?

I know. It seems strange to simply abandon a code base and re-start from scratch. Yet, the old code base was messy. Too complicated. I was, in a way, in the same place as Google. I had an overly complicated search system that needed to be simpler, faster and more reliable. As I started re-thinking my whole architecture, Go made more and more sense. The backend and front end joined in. No longer did I have an API serving an MVC app. I now had a search system with a front facing interface. I'm still using internal APIs to move around data in some places, though. But it is no longer a system divided in two.

There are some drawbacks to using Go. One being that it is a new language. I have to write a lot of the code myself. Can't simply do an import this as in Python. But on the other hand, there is not a lot of code to write. The amount of code written is less than half of the original. Which is mind-blowing, considering how I put a lot of effort into keeping it concise. Another drawback is that Go is undergoing heavy development. I'm not sure what it has in store for the future. Hopefully, it won't break too much of my code. I do have to say that the way Google is handling the releases has been very good for me.

I chose Go because it is being developed to solve the same problems I have to solve. All by a group of scientists an programmers that are each twice as smart as I have ever been (on my best day). It was simply a natural move. One that I hope will allow me to give Google, Blekko, DDG, and Bing some fun competition. To end, I will include a quote found on the web (through Nuuton, of course):

"Go is not meant to innovate programming theory. It's meant to innovate programming practice." -- Samuel Tesla

Go back to the main blog page.


Viewing all articles
Browse latest Browse all 9433

Trending Articles