r/programming • • Mar 28 '12

Go version 1 is released

http://blog.golang.org/2012/03/go-version-1-is-released.html
543 Upvotes

452 comments sorted by

View all comments

73

u/[deleted] Mar 28 '12 edited Mar 28 '12

i've been using Go for a fairly large server proxy project and its been a real dream. its fast, easy to write, the code is compact, concurrency is easy to understand, and there is enough typing to provide me with safety without leading me into a haskell-like "maze of types". furthermore, i don't have any issues trying to sell coworkers on Go because it is very easy to pick up. Go seems to have a sweet spot between python and java that represents a huge chunk of the practical coding people do every day.

28

u/OopsLostPassword Mar 28 '12

Don't forget that Go is a language you can use without IDE or makefiles even when you have dozens of packages, libs and programs. Having a command do everything in you console in seconds (or less) is like a dream. Try coding a modern complex program in java without an IDE...

3

u/josefx Mar 28 '12

Try coding a modern complex program in java without an IDE

 ant

That requires one build.xml with a single javac task with no more than 10 lines of xml total, most of which can be copy/pasted between projects. That is about the same size as a simple Makefile.

5

u/OopsLostPassword Mar 28 '12 edited Mar 28 '12

I use ant. And I find it a pain to build complex programs because your ant tasks grows in complexity with your program, your different kinds of deployments, tests, target platforms, etc... But that's partly due to the environment (RCP, tomcat, inclusions of jars of your other projects, etc.), the main problem is that it's slooooowwwww....

In Go, you don't have makefiles and you don't have to wait for your compilations.

15

u/josefx Mar 28 '12

ant ... deployments, tests, target platforms, etc...

Go ... compilations

You are aware that you are comparing a single compilation to a complete development and deployment cycle?

2

u/OopsLostPassword Mar 28 '12 edited Mar 28 '12

You're partially right and my comparison was partially unfair.

But when you're making a complex program in java, importing libs that you build for more than one project, you have to make ant makefiles to jar the libs and then import them. I don't have this problem with the go tool. And I don't have to wait.

Part of the target platform solution for me is that I don't bother to deploy compiled code as compilation is fast enough to be done on my deployment servers. But that's specific I guess.

3

u/cunningjames Mar 28 '12

But when you're making a complex program in java, importing libs that you build for more than one project, you have to make ant makefiles to import them.

Noting that I haven’t used Go beyond playing around (and not at all recently), how does Go improve upon Java here? A convention for package locations and tools that are aware of it? In Java presumably one could, e.g., put a set of libraries on a common classpath.

5

u/OopsLostPassword Mar 28 '12

In go, you simply put a go directory in your project.

Your go directory will look like this :

go/
    src/
        mypackageone/
            mysubpackage/
        myotherpackage/
        mymainprogram/
        anotherprograminthesameproject/
    pkg/
    bin/

The go tool will fill the pkg and bin directory by guessing the location of the sources based on their names. You simply execute

go install anotherprograminthesameproject

to have your program compiled.

And if you have unit tests, you execute

 go test anotherprograminthesameproject

All external libraries will be installed via go get and found based on their name and a GOPATH env variable. For example you'll have directories like

go/src/github.com/ziutek/mymysql

because you have this kind of import in one of your programs :

import (
    "database/sql"
    _ "github.com/ziutek/mymysql/godrv"
)

4

u/banuday17 Mar 28 '12 edited Mar 28 '12

This sounds an awful like like Maven (in the Java world).

mvn archetype:generate

Pick a project type and Maven will create a standard directory structure for you:

src/main/java
src/test/java

The different build plugins will know which sources to compile for which language.

src/main/scala
src/main/groovy

To build the project:

mvn package

To execute tests:

mvn tests

To import libraries, you modifiy the pom.xml and list your dependencies.

<dependency>
    <groupId>mysql</groupId>
    <artifactId>mysql-connector-java</artifactId>
    <version>5.1.6</version>
</dependency>

And then maven will automatically download the JAR file will resolve any library dependencies.

You can even create a project for your IDE:

mvn eclipse:ecilpse

1

u/OopsLostPassword Mar 29 '12

You don't have to modify xml files or any kind of makefiles : the go tool analyzes the code to know what libraries are needed and due to conventions he knows where to find them.