Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I've been a Python developer for a decade. Go is the first language to successfully pull me away from Python. I've been developing in it for almost a year now and for every reason this blog post points out, I'm in love with it.


How has the library situation been? As a fellow Python developer, I'm very spoiled on libraries and every time I've looked at go, it doesn't seem to be gaining traction in that area.

The page full of go libraries the OP points to is laughably small -- even Haskell does better.

The core language though seems quite nice. Although it looks to not support OpenMP, which is a shame.

EDIT: I understand that Go is young and thus can't match up directly with Python/Java/Perl/C in sheer number of libraries. I'm more concerned with the rate of change of language adoption and new library creation, which doesn't seem to be large. But, the enthusiasm in this thread is quite encouraging.


Go is a new language (while it was developed in public, release 1 was just months ago) so of course the library situation is less well defined than in older languages.

On the positive side, the standard libraries are very consistent, the good 3rd party libraries tend to follow the conventions of the standard libraries (lots of decisions made in the language and tooling make it easier to do things the Go way than to treat it like it is another language) and if you really need some large chunk of functionality that Go doesn't provide and you don't have the time or willingness to make a pure Go version, you can easily pull C libraries in via cgo.


Ten years ago I was saying the same thing about Python with respect to Perl. Sure, it had some nice language features, but the libraries were a little spares. Now look at the Python libraries today.

Go's libraries are, IMHO, very thin right now. Just of the things I've recently looked for, there's no TLS v1.2, no XML parsing of any sensible variety, and the SMTP library is a sad joke. But I'm still using Go daily.

And guess what? It's also fun to get to write the libraries.


What does Go's encoding/xml package (http://golang.org/pkg/encoding/xml/) not do for you?


Being a new language it can't compete on the number of libraries. However, it does cover the ones I need the most for writing network servers. JSON, Websockets, Databases, SMTP, etc..

If I need to integrate features into a server that are more easily done in Python, I'll just launch a Python process from Go and communicate with it over pipes to get the functionality I need.


Can you be more specific regarding what libraries you need/miss?


Actually, yes! I picked up Go this week, and I'm actually really enjoying it. I did, however, hit a slight stumbling block because I needed to cryptographically sign some files to the PKCS#7 standard.

The 'usual suspects' have library support for this (Ruby, PHP, etc etc): Go does not (so I invoke openssl from within Go instead).

Putting that aside, it is a great language and one I'm really enjoying using. I primarily work in Objective-C, so it makes a nice change!


I suspect the 'usual suspects' just wrap OpenSSL, you can use Go bindings for OpenSSL too, but I'm also sure Adam Langley, who is responsible for the Go crypto lib and the main crypto guru for Chrome will be happy to help get any bits that you are currently missing into the go.crypto repo.

Hell, Go even has an official ssh library, I don't think any of the 'sual suspects' has that ;)

http://go.pkgdoc.org/code.google.com/p/go.crypto/ssh


To be fair, I didn't actually expect Go to have it covered. I was porting over some Ruby code, and it just meant a little diversion via the OS/Exec package.


I'm currently working on a set of OpenSSL bindings for go. https://github.com/shanemhansen/go-ssl/

Honestly the project is only a few days old and really sucks, but I found wrapping OpenSSL's SHA and AES features trivial. cgo is the most awesome FFI I've ever used. SHA hashing is actually faster using the OpenSSL version.

Please feel free to fork and add your features, in the meantime I'm working on adding support for a TLS listener/connection like crypto/tls.{listener,Conn}. http://golang.org/src/pkg/crypto/tls/


I was very excited when I learned Go had standard library support for ASN.1 as I want to write a Go implementation of my companies ASN.1 protocol, but then I realized it was DER and not BER. I need a library that has good support for BER. That said there is a 3rd party BER 'asn1-ber' library that exists on Github, but I have not had time to explore it enough, and the description for the project says it is very basic; just enough for the LDAP protocol.


Machine learning, natural language processing, linear algebra. Extra points for bioinformatics-related stuff.

These are things that, obviously, aren't going to be on the top of a core dev team's priority list. They will come with time. But I can't do without them.


There are already libraries to do some of those things. There are for example several linear algebra libraries like gomatrix: http://code.google.com/p/gomatrix/

I don't know so much about bioinformatics, but I know some folks are using Go in that field without too much problem. Of course, the more specialized your needs, the greater the chances you might have to roll your own.

But given that Go 1 has hardly a few months old, this is not very surprising.


