28 ms·
Why I Program in Go
- georgemcbay 14y agoThose are many of the same reasons I program in Go. To add another: * Go's build tools and the language's overall approach to building projects are fantastic. For the vast majority of projects you don't need an external build manager like make. One of my least favorite bits of programming in C and C++, even when I was doing that on a daily basis years ago, was the huge morass of make/autoconf hell that would grow up around projects and would be very difficult to understand and reason about unless you were there for the entire project's development. With Go open source projects (on git, svn, mercurial) much of the time you can just go get http://hosted-code-site/blah/(package) cd (package) go build ... out pops a working executable.
- mitchi 14y agoI have to agree that this is invaluable.
- enneff 14y agoActually, the "get" command implies "build" and "install", so it's just (a real example): go get github.com/nf/todo and you get a todo binary in your workspace's bin directory.
- georgemcbay 14y agoTIL. Thanks, that's good to know. Another (related) wonderful thing about Go is how fast everything compiles, so fast that it never occurred to me that go get was building as part of the install.
- danieldk 14y agoWith Go open source projects (on git, svn, mercurial) much of the time you can just And have absolutely no version management or any way to indicate API changes (except for making a new repository for every API-breaking change).
- codygman 14y agoThe ecosystem makes it more difficult to write bad software. Handle all of your errors, you can't put in things you don't use, it makes testing VERY easy, logging really easy, and if you have testing you have performance testing for free with it. Not having version management is a real concern, but I solve that problem by forking the projects and updating manually as needed. Ubuntu and debian are soon going to be allowing you to install go packages with their package management systems if I'm not mistaken.
- aleksi 14y agoIt's not practical to fork all projects if you have a lot of them. And Debian failed in packaging Python and Ruby libraries (IMHO). That's why I created http://gonuts.io http://gonuts.io
- voidlogic 14y agoI love Go for many of the same reasons as the author. Go's fantastic performance doesn’t' hurt either. :) These micro-benchmarks match what I have seen in the real world: http://benchmarksgame.alioth.debian.org/u64q/which-programs-are-best.php?calc=chart&go=on&ghc=on&sbcl=on&java=on&scala=on&csharp=on&fsharp=on&php=on&hipe=on&python3=on&erlang=on&clojure=on&yarv=on&perl=on&jruby=on&xfullcpu=1&xmem=1&xloc=1&nbody=1&fannkuchredux=1&meteor=1&fasta=1&fastaredux=1&spectralnorm=1&revcomp=1&mandelbrot=1&knucleotide=1®exdna=1&pidigits=1&chameneosredux=1&threadring=1&binarytreesredux=1&binarytrees=1 http://benchmarksgame.alioth.debian.org/u64q/which-programs-...
- pron 14y agoThey sure do. Slower than Scala and requiring more code and lacking the awesome power of the JVM. Great choice, indeed.
- voidlogic 14y agoYeah- that is great as long as you don't care about using 30x times more memory.... The awesome bloat cough I mean power of the JVM in action. Go vs Scala: http://benchmarksgame.alioth.debian.org/u64q/benchmark.php?test=all&lang=go&lang2=scala http://benchmarksgame.alioth.debian.org/u64q/benchmark.php?t... It will be interesting to re-visit this when Go 1.1 is out as well. Go being even younger than Scala has a lot of low hanging optimization fruit. :) P.S. If Go didn't exist I would still be using Java/C#/C/C++ for everything. (I still use Haskell/Prolog where needed)
- pron 14y agoThe memory consumption is probably mostly due to the JVM's GC implementation that can be very finely tuned (although large RAM footprint surely is a feature of the JVM). Some of the bloat is, true, baggage that's been accumulated through the years, but that's being taken care of in Java 9. And the rest of the "bloat" is there for a reason. Let me put it this way: if you have a program that absolutely requires JVM performance, it probably requires the "bloat" as well, as it gives you runtime instrumentation, advanced debugging hooks and other sorts of invaluable monitoring tools.
- danso 14y agoI want to try out Go...but I have to make one initial observation...It can be somewhat hard to Google (ironically) for Go programming examples. I'm sure there's some tinkering you can do in your search query to get slightly better results, but "Go" is a difficult proper pronoun to facet a search around. https://www.google.com/search?q=go+facial+recognition https://www.google.com/search?q=go+facial+recognition https://www.google.com/search?q=python+facial+recognition https://www.google.com/search?q=python+facial+recognition
- PuerkitoBio 14y agosearch for golang, most relevant resources will be found with this term. Edit: also, for package discovery, godoc.org. But golang+anything usually works.
- danso 14y agoI was wrong to doubt Google's foresight.
- kristianp 14y agoThis was never a problem for me when I was using go. Just use golang in your search terms.
- rartichoke 14y agoGolang is pretty popular to search with. Also an interesting thing to note is the main page (golang.org) has an awesome amount of information. Couple that in with a few Google I/O videos on Youtube and you seriously have enough information that you almost don't have to Google for anything.
- jvm 14y agoThey seriously need to implement go ogle <packagename>
- steveklabnik 14y agoI just can't get that hyped about Go, but I will tell you (as a Rubyist, primarily) I've really been enjoying Rust. While they're not directly competing, my experience is similar to the author's PHP -> Go, which is why I comment. I have programmed significant projects in statically typed languages in the past, but this new batch of languages (Rust/Go/Scala/etc) are certainly neat.
- pron 14y agoFor the life of me I can't understand why anyone would give up the power (in terms of profiling, monitoring and ecosystem, and somewhat better performance, too) of the JVM, for a language marginally more convenient than Java, and arguably less expressive than other JVM languages. The only thing I could think of is a smaller RAM footprint, if you care about that sort of thing. Whenever Go is compared to Java, the arguments in its favor seem kind of fuzzy. After all, one of the motivations behind Go was a C-like language with far better compilation time than C++. And Java already fits the bill. So, yeah, Go is leaner and more modern -- but certainly not by an order of magnitude, like other JVM languages. Here, too, the author says that he didn't like Java's IDEs (really? does Go have better tooling? Because Java IDEs really get the job done), frameworks etc. But those things are simply the result of years of changing fashions. Newer Java "frameworks" are just as lean-and-mean as Go. There are so many new and exciting languages around, but Go seems to carry the least "oomph" of the lot. It's basically Java. A little nicer; a little slower; a lot less powerful.
- realrocker 14y ago>Here, too, the author says that he didn't like Java's IDEs (really? does Go have better tooling? You should really write a GO code to understand what the author means. Writing GO code has no frills. And I have seen nothing cooler than: http://gofmt.com/ http://gofmt.com/.
- pron 14y agoEven if that's the case, Go just brings too little to the table. And if you think gofmt is cool, take a look at Project Jackpot [1], or its use in the NetBeans IDE [2]. [1] https://bitbucket.org/jlahoda/jackpot30/wiki/Home https://bitbucket.org/jlahoda/jackpot30/wiki/Home [2] http://netbeans.org/kb/docs/java/editor-inspect-transform.html http://netbeans.org/kb/docs/java/editor-inspect-transform.ht...
- zaphar 14y agoThose aren't in the stdlib. gofmt is. So is gofix, go vet, godoc and a host of other things. Batteries included means a lot.
- nnoitra 14y agoWe don't care you why program in Go.
- kicktheshoe 14y agoexactly. Wonder how many of these are upvoted by Google staff. EDIT: and dissent downvoted by google staff?
- codygman 14y agoI care
- TallboyOne 14y agoIf anyone is interested in learning go, my site has a compiled list of tutorials and so on http://pineapple.io/resources/tagged/go-language?type=tutorials http://pineapple.io/resources/tagged/go-language?type=tutori...
- ternaryoperator 14y agoThe recent five-part tutorial on Go that ran in Dr. Dobb's also has articles worth linking to: http://www.drdobbs.com/240008277 http://www.drdobbs.com/240008277
- TallboyOne 14y agoAdded
- theyak 14y agoI have been unable to find a good web server tutorial. Everything seems to be listen, process page, done, repeat. This doesn't seem to allow multiple connections at once, especially if the process page process takes a long time.
- enneff 14y agoGo's net/http package is concurrent behind the scenes; each request is handled in a separate goroutine. You just write your HTTP handlers in the obvious way and the concurrency is taken care of by the runtime. http://golang.org/doc/articles/wiki/ http://golang.org/doc/articles/wiki/
- martinced 14y agoHis second point is, to me, the most important for would-be language designers: Standardized formatting: A standard tool to enforce formatting rules that is not subject to change based on the team members' or leader's opinions is a welcome feature for lowering the "not my code" mental barrier. This is a godsend. The best thing to have happened to our industry since a very long time. But his first point is oversimplified: The compiler not only checks for code that can theoretically result in a runnable program... It's not exactly as if Go did solve the halting problem or we'd ALL be using Go. So I think a bit more in-depth explanation would have been welcome.
- tikhonj 14y agoIn a certain sense, languages like Agda do solve the halting program, but we're not all using them... Seeing more total languages used in industry would be pretty cool.
- chimeracoder 14y agoSlight correction > The compiler not only checks for code that can theoretically result in a [logically correct], runnable program... Some examples of this: - If you try to assign to a variable that will never be read, this is a compile-time error. - If you try to import a module that will never be used, this is a compile-time error. - If your dependencies don't form a DAG, this is a compile-time error. Incidentally, not only does this make runtime errors (or logical errors) much less common, it also makes Go code more readable and vastly contributes to its impressive compilation speed.
- kicktheshoe 14y agoIf the biggest gain for the language is a formatting utility then that language is not worth learning.
- jlgreco 14y agoWhat is the "biggest" gain a language can have is a matter of taste. Someone who considers the handling of formatting and style to be the "biggest" is likely to be one who values those things highly. That you do not value those things as highly is not particularly profound. It doesn't mean that he is wrong to be excited about that, nor that he is excited about the wrong language, nor even that there is no reason for you to be excited about that language. It only means that there is no reason for you to be excited about that language for that particular reason.
- ericbb 14y ago> Now, you might want to ... acquaint yourself with [dataflow variables and declarative concurrency] because [they are] the centre-piece of Go's language features. Not so. Go has native support for neither dataflow variables nor declarative concurrency. Go does have native support for message-passing concurrency--but that's different.
- code_martial 14y agoYou're right about that. However, I find it easier to understand Go's concurrency model by starting with dataflow and then adding one more requisite (channels), than starting with classic fork-and-join and then making a bigger jump to message passing concurrency.
- c141charlie 14y agoGo nails code readability and documentation better than any other language I'm aware of. For example, look at the package documentation for Go's list data structure at http://golang.org/pkg/container/list/ http://golang.org/pkg/container/list/. 5 seconds of reading this you immediately get what the package does and how to use it. Now let's say you want to know how the list is implemented. No problemo. Click the package files link list.go, http://golang.org/src/pkg/container/list/list.go http://golang.org/src/pkg/container/list/list.go, and you're presented with very readable source code. Now compare this with Java. I just Google'd Java List. First link is this: http://docs.oracle.com/javase/6/docs/api/java/util/List.html http://docs.oracle.com/javase/6/docs/api/java/util/List.html Documentation looks OK, but wait, this is the interface. I want to see docs for a concrete implementation. I'm tempted to click on the AbstractList link, but oh wait, that's just another non-concrete class that other List classes probably inherit from. Let's see, let's go to the ArrayList ... this looks good. http://docs.oracle.com/javase/6/docs/api/java/util/ArrayList.html http://docs.oracle.com/javase/6/docs/api/java/util/ArrayList... Nice. I wonder how they implemented this. And I'll keep wondering because I can't find a link to the source code. Maybe there is a link to it, maybe not. We're talking about Oracle so without knowing better, I'll assume there is not ... Let's try Scala. Google "Scala List". Click on first link. http://www.scala-lang.org/api/current/index.html#scala.collection.immutable.List http://www.scala-lang.org/api/current/index.html#scala.colle... What the fuh is a "sealed abstract class List[+A] extends AbstractSeq[A] with LinearSeq[A] with Product with GenericTraversableTemplate[A, List] with LinearSeqOptimized[A, List[A]]" Oh sweet, this thing has all kinds of methods, i.e. ++, ++:, +:, /:, :+, ::, :::, :\ Reading further, I see section in the documentation called "Shadowed Implict Value Members". Wow, I have no idea what that is. Looking back to the Go documentation, I immediately "relax" as another commenter put it. For some reason, I think Scala will end up being the next Java. It has so much momentum, runs on the JVM, has seamless interop with Java code. Has the Play Framework, AKKA, and thousands of other awesome libraries written for it. And if Scala powers Twitter, then I think this answers the scalability and concurrency question. While I'm bullish on Scala, at the end of the day, I find Go's simplicity make it more beautiful than any other language.
- rorrr 14y ago> Go nails code [cut] documentation better than any other language I'm aware of. That's because you haven't seen PHP's documentation. Look at your Go's list example. It doesn't even show how to create a list and fill it with items. It doesn't have users' comments. It doesn't explain much about the data structure. Can it be a circular doubly link list, for instance? Is there a method to empty the list, or quickly insert more than one element? Instead it has strangely named sections (like "type Element") that aren't obvious to somebody new to the language. Sorry, but this documentation is shit.
- fooooobar 14y agoNot what I would call fresh or all that new...
- guilloche 14y agoI am C and lisp fan and think OOP as non-sense. I used python a bit but hate its performance. Can I still get something from Go that can not be provided by C and lisp? Does go provide great flexibility by C and lisp? BTW, I think emacs is the best IDE so I do not care any tools/IDEs at all.
- enneff 14y agoIf you're a C programmer then you will enjoy Go. Try it.
- djhworld 14y agoGo is a bit like C but it has GC so it depends on how much you value the fine degree of control of memory allocation that you get with C. Personally I think Go has a lot cleaner syntax than C and the tools give a lot more "friendly" error messages when compiling your applications. You do still get nullpointerexception runtime errors though but that's an inherent problem with the nil/null type.
- guilloche 14y agoThanks for replying. It seems GO is not for me at least now. What I want is an optional strong typed script language with highest performance. Lisp serves me well here. I have only three real things to care about a language: 1. Performance and thus optional strong typed is required. Go can have optional strong typed system, so performance may be improved in future, but its GC seems a big warning for me. I want to have option to allocate/free memory myself. the GC is also an enforcement of some design principle, which is also a big minus regarding the next point. 2. Great flexibility, basically the language should not make any decisions for developers. I dislike C++ for its OOP approach to make way too many decisions for developer. I want no limitation from a language. I can self restrain to avoid all troubles from freedom, I can design OOP/GC myself if it is neccessary, but please not make decision for me. (C++ did not enforce OOP, but most of the extra part beyond C usually distorts a good design otherwise) Lisp and C are almost perfect here. Does GO allow any weird design people may think of? any enforcement of some supposed-to-be good principle? 3. A script, which can relieve me on all details. Occasionally, I may not care performance, and I want life easy. Python is prety good here. Lisp is good but lack of compiling on ARM machines is a big disadvantage.
- tsahyt 14y agoThus far I feel that, if any language was ever going to replace C, it's probably Go. In a way I sympathize with Go. I like it for the compactness and simplicity. Those are two design decision which seem to be unique among modern languages and exactly the two things I like most about C.
- introspectif 14y agoAs an ex-Ruby cum Node.js lover recently converted to Go... Programming in Go, once it clicks, really does feel relaxing and productive. If you're a decent Node.js programmer, it's like stepping up to "Node Pro", in the sense that you work close to the metal with your web server so everything feels clean and easy to wrap your mind around. But Go code is cleaner and tighter. The code formatting conventions contribute to that greatly, as well as the fact that you just don't have to pull in as much 3rd party code because so much functionality is already beautifully integrated. There are a lot of positives about Go that reveal themselves over the first couple days of coding in it. I do wish the documentation convention included not only a brief description each function, etc., but also a brief example. By the way, I also evaluated Scala for a few days before settling on Go as my preference. I like Scala, but it quickly becomes a sprawling language as your explore it further, and frameworks like Play and Lift bring even more baggage along for the ride. The core language, on its own, was attractive, but overall, the experience just didn't have the compact, robust, completely under control, and nimble feeling that came with Go. Oh ya, and the Go syntax felt ugly and awkward at first. That feeling quickly faded after a day of use, but it's worth mentioning because I bet it turns some people away from Go before they even get to the great parts. Just my 3 cents worth.
- agentS 14y ago> I do wish the documentation convention included not only a brief description each function, etc., but also a brief example. It is getting there. If you run godoc locally with tip, you will find many more examples than there were previously. See http://golang.org/pkg/path/ http://golang.org/pkg/path/ for a current example. And the source for those examples can be found here: http://golang.org/src/pkg/path/example_test.go http://golang.org/src/pkg/path/example_test.go. Note that this technique will work for your own packages as well. The technology is there, the implementation is still incomplete; but more progress has been made than is easily visible.
- asdf3 14y agoThe golang website supports other versions; to see the docs for tip go to http://tip.golang.org/ http://tip.golang.org/
- p0nce 14y agoI prefer to use Hypescript for all my kickass cloud deployments.
- mcartyem 14y agoCan anyone explain in less than ten words the most important reason to program in Go?
- Symmetry 14y ago"Many of the best part of both C and Python"?
- af3 14y agoIt feels like Go is the new Fortran.
- crusso 14y agoJava is perhaps the most depressing language I've ever programmed in. I'd have to agree with him there.
- mark_l_watson 14y ago"Earlier I mentioned about the JVM being a bad trade-off for phantom portability. In practice, non-trivial Java programs also require porting for different systems." I have used Java since the beginning (and I have written several Java books). I have had very few portability problems. The JVM is a great ecosystem that supports several fine programming languages.
- jhuni 14y ago> Scalars (integers, characters, strings, floats, booleans), sequences (lists/arrays) and maps (key-value pairs) as built-ins are enough to support almost all data models. There is some wisdom in Larry Wall's decision to make scalars, lists, and maps the main data structures in the Perl programming language and to give them the sigils $, @, %. The considerable wealth of Perl libraries available on CPAN today demonstrates that you can support essentially all data models using these three data types.