Matthew is a freelance technical writer helping businesses win over developers by creating documentation developers need, to really use their platforms to the full. He's also the editor of Master Zend Framework, where you can learn everything there is to know about Zend Framework.
Unless you’ve been living under a rock these last few years, you’ll have heard of Go (sometimes referred to as Golang), a language originating from Google, some years ago.
…an open source programming language that makes it easy to build simple, reliable, and efficient software.
is a statically-typed language with syntax loosely derived from that of C, adding automatic memory management, type safety, some dynamic-typing capabilities, additional built-in types such as variable-length arrays and key-value maps, and a large standard library.
Available for most modern operating systems, including Mac OS X, Linux, BSD and Microsoft Windows, it was conceived and initially created at Google, back in 2007, by Robert Griesemer, Rob Pike, and Ken Thompson. Each of these three developers have quite impressive pedigrees.
Most programming languages, especially one with such a strong C heritage, can be difficult to get started with. Go on the other hand, is quite the opposite. And in today’s tutorial, I’m going to show you how to get started developing with Google Go, right from installation to a running application.
Whether you’re on Mac OS X, Linux and FreeBSD, or Windows, Go is easy to install and configure. I’m assuming in this tutorial that you have a UNIX/Linux operating system. When I first installed Go, being on a Mac, I used the latest package file.
But you can just as easily install, from source, using the following commands:
tar -C /usr/local -xzf go1.2.1.linux-amd64.tar.gz export PATH=$PATH:/usr/local/go/bin
If you’re not familiar, these will extract a copy of the go files, from
/usr/local/goin your filesystem, and add the
bindirectory within it to your profile path.
Alternatively, if you’re on Windows, download and run the MSI Installer.
When the installer’s complete, you’ll find the installed files under
c:\Go; and the installer should have added
PATHenvironment variable. You may want to check, just to be sure though.
Configuring Your Environment
With that done, we have the binaries required to begin. But we need to ensure that our environment’s also ready, which requires one more step and a bit of background.
Go development uses the concept of a workspace, which contains the source files (src), compiled binary files (bin) and packages (pkg).
The source file directory structure, generally, models open source code repositories, such as Github. So a typical source directory could look as follows:
src github.com settermjd sitepoint hello-world.go
You can see that under
src, I’ve linked to my Github repository, called
sitepoint, and in it is one file,
In our second interview, we talk to Tom Oram, who works for a small development firm in Wales and Rob Allen, from Nineteen Feet.
These two developers have a solid wealth of PHP experience and knowledge and have helped me refine my ideas and approaches on many occasions. With that, we’ll start with Tom.
What lead you to PHP?
A job. I was offered a job using a language I knew nothing about called PHP. It was PHP version 3 at the time, so much less advanced than it is now. Since then, I’ve been using PHP almost every day of my working life.
What have been the things about PHP that bit you?
In previous versions I’ve had various things which have caused confusion and frustration, most notably references and object copying in PHP 4.
However in PHP 5 I don’t really have anything that really catches me out. There are, however, things which I think could be improved or added to make the language easier and more consistent to use.
What have been the highlights or redeeming features
I guess the best thing about PHP is the speed in which you can get going. You can have an idea and very quickly try it out while at the same time it’s very well suited to larger and more complex projects as well.
What are the compelling PHP features for you?
For me I love interfaces and the fact that static typing is becoming more and more possible while still allowing dynamic typing.
What do you want to see added to the language?
- Type hinting for scalar parameter types
- Type hinting of return values
- Nested classes
Why PHP over Ruby, Python, Go, etc?
Honestly I think they all have their own pros and cons. In many ways I think the other languages are designed better and are more consistent.
However if you’re used to programming in a statically typed language (especially Java) then PHP might seem easier to relate to than Python or Ruby.
Do you see yourself moving to another language in the future?
I use other languages all the time, and if a job is better suited to another language I will use that. However for web-based projects I always reach for PHP first, I currently have no intention of changing that.
Do you have a custom framework/setup?
I read an old post, circa 2010, on the MailChimp blog a little while ago, about their experience using PHP.
It struck a chord with me, because the sentiments they shared I’ve felt myself, and heard echoed many times over the years. What are these sentiments, you may ask?
They’re the ones which infer that PHP, despite all its successes, really isn’t a true programming language. They’re the ones which intimate that, no matter how good you are, no matter what you’ve achieved, if you’re a PHP programmer, well, you’re really not a true developer, yet.
They’re the ones which suggest, or is that presuppose, that you should really become one of the cool kids developing in Ruby, Python, or Go; basically anything other than PHP. After all, what can you really do with PHP, right?
Unless you’ve been living under a rock, today’s PHP isn’t your grandmother’s PHP; it’s an entirely different, much more elegant and mature language with countless improvements and additions.
I’m not going to go over how to use Composer, as it’s been covered so well here on SitePoint already; especially by this article, by Alexander Cogneau.
Instead, I’m approaching it from a different angle, taking you through the excellent Composer cheat sheet, which I came across recently.
In part one of this series, we considered the problem of how to create and manage development environments in a way which was simple, repeatable, and (even) efficient. It's a problem which I'm confident we've all run in to from time to time. The solution was a relatively new tool called PuPHPet. If you missed […]
Does creating and managing development environments frustrate you, slow you down, or distract you from development? Do you have issues because your development and deployed environments differ? If so, I've got the solution for you – PuPHPet! Introduction I can't speak for you, but one of my pet peeves about software development is environments. Whether […]
Synopsis This post shows the user how to deploy a simple website using no more than a git post-receive hook. It covers just enough background information so that the reader can go further and expand their knowledge as their time permits. One-Click Deploy How often do we say preach the mantra of one click deployment? […]
Wondering why your site users don’t see or use the very obvious button you put there for them to click on? Maybe they’re not actually seeing it. Matthew Setter explains.
You’ve been staring at your code for hours, trying to figure out why it’s broken, when a coworker comes over to help and finds the problem in an instant. Why was the problem so obvious to him but not to you? Let’s discuss the interesting phenomena related to your ability to perceive things: inattention blindness.
Continuing this 3-part series that will give you a hands-on introduction to OXID, we take a look in part 3 at writing a custom module to extend the platform’s core functionality.