I'm working on a Restricted Boltzmann Machine learner for Go. (https://github.com/taliesinb/gorbm).

It is very early days (0.083 days to be exact) but I intend to support Hinton-style "deep learning" within the next few days.

I have a feeling that Go's concurrency features will make it a good fit for various ML workloads. And it's a rare combination of expressive and metal-close, which is good fit for prototyping crunchy algorithms.


I'm basically in the same situation though I've been programming with Go for under 6 months now.

A few features that have really begun to draw me away from Python:

* A step away from object-oriented programming while still providing a way to associate functions with types via methods. I've been tending towards a more functional style in Python lately with functions and simple types instead of heavy OO code. * Static instead of dynamic typing. I find that I rarely actually benefit much from the dynamic typing features in Python and they can often be a source of bugs.

A couple of things I still find myself missing regularly:

* A full-featured unit testing library like Python's unittest * A simple interface for defining rich command-line argument parsers like Python's argparse


> * A full-featured unit testing library like Python's unittest * A simple interface for defining rich command-line argument parsers like Python's argparse

Most people find that the libraries for both unit testng and arg parsing in the Go stdlib are more than enough (IMHO specially the arg parsing lib does way more than I would ever want in a command line program).

But some people have written more "rich" alternatives, see the Unit Testing and Command Line UI sections here:

http://go-lang.cat-v.org/pure-go-libs

Some of the libs there are outdated, but that is mostly because in practice almost everyone find using what the standard Go distribution provides works very well. (If there is some functionality you are really missing you could fill an issue, but you would have to make a convincing case as to why it is needed.)


In the workplace we've written a pretty extensive suite of command-line programs in Python using the argparse module. It has some nice features to easily define subcommands as well as mandatory positional arguments, different argument multiplicities, etc. While most simple command line apps don't need this kind of functionality, the kinds of apps we are writing at my employer often do.

Anyway, neither of those cases are by any means a major downer, just two things that have been niggling me from time to time.


Somebody mentioned recently that the code that is part of the `go` tool that handles sub-commands maybe should be factored out and added to the stdlib, it should be relatively straightforward. If you are also interested in that I would recommend filling an issue in the tracker and if a few more people find it useful it probably will happen sooner rather than latter.


if you're talking about someone mentioning it in #go-nuts, that might have been me. I have a reference project to do that here: https://github.com/jordanorelli/multicommand

haven't taken time to turn it into a proper library.


Have you looked into using the built-in testing[1] library for unit tests; it seems very full-featured to me. In Go the flag[2] package contains the command-line argument parsing functionality.

Is it that you didn't know about these libraries, or that they don't meet your requirements? If the latter, what do you require from each of them that they do not already deliver?

[1] http://golang.org/pkg/testing/ [2] http://golang.org/pkg/flag/


I have used (and continue to use) both of these libraries. The testing library works fine but it doesn't include much other than the bare minimum. A more batteries-included library could include some assertion methods to test for value equality/inequality and provide some pre-canned error messages.

As for the flag package, it's fine for simple command-line flags but doesn't have anything to deal with specifying positional arguments. Sure you can get them from the Args() method but you have to basically write another layer of argument handling to deal with them. I like Python's argparse module's approach and flexibility there.


> A more batteries-included library could include some assertion methods to test for value equality/inequality and provide some pre-canned error messages.

For value equality, just use reflect.DeepEqual[1]. The wiki also has a page on table driven tests, which is worth a read[2].

[1]: http://golang.org/pkg/reflect/#DeepEqual [2]: http://code.google.com/p/go-wiki/wiki/TableDrivenTests


Just the other day I stumbled upon that wiki page, it looks like a pretty reasonable technique and I've started adopting it.

Thanks for the pointer to the reflect package, I shall check it out.


What evidence is there, if any, that Go is significantly more performant than Python? I'm not disputing it (it seems to me as though it ought to be). I'm just asking if there is any evidence that it actually is (or will be). If no real evidence yet, I'd still be interested in opinions (with explanations.)

I'm particularly wondering about code other than Web apps with hundreds of simultaneous users, such as single-user statistical AI/machine learning or other performance-demanding apps where Python has to delegate to libraries written in C.


Optimized C/C++ will usually beat out Go code, while Go will usually far outstrip the cpython interpreter[1]. Go itself doesn't really have any optimization for vector processing using SIMD that would make it a "fast" language for doing things like machine learning, machine vision, etc.; hand-coded C/C++ is always going to beat out any other language here. If you're talking python vs. go though, Go will win hands down.

