12 ms·
Go is amazing, period.
- firefoxman1 15y agoIs there currently a good web framework for Go? Edit: web.go looks pretty sweet: http://www.getwebgo.com/ http://www.getwebgo.com/ Edit2: As does app.go: https://github.com/georgenava/appgo https://github.com/georgenava/appgo ...There's a large list of Go projects here: http://godashboard.appspot.com/project http://godashboard.appspot.com/project
- zemo 15y agounlike other languages, a framework isn't as much of a requirement in Go since the Go standard library includes an http server, json serialization/deserialization, html templating, email, logging, basically everything you need in a web app. The url routing is pretty crappy, but that's my only real gripe. ngmoco's Falcore is worth looking at: https://github.com/ngmoco/falcore https://github.com/ngmoco/falcore
- drivebyacct2 15y agoGorilla's mux adds much more capable and advanced routing. It's really nice to use it with subroutes, etc. Again, dead simple partly because it's designed well and partly because Go makes it easy to build. http://gorilla-web.appspot.com/pkg/gorilla/mux/ http://gorilla-web.appspot.com/pkg/gorilla/mux/ If you want something more lightweight (Gorilla's not "heavy" by any means) there is pat (formerly pat.go) https://github.com/bmizerany/pat https://github.com/bmizerany/pat
- enneff 15y ago> Is there currently a good web framework for Go? The standard library gives you almost everything you need. The http package provides a web server and client: http://weekly.golang.org/net/http/ http://weekly.golang.org/net/http/ The template package provides text templates: http://weekly.golang.org/text/template/ http://weekly.golang.org/text/template/ and automatically-escaped HTML templates: http://weekly.golang.org/html/template/ http://weekly.golang.org/html/template/ For other bits and pieces, see the rest of the standard library: http://weekly.golang.org/ http://weekly.golang.org/ I also recommend the Gorilla Web Toolkit for some other useful web-app functionality: http://gorilla-web.appspot.com/ http://gorilla-web.appspot.com/
- 4ad 15y agoYup, the standard library was all I ever needed. People from other languages are familiar with frameworks and seek them in Go, but I'd say they are seldom required. The rich standard library and the language makes everything easy.
- dhaivatpandya 15y agoI've used web.go successfully before; its quite nice.
- firefoxman1 15y agoWhat's it like to use a compiled language for a web server?
- BarkMore 15y agoBecause the Go compiler and linker are so darn fast, the extra compilation step is just a blip. It's not like working with Java or C++.
- enneff 15y agoIt's really nice. You can build your Go program, deploy it as a single binary and it just runs. No need to hide it behind nginx or some other dedicated web server. The Go http package is DoS hardened and very fast. It's refreshing how little mechanism there is.
- stock_toaster 15y agoHow are the database libraries (postgres/mysql) these days? Last time I poked around (been a while) it seemed like most of them were pretty beta yet.
- enneff 15y agoThere's the new database/sql library (http://weekly.golang.org/database/sql http://weekly.golang.org/database/sql), which is a general SQL interface backed by various driver implementations (http://code.google.com/p/go-wiki/wiki/SQLDrivers http://code.google.com/p/go-wiki/wiki/SQLDrivers).
- stock_toaster 15y agoGood to see that has improved quite a bit. Thanks!
- jbarham 15y agoNote that there is experimental support for Go on App Engine (http://code.google.com/appengine/docs/go/overview.html http://code.google.com/appengine/docs/go/overview.html) and the beta versions are tracking the Go 1 changes pretty closely.
- jff 15y agoA simple server for static files and blog posts: https://bitbucket.org/floren/goblog https://bitbucket.org/floren/goblog It uses only the packages which ship with Go, with the exception of a Markdown parser. Unfortunately, it's written for an ~6 month old release of Go on Plan 9, but you can get the general idea of building Go web stuff. The code's a bit ugly too, but it does work.
- Radzell 15y agoI like go. As a guy who really doesn't like javascript I like the structure of GO. I like really structured languages. For anyone who like the mobile/desktop type of programming this seems like a refreshing change.
- ootachi 15y agoEr, JavaScript is a structured language (meaning it doesn't mandate labels and goto for control flow).
- brnstz 15y agoMany programmers educated in the OOP days don't know the term "structured programming". I once interviewed someone who called a Pascal-like language "functional". We hired him anyway.
- Radzell 15y agoFrom what I here there not enough programmers around so you might of not had a choice.
- enneff 15y agoI think what your parent is referring to is that, compared to JavaScript, Go provides a fairly rigid structure in which to write programs. You write packages that consist of type, function, and variable declarations, and link them together with import statements. Its rich standard library supports a range of useful, omnipresent interfaces, which make it easy to do things in an obviously correct, interoperable way. By comparison, JavaScript lets you structure your code in however you like, and there is a very tiny standard library and no real uniformity across implementations, frameworks, and so on. This can be a strength, but I think on balance it is a real weakness in JS. node.js has done a lot to improve this, though the language itself still lets you define anything, anywhere, at any time, and change that state from anywhere else.
- ootachi 15y ago
- juliennakache 15y agoWow. This dude is 14 year old.
- oomkiller 15y agoYep, and he just released his bayesian alg he talks about here: https://github.com/Poincare/Bayesian.go https://github.com/Poincare/Bayesian.go
- braco_alva 15y agoYeah, very impressive for someone of his age, I wish there were more kids like him.
- bane 15y agoreminds me a bit of http://en.wikipedia.org/wiki/Ken_Silverman http://en.wikipedia.org/wiki/Ken_Silverman
- halayli 15y agoThe OP easily dismissed numpy in Python and coroutines (e.g gevent)
- zemo 15y agoto be honest, I've used both gevent and Go and concurrency is far more natural in Go. Sure, you can do most of what you want with gevent, and if you're using stackless or pypy you can even have channels, but implementing concurrency at the library level is a mistake. It feels bolted on. It's like how some programming languages weren't object oriented from the start, but then they bolted an object system on top of it in a later release; it feels kludgy and you notice that it's bolted on. Concurrency in Python reminds me of that. Yes, it works, but it's awkward and feels like a second-class citizen.
- jbarham 15y agoI've done concurrent programming in both Python and Go, and to be fair to Python, its standard library queue class (http://docs.python.org/library/queue.html http://docs.python.org/library/queue.html) is very close to Go's channels so it does CSP style concurrency quite nicely. However, Go's goroutines are IMHO superior to Python threads since they're much more lightweight and can run in parallel on multi-core CPUs and you can have a lot more of them. Go gets it right by putting goroutines and channels into the core language to encourage CSP style concurrency, but putting other more traditional, but harder-to-use, concurrency primitives like mutexes into the standard library.
- luriel 15y agoI agree with most of your comment. But I'm sorry, this part is not even close: > its standard library queue class (http://docs.python.org/library/queue.html http://docs.python.org/library/queue.html) is very close to Go's channels so it does CSP style concurrency quite nicely. Among other things, it lacks any construct similar to Go's `select`, without which channels are nowhere nearly as useful. And then there are issues like what you point out about how incredibly cheap goroutines are.
- swah 15y agoI'd love to have Python library availability in a staticly typed language.
- ootachi 15y agoMany statically typed languages have excellent library support. At this point Java, for example, has all of the libraries that Python has, and more.
- simplyinfinity 15y agothere are also a lot of libraries for the .net platform outside the framework itself , too
- edwinnathaniel 15y agoNot only excellent library support, but also a large array of productivity tools ranging from superb IDE, static code analysis, build+dependency tools, great Continuous Integration, etc.
- dhaivatpandya 15y agoHaskell also has (pretty) good library support (talking about "batteries included")
- swah 15y agoIt's mainly a bad impression then, that w/ Python every document is to the point and with Java an outsider can't do anything? I'll try to build my next project on top of github.com/codahale/dropwizard
- drivebyacct2 15y agoNot to push the issue, but Go's standard libraries are fairly decent for being minimal and are dead simple to use. The docs have a good mix of examples and quickly parseable information.
- reddit_clone 15y ago
- j45 15y agoA lot of great and capable languages are overlooked. The question is how do they overcome the opinion, hearsay and preferences that are louder than the truth? Too few devs: - truly give something 5 minutes before jumping to their foregone conclusion. - admit that most languages with a decent capable and decent programmer are all, pretty equally equipped. - every language + framework has it's pros and cons.
- dhaivatpandya 15y agoI didn't give Lisp 5 minutes; something I still regret (could have learned it so much earlier!)
- brnstz 15y agoGo has the advantage of being developed by Rob Pike and Ken Thompson. It also potentially has the marketing muscle of Google behind it, although the most I've seen so far is free stuffed Gophers at OSCON. Type safety, easy concurrency, static checking, C-like syntax, fast compilation time, concise syntax, etc. Java is ripe for replacing as the default language for (new) large systems. The replacement could be another language on the JVM, but I think Go has a good shot.
- ootachi 15y agoDepends what you mean by type safety. If by type safety you mean free from segfaults, Go is very much type-unsafe (send a map over a channel, access it concurrently, and it will segfault).
- drivebyacct2 15y agoMaybe I'm mistaking terminology but that doesn't seem like a type issue you're describing.
- ootachi 15y agoThere's no one definition of type safety. It ultimately depends on what your type system is trying to enforce. I strongly suspect, however, that most programmers expect "type-safe" languages to enforce memory safety, and that Go's lack of memory safety is surprising in this context.
- tpsreport 15y agoHere's a summary of the article: * author cannot write portable C sockets code * author cannot handle C/C++ * author believes his app would be too slow in Python, later abandons App, but retains his bias against Python * Go has no parens for if/for * Go has unicode support * Go has closures "like salt shakers" * Go is cohesively designed * Go has nice libraries Go may or may not be a good language, but this kind of argument is not going to win me over.
- noveltyaccount 15y ago* Author is 14 years old
- dhaivatpandya 15y agoEven if I was 59, I still think that the comment above is quite misinformed.
- dhaivatpandya 15y agoI usually wouldn't respond to mean comments, but, this one really throws me off (I'm the OP). There is a very strong difference between "cannot write" and the need for something to be simple. I can definitely handle C/C++, and I don't think writing something in a higher-level language changes that. If something is doing processing with 4000 threads with around 10 years worth of by-the-minute data, it sure as hell will run too slow in Python. And, the arguments stated after are not crucial to "making you switch to Go", which was not the point of the article anyway. EDIT: Also, I did not abandon the app, and in fact open sourced the Bayesian filter stuff I wrote right here: https://github.com/Poincare/Bayesian.go https://github.com/Poincare/Bayesian.go
- rocha 15y agoAre you processing data using 4000 threads? Do you have access to a cluster? Otherwise it seems counter-productive. BTW, Python has great facilities (IPython.parallel) for doing parallel and distributed computing. It is also pretty good at number crunching using Numpy.
- rian 15y agoi truly believe go contributes negative work to society. it's basically C/C++/Java/C# with syntactic sugar except it's different enough to get bored programmers to waste their precious time reporting all their code. if you want to learn a new language, actually learn a new language. learn a language that's actually breaking the mold in terms of how we communicate with computers. think at a higher abstraction level than dynamic dispatch and composable objects and subroutines, that stuff is already more than 40 years old. http://www.thocp.net/biographies/papers/backus_turingaward_lecture.pdf http://www.thocp.net/biographies/papers/backus_turingaward_l...
- deleted 15y ago[deleted]
- drivebyacct2 15y agoSo because it's not revolutionary, it is actually harmful? Sorry, I don't follow at all. Even if it's "better" than C/C++/Java/C# [1], then it's a positive contribution. [1] I think it's silly to imply that languages are "better" than one another. Some are more apt for certain projects and some have different feature sets that appeal to certain people. Certainly it seems unrealistic to absolutely call a language useless, especially given the points in this articl.
- jshen 15y agoI completely disagree. My goal is to build better systems, and if an evolutionary change helps this, then that's where I'm going. You seem to value "breaking the mold" for the sake of "breaking the mold" Or, you didn't give a good reason to value it. "that stuff is already more than 40 years old.". Is this the fashion industry? Or do you believe that quality is a function of age?
- njharman 15y agoI agree with your goal. But the parent is correct in that learning a really different language will help you become a better developer and thus build better systems.
- srean 15y agoI have'nt managed enough time yet to familiarize myself with Go, but the little that I have glanced at, it seems a nice enough language for scientific computation. The syntax and semantics of arrays are nice and binding to C is purportedly simple. Ease of binding with Fortran would have been nice too. So I find it a bit strange that I never hear of Go in the context of array based computation, that is the stuff people use Numpy, MATLAB, J, K for. Is there any particular reason for that or is it just that not many have got around to doing it. A type-inferred language with first class functions, with strong support for parallelism, and good support for arrays and slicing seems a really sweet deal. Throw in SIMD and it is already very compelling. Is anything wrong with the picture that I am missing. Performance issues ?
- georgemcbay 15y agoThus far you barely hear of anyone using Go in any context, though that is changing. I think the primary reason for the lack of users has been language stability. The Go team are currently working on the first actual "release" of the language ("Go 1") to address this. But prior to the move towards Go 1, the language was very much in flux, more so than you'd want for a language (that you'll actively be maintaining code in) to be. (And gofix, while nice, isn't really a substitute for language and standard library stability).
- krasin 15y agoAccording to the recent weekly release, they are 1-2 weeks before Go 1 release: http://weekly.golang.org/doc/devel/weekly.html#2012-03-13 http://weekly.golang.org/doc/devel/weekly.html#2012-03-13
- eternalban 15y ago> And gofix, while nice, isn't really a substitute for language and standard library stability I agree with you in principle but practically, gofix (+ gofmt) it is pretty darn close. I revisited a Go project that I wrote back when it first came out (in other words, an ancient one :). Biggest pita was dealing with the 'error' changes that gofix couldn't fix (and some minor pain due to time and Duration), but everything else was taken care of by the tool. In any event, my understanding is that the Go authors will strategically depend on gofix to deal with language evolution (beyond "Go 1"). I've been coding since '82 and have had my share of PLs. Go is a serious contender and I highly recommend it to anyone looking for a "modern" C.
- georgemcbay 15y agoAs someone who is 38, and has programmed in everything from 6510/68k/MIPS/ARM assembler to C/C++ to ActionScript/haxe/JavaScript to D to Python, et al, I also think Go is pretty great. In addition to the cool things in the language, I really love what they are doing with the build system. The Go programming I've been doing has been on Windows but targeting an ARM CPU (the PXA168 in the Chumby 8 device) and cross-compiling Go code requires simply setting a couple of environmental variables. Sooo much nicer than having to set up a full-on GNU-style cross-compiling setup and using different toolchains for all your different targets. eg: set GOOS=windows set GOARCH=386 go build Just built my project for Windows x86. --- set GOOS=windows set GOARCH=amd64 go build Just built my project for Windows x64 --- set GOOS=linux set GOARCH=ARM set GOARM=5 go build Just built my project for the Chumby device. --- I highly recommend checking Go out and looking past any of the superficial allergies you have to it (I'm historically a braces-on-their-own-line guy, so getting used to the strict enforcement of the other style was a pain for me) and giving it at least a few weeks to sink in. If it still isn't your cup of tea after that, then that's fine, but it is well worth a look, IMO.
- tedunangst 15y agoWindows port details? I start at golang.org, link to http://golang.org/doc/install.html http://golang.org/doc/install.html. Says "A port to Microsoft Windows is in progress but incomplete." That in turn links to the world's least helpful wiki page: Page "WindowsPort" Not Found. Where do I find out more about the Windows port?
- enneff 15y agoGo 1 is about to be released. See the install docs for Go 1 at http://weekly.golang.org/doc/install http://weekly.golang.org/doc/install - these include windows instructions.
- tedunangst 15y agoThanks. If I was somehow supposed to know about the weekly site, I failed.
- joe_the_user 15y agoHmm, The complaint I see here seem to be about c/c++ libraries. TL;DR; c is too level and boost sucks (ie, is too complexified). Go sounds like one fine answer to this. I would claim that c++ with QT is another answer to this. Write parsers for DSLs quickly and easily with QT - its container classes work without nightmarish overtemplating, its string class is like an ordinary class, etc.
- nakkiel 15y agoThat's funny. On my resumé, I always word it as "C++/Qt" because C++ with Qt is no more complicated than Python for most things (well at least it was so a couple of years ago).
- rplnt 15y agoI've used glib for some "string and network stuff" with C and was quite happy. http://developer.gnome.org/glib/2.30/ http://developer.gnome.org/glib/2.30/
- briancurtin 15y ago> The first thing I immediately noticed is that they got rid of the parentheses in "if" and "for" statements. Coming from Python, I really like this. Python doesn't enforce any parenthesis in those statements, so how were you using them in Python that changes how you'd do the same thing in Go?
- andrewflnr 15y agoI assume he likes it because it doesn't change anything. He's used to the Python way.
- briancurtin 15y agoMaybe I'm missing something, but "they got rid of the parentheses" sounds like either Go used to require parentheses for this or he thought Python did. If it was the former, then I misread (I don't know very much about Go).
- deleted 15y ago[deleted]
- ek 15y agoI really like most things about Go, and was even going to use it for a bytecode interpreter project I was working on. A problem that I ran into, however, was that in interpreting a dynamic language with a stack machine, we needed a way to be able to store arbitrary data in stack values, which in C/C++ would be done using a struct with a type flag and then a union of various types. Go doesn't have unions, though, and so this means that we would have ended up using a struct and using about 3x the memory on average, per stack value. You can see this limitation exposed as well in goyacc, the port of Yacc to Go (as the name suggests). Where Bison uses a union for yylval, Go is forced to use a struct. I think this has been discussed on the golang-nuts mailing list a couple times and dismissed, for reasons of which I'm not fully aware.
- chmike 15y agoUnions is a problem for garbage collectors. It is difficult to know if it contains a reference or a value. Though Go should have a solution for your use case. The only one I see is polymorphism. Thus a stack of references to different instances of the same class.
- ootachi 15y agoDiscriminated (type-safe) unions like ML and Haskell have are no problem for garbage collectors: you simply assign one ID to each variant of the union, and prefix the data with the ID corresponding to the variant in use. You can simulate ML-style unions in Go with interfaces and downcasts, or the reflect package (basically like case classes in Scala, but without the exhaustiveness checking). Unfortunately, downcasts in Go (and interfaces generally) are slow.
- jkn 15y agoCouldn't you use an empty interface to store arbitrary values? From the tutorial: Every type implements the empty interface, which makes it useful for things like containers. Unions are on the roadmap: http://golang.org/doc/devel/roadmap.html http://golang.org/doc/devel/roadmap.html but it's a list of ideas rather than features promised.
- chmike 15y agoI looked at its serializing documentation and I was surprized to see that every floating point value is serialized to a double precision value. There are now four types of foating point values and this simplification is downgrading the capabilities of data tranfer. Extended is needed in some scientific computations. Appart from this, the base type encoding is great. The other weird choice is the structure encoding with field numbers and omitting null value fields. My impression is that this is less efficient than coding the null fields. Is this choice based on measurements ?
- fdb 15y agoHow would you call foreign functions in C or C++ from Go? Is there something like a foreign function interface?
- justincormack 15y agoYes there is a C ffi. Not that well documented last time I looked, but you can look at the source of the standard libraries for examples.
- jkn 15y agoFrom http://blog.golang.org/2011/03/c-go-cgo.html http://blog.golang.org/2011/03/c-go-cgo.html : package rand /* #include <stdlib.h> */ import "C" func Random() int { return int(C.random()) } func Seed(i int) { C.srandom(C.uint(i)) } So calling C functions from Go is very easy. However the other way is not supported, AFAIK.
- luriel 15y agoCalling Go from C is supported, but is not quite as straightforward. You can also use SWIG.
- genbattle 15y agoGo has utility called CGo that allows you to create interfaces to C libraries in Go. I've heard you can use some magic to get Go to talk to C++ by exporting functions back to C somehow (disclaimer: I'm not a C/C++ person).
- jstepien 15y agoI couldn't sacrifice performance (lots of number crunching was involved with costs tight), so, I couldn't pick Python. PyPy, Cython or Shed Skin might have been answers to those number crunching problems. I'd love to learn whether they would be sufficient for OP's performance requirements. Some benchmarks look promising, for instance this one published in late 2010: http://geetduggal.wordpress.com/2010/11/25/speed-up-your-python-unladen-vs-shedskin-vs-pypy-vs-c/ http://geetduggal.wordpress.com/2010/11/25/speed-up-your-pyt...
- jwr 15y agoSupport for Unicode as a groundbreaking language feature? Closures (and first-class functions) as a major achievement? I don't want to sound smug, so I won't mention any languages I'm comparing to — but seriously, unless you've been living in Python-land, those things are nothing to write home about. I'm surprised this is getting so many upvotes. If I were to praise Go, I would concentrate on something innovative — concurrency primitives are interesting, for instance. I would not consider them sufficient for all applications, but they are intriguing and worth discussing.
- saulrh 15y agoClosures and first-class functions aren't an achievement. Closures and first-class functions in a language low enough and fast enough level for systems programming? That's an achievement. Same for unicode. These aren't just features. These are features done fast.
- unlogic 15y agoLisp has been having all these for five decades now and those features are done fast. http://shootout.alioth.debian.org/u32q/benchmark.php?test=all&lang=go&lang2=sbcl http://shootout.alioth.debian.org/u32q/benchmark.php?test=al...
- jff 15y agoSo much for Lisp as the ultra-expressive, compact language, I guess... Impressive speeds, though.
- unlogic 15y agoWell, the link to the shootout statistics is probably not the best demonstration for Lisp speed/memory consumption/SLOC count relation. If you look into the Lisp sources there you will see that there are lot of things precompiled for the sake of reducing the execution time. Here's where the extensive memory usage and source size come from. I intended to say that Lisp's and Go's both performance and succinctness in the wild are probably on par. But Lisp is already there for a long time.
- andrewnez 15y agoIncidentally we're hosting a free "Evening with Go" tomorrow night in London: http://eveningwithgo.eventbrite.co.uk/ http://eveningwithgo.eventbrite.co.uk/
- Aqueous 15y ago"And, the worst problem I faced was of sockets. Non-blocking, multi-plexed and cross-platform socket support with C is basically non-existent (unless I wanted to use libev or libevent," What are you talking about? Most every single evented io library out there just boils down to a single system call in the underlying language - C: epoll(or select, poll, or kqueue) on socket/file descriptors. You do know that socket() returns a socket, which is actually just a file descriptor, right? You don't need libev and libevent because you can just write your own in two seconds with epoll! And if you're really attached to having the library handle the work for you you can always use one of the many cross-platform event libraries, like Glib which, last I checked, works on Win32, Mac, and Linux.
- deleted 15y ago[deleted]
- sigzero 15y agoInside a function, the := short assignment statement can be used in place of the short var declaration. (Outside a function, every construct begins with a keyword and the := construct is not available.) === Why is that? I would find that frustrating and inconsistent.
- prtamil 15y agoIs the Author is 13 years old. When did he really start programming.? just wondering After 16 years of programming experience still not able to decide which language is best. At last Settled for C and Common Lisp. But still have Doubts. As per Personal Experience Both Language is more than enough for me.
- prtamil 15y agook guys,, Let me print my wisdom, "Its not the programming language its You,its always you"
- observer1 15y agoIf you are going to create a headline that ends with ", period." the content of the article had better contain a cohesive and very strong argument that supports the emphasized statement. You could have easily posted - "Go is amazing." That is a statement of opinion -- which pretty well describes the article and the author's place as an expert. "Go is amazing, period." claims something much deeper, which the article completely fails to deliver.
- namidark 15y agoSo he recommends Go but has never actually used it? The only reason he looked at it again was the potential to use it for a small project he never finished or did I miss something?
- Osiris 15y agoMy background is in garbage-collected languages, including .NET and PHP. Because of my lack of background in manual memory management, I've always been nervous to try to learn C, even when it may be a better approach. Go sounds like a great language for someone with my background to be able to work with a closer to the metal language but by handling some of the more difficult aspects of working with C like memory management and pointer arithmetic.
- nsomething 15y agoGo needs Allman style. It's unnatural to me otherwise