Sunday, July 8, 2012

Dumping PHP For Go


It has been a long time coming for me to switch out of PHP for my main programming language.  I have been working with PHP for years and have grown tired of the limitations/issues.  It has been hard for me to convert, being that there are always jobs for PHP programmers out there and I gotta eat! For me, the aggravation coming with working with PHP has forced me to switch.

Why do you hate PHP?

I don't hate PHP at all.  The language itself has many advantages like a great community, numerous libraries (although how many different MVC frameworks can you have?), great documentation, and ease of entry.  There are libraries to connect PHP to virtually every database, REST API, or other third party software.  These are all reasons I began using the language in the first place.

PHP is supported on virtually every web hosting company on the planet, making PHP a useful skill to have.  There are some great open source frameworks and apps like WordPress, Zend, Joomla and too many others to list.

Why no more PHP?  First, I should probably clarify that I will continue to use PHP as many of the projects I'm working on still use PHP.  However, there are many quirks about PHP that have been bothering me.  I won't go into detail because I will not be saying anything new about the subject. If you want to read the most epic of rants on PHP issues, see this post.

PHP code, especially large code repositories, have become difficult for me to enjoy maintaining.  Sometimes your app just stops working because of some typo in your code or the spaghetti code becomes just too unreadable.

PHP just doesn't seem exciting for me anymore.  There doesn't seem to be anything exciting happening.  Yes PHP 5.4 was recently released which has the new Traits feature, but other than that, not much has been happening with the language and nothing interesting as far as apps or frameworks. The only object that piqued my interest was Laravel.

Why not Python/Ruby/Java/Any Other Language?

I like to consider myself open to trying new programming languages.  Even if you don't wind up using a language long term, sometimes your programming skills can still benefit from solving solutions from a different point of view.  Below is a quick overview of my dealings with other languages.  Most were brief enough that they shouldn't be taken too seriously.

Python - I have no problems with Python.  I have completed a couple of projects in Python and find it a joy to work with.
Ruby - My only experience was with Ruby On Rails around version 0.9.3.  At the time, the framework made coding easier but at the expense of performance.  Scaling was terrible at the time.
Node- This seems to be all the rage.  Everybody likes to use the term "Non-Blocking" to make themselves seem cool.  The draw is to be able to code the same language client side and server side and even share that code so you don't have to write validations in two places.  Node is still young but provides ample libraries with a large developer community already.
Java - Too bloated for me and if I use it there is a possibility Oracle might sue me!
C -   I mostly used it in school and haven't had the need to use it since.
C# -  This language seemed well thought out, but I am not into using .NET products and Mono just wasn't a viable solution for me.

There are some languages that I would like to still try (for various different reasons) like Clojure, Scala, Dart, Smalltalk, Erlang, and Haskell.  I will get to them when I can.

Why is Go the Shiznit?

Go makes me a better coder!  I enjoy coding more with Go and was productive very quickly.  The documentation was complete and organized.  The support forums are great and are frequented by the core contributors of the language.  Effective Go is a great way to get started with Go.

I like the multiple return values instead of exceptions which forces you to deal with errors right away.

Some people don't like static typing and strict compilers, I do.  It saves me a lot of debugging time and prevents my program from crashing in a rare use case.  The compiler will tell me if I declared a variable and didn't use it or tried to use an undeclared variable, both signs that I have probably made a typo somewhere. The compiler is very fast!  Large apps can still compile in under half a second.

Since I'm not a sysadmin, I prefer to pay extra to have my code managed by someone.   Besides Google App Engine, people have implemented Go on Heroku and OpenShift.

Although I haven't used it, Go's concurrency model seems straightforward and easy to use.

Interfaces and reflection are awesome.  Takes a little getting used to, but once interfaces click in your head, you'll be hooked.  There is a blog post that sums interfaces/reflection up better than I can at


Go helps me write cleaner and more maintainable code.  Now that Go 1 has been released, the code base has really stabilized, allowing me to feel more confident about using Go in a production environment.  The maintainers of Go say: "People who write Go 1 programs can be confident that those programs will continue to compile and run without change, in many environments, on a time scale of years."

Since there are millions of PHP users and six people who read this blog (Hi Mom!), I doubt that I will cause of a shift of PHP users to use Go, but maybe the next time you have a project that is a fit for Go, you will give it a try!  You can create Google App Engine projects for free to help you get started.


  1. This matches many of my own feelings.

  2. You should post a simple hello world with Go on Heroku.

  3. I have never been a PHP developer but I do Python. I agree with your last header completely, glad I'm not the only one who feels that way.

  4. I'm a PHP developer, but I'm trying to switch too.
    But I'm interested in HTML5 so I'll go for DART

    1. Go is great to use the features of HTML5. My web applications use the native facilities to handle for example json and websockets in an incredibly easy way.

  5. This comment has been removed by the author.

  6. If you like python/ruby please check groovy/grails.

  7. I read this article for the fourth time
    I think I also want to move from the php language to a new language and more efficient
    In this article based on comments
    Dart better for me to online applications because it is server & client side will save time
    But I want to Go with the language of another client side

    1. Glad you took the time to read it once let alone 4 times!

  8. As you immerse yourself with Go. You will find that some of it's virtues besides speed and concurrency are the tool sets. Go's philosophy is aimed at optimizing the efficiency of the end user. There are so many small optimizations to mention; such as "go fmt" which automatically formats indentation of your builds, "go doc" built in documentation, etc,...

    Another major encounter was design. Note, that I come from an Object Oriented language (Ruby). If this is your case; you will find that the idiomatic way to Go programming is a bit different. Go is a procedural language, but it's implementation details are slightly different than one might imagine, almost anything you can achieve using inheritance in another language, you can build in Go! using what gopher's like to call as, "composition."

    There is an awesome article written by Nathan Youngman which I highly recommend every beginner should read. It really put many details into perspective for me. Go Object Oriented Design

  9. I wrote a similar article a few years ago. For me it was PHP to possibly Groovy and Grails. I found that too bloated right along with Java. I also went through Go when it was too young and Python which I loved. I'm now on Go as my language of choice. Easy to write, compiled native code, and probably the least problems I've had with typed languages. Just can't beat it.

  10. The draw is to be able to code the same language client side and server side and even share that code so you don't have to write validations in two places.

    pgp download

  11. What Database do you suggest to use with GO? is MySQL good to go with Go?

    1. There are libraries for all the major databases out there to use with Go. I would recommend using whichever you are most comfortable with. If you like MongoDB, there is a great wrapper for it.

  12. Go is extraordinary to utilize the characteristics of Html5. My web requisitions utilize the local offices to handle for instance json and websockets in a fantastically simple way.

    cool website design // Best Web Design

  13. So.. Are you getting any Go work or is the PHP work still dominating?

  14. Go is a procedural language, but it's implementation details are slightly different than one might imagine, almost anything you can achieve using inheritance in another language, you can build in Go!

    PHP Development Company

  15. Really Nice Information,Thank You Very Much For Sharing.
    Web Designing Company

  16. Web programmer than would be who makes dynamic applications. Web programmer has little bit of designing information but better at making applications.Develop Android App

  17. Delta Decisions Inc. is a premiere web development firm specializing in e-commerce and business websites. We offer services including website design, web hosting, SEO servives, pay-per-click, google adwords, website branding and much more.
    web design Toronto

  18. This comment has been removed by the author.

  19. Those are the important features and will surely bring around more of the certain features which are needed to be occupied herewith. best splash pages

  20. Easily, the post is actually the best on this deserving topic. I fit in with your conclusions and will eagerly look forward to your upcoming updates. Just saying thanks will not just be sufficient, for the extraordinary lucidity in your writing. I will at once grab your rss feed to stay privy of any updates. Delightful work and much success in your business efforts!
    website development company in United States

  21. Thank you for sharing this post about the best techniques for PHP Development, This is very useful for PHP Development and PHP Development CompanyBangalore Web Design Company | Web Development Company Bangalore

  22. The Post was really very useful and thanks for sharing the information about this topic. Website Development Company in Florida

  23. Great site for these post and i am seeing the most of contents have useful for my Carrier.Thanks to such a useful information.Any information are commands like to share him.
    PHP Training in Chennai

  24. Really it was an awesome article...very interesting to read..You have provided an nice article....Thanks for sharing..
    Android Training in Chennai
    Ios Training in Chennai

  25. Hi,

    Thanks for sharing a very interesting article about Dumping PHP For Go. This is very useful information for online blog review readers. Keep it up such a nice posting like this.

    Web Design Company Bangalore