To be honest my personal viewpoint is that we're better off reducing our dependence on SIMD CPU instructions and using GPUs for this sort of highly-parallel processing instead. Most Processors sold these days come with a GPU built-in, so why not make use of these SIMD units, rather than duplicating them on the CPU? This is just my opinion though, and is sort of irrelevant to the question.

Go has an excellent interface to C (cgo) built in, and SWIG can also be used to wrap C/C++ libraries so they are usable in Go. If your aim is core-for-core speed, then your best option is probably to take some highly optimised C/C++ library and create a wrapper that allows you to access it from Go. This route would be at least as performant as any python implementation using the same technique, if not much faster. If your goal is having a highly-concurrent and safe implementation, it is better to implement such libraries from scratch in Go; this is the method most Go libraries use.

Just as with benchmarks, I don't think anyone can give you a non-subjective answer on whether Go will be faster (so take mine with a grain of salt).

[1] http://shootout.alioth.debian.org/u64q/benchmark.php?test=al...


I/O bandwidth between the GPU and main memory is a significant limiting factor, giving SIMD instructions on the CPU an advantage.


For big data sets or complex SIMD algorithms the I/O bandwidth overhead is tiny compared to the speedup achieved by moving the calculation to the GPU.

For the calculations that don't work well on the GPU due to small data sets, simple calculations, or bandwidth constraints we could just run the code in parallel across multiple cores/multiple goroutines.

I think eventually (and this seems to be the direction companies like AMD are headed in) we'll have a couple (maybe up to 4) big cores right next to a bunch of smaller whimpy GPU-like cores which handle SIMD, making SIMD on big cores all but redundant. We're not there yet but AMD and Intel are both working on trying to get their on-chip GPUs to share memory with the processor directly. At the moment the focus for this is mainly gaming performance, so textures, etc. don't have to be copied from main memory to the GPU; the same functionality will greatly benefit GPGPU though. Once we have this heterogeneous architecture and newer faster memory technologies, the problems with using the GPU for SIMD will disappear.

But for the moment, with the real-world technology constraints we have, you're absolutely right on the limitations of GPGPU.


Running code in parallel across multiple cores is going to lose to SIMD. I don't think SIMD is going away anytime soon.


Go's http package is competitive with nginx, so that should give you an idea of the playing field that Go competes in.


Do you have a pointer to some data? I am especially interested in the minimal latency even when serving from memory a response under light usage (100 concurrent users).

This would be at first to provide "backend" services to currently running applications, so the latency overhead is important.


> What evidence is there, if any, that Go is significantly more performant than Python?

You do realize that Go compiles to machine code and Python is a dynamically interpreted language?

The obvious answer is that the Go standard library packages (http://golang.org/pkg/) are written in Go, including crypto code (e.g., http://golang.org/src/pkg/crypto/sha1/sha1block.go), but many of the Python standard libraries are written in C for performance reasons.

For file I/O and network bound applications (e.g., Django) Python is a great choice, but if your app involves any serious computation Go is much, much faster than Python (or Ruby, Perl, PHP etc.).

Python does have excellent 3rd libraries for computation like Numpy but the actual number crunching code is written in C or Fortran.


>You do realize that Go compiles to machine code and Python is a dynamically interpreted language?

Which doesn't matter much if Go's machine code/runtime is inefficient or if Python libs are written in C in the first place whereas Go's are written in Go.



And the sad thing is that have the same syntax obscurity derived of C. Is still not readable (like python or pascal), lack the fast-coding/reading and a lot of things that make python the most fun/readable language ever (IMHO!!).

However, I wish that python have some of the cool things of GO (like gorutines) and other stuff like in cobra-language.com and:

1- Removal of null (using maybe as haskell) 2- Decimal instead of float as default

Still, the new languages refuse to fix #1. #1 Must be declared a goal like have garbage collection right now.


You can't really use Maybe like in Haskell without a static type system.

After all, in Python, there is no actual Null-pointer exceptions; instead, you have TypeErrors that just happen to trigger on None. Even if you had some sort of option type, you would still get runtime errors because there is not enough information to deal with them at compile time.

Now, you could add some sort of abstractions to make checking for None in your code easier. But when your "benevolent" dictator hates folds, you're not getting any advanced features like monads any time soon!


Yep, the sad thing is that you can't get all in a single package.

The type system in Haskell look very good. But the cobra language have a implementation very close and in line with the spirit of python...


>Is still not readable

Wha...? Have you spent any time with it at all?




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: