Live data from Hacker News

Go is amazing, period.

poincare101.blogspot.com

131–140 of 241 posts

Re: Go is amazing, period.

#131
post #83

Earlier quoted context omitted.

It does, but for a good reason. Its so the parser can find the line endings without needing complicated rules and look-ahead. Go style is enforced mechanically with gofmt ( http://weekly.golang.org/cmd/gofmt/ ), anyway, so one typically drops the pretension of these kinds of style quibbles. It is more important to have one consistent style than to make everyone happy. The gofmt style forced me to change several of my…

Thanks for answering! I have no idea why someone downvoted your reply. People: downvoting is for mean and/or stupid comments, not things you disagree with. Anyway, in that case I imagine we'll see a Go preprocessor that takes all the line-initial braces and moves them up a break before sending code to the compiler. People get pretty worked up about this stuff.

I work in a place where people don't use spaces and don't use empty lines to separate logical groups of lines. It's a real pain for me who is a code format junkie as our code ends up being an ugly pack of unrelated crap that's really hard to read.

It's Python code and I find it uglier than some fairly large C++ project I used to work on.

Anyway, I wish there was a gofmt in Python because at least, I'd drop all hopes of forging my own rules (silly junkies) and some basic clarity would be forced into our codebase.

I know there are beautifiers but when such things are enforced and not negotiable, it's just so much simpler and people just stop caring as well.

Re: Go is amazing, period.

#132
post #118

How would you call foreign functions in C or C++ from Go? Is there something like a foreign function interface?

Yes 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.

Re: Go is amazing, period.

#133
post #83

Earlier quoted context omitted.

It does, but for a good reason. Its so the parser can find the line endings without needing complicated rules and look-ahead. Go style is enforced mechanically with gofmt ( http://weekly.golang.org/cmd/gofmt/ ), anyway, so one typically drops the pretension of these kinds of style quibbles. It is more important to have one consistent style than to make everyone happy. The gofmt style forced me to change several of my…

Thanks for answering! I have no idea why someone downvoted your reply. People: downvoting is for mean and/or stupid comments, not things you disagree with. Anyway, in that case I imagine we'll see a Go preprocessor that takes all the line-initial braces and moves them up a break before sending code to the compiler. People get pretty worked up about this stuff.

Don't want to make this a big meta discussion, but I noticed that often the best comments are downvoted first, and eventually end up on the the top of the page. Don't worry this type of thing corrects itself.

Re: Go is amazing, period.

#134
post #97
post #89

Earlier quoted context omitted.

Java is type safe, because the language defines clear semantics for what happens when you mutate two memory locations simultaneously (you get one result or the other). Under no circumstances does the program have truly undefined behavior. Java HashMaps aren't thread-safe, but they will just do the wrong thing when you try to access them concurrently. Under no circumstances will the program be able to read or write un…

Incidentally, I've seen unsynchronized access to a Java HashMap cause an infinite loop on .get()s which is (allowably) undefined behavior, and pretty unexpected (see: http://mailinator.blogspot.com/2009/06/beautiful-race-condit... )

There is quite the difference between libraries having undefined behavior if you do not follow their contract and the language.

Re: Go is amazing, period.

#135
post #84

I 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…

Couldn'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 but it's a list of ideas rather than features promised.

Re: Go is amazing, period.

#136
post #118

How would you call foreign functions in C or C++ from Go? Is there something like a foreign function interface?

From http://blog.golang.org/2011/03/c-go-cgo.html :

  package rand
  
  /*
  #include 
  */
  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.

Re: Go is amazing, period.

#137
I 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-pyt...

Re: Go is amazing, period.

#138
post #85

Earlier quoted context omitted.

Nothing in go is silly. There are multiple reasons why it's required. The answer usually given is faster compile times and the removal of semicolons from the language. I don't know the details, but someone new complains about it on the mailing list fairly frequently. Also having a tool enforced brace style is just plain practical. Less silly arguments/bikeshedding. I was also a brace on its own line kinda guy, but be…

What about using two characters for assignment? a := 1 vs a = 1

Having both := and = goes back a long, long, long way. Go isn't even the 100th language to differentiate them.

Re: Go is amazing, period.

#139
post #128

Here'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 a…

It's hard to expect a really detailed analysis from someone still in high school. On the other hand, it is good to see how the various languages look like from a fresh perspective of someone with relatively little preconceptions from years of using C/C++/Python/whatever. After all, if he has lots of problems with writing something in C++, but much less when writing it in Go, it probably means lots of us had at some p…

Please, ignore people's age, it makes people in high school much happier. From someone in highschool (or the UK equivalent), the age anonymity of the internet is one of it's greatest strengths.

I think he'll still have to learn a fair few tricks to get around some features of Go. Things like type assertions, float32 vs float64, get ready for it lack of generics, and no distinction between stack and heap aren't common in other similar languages, and just getting to know the standard library is a huge part of being productive in a language. C could be seen as better in that respect; the core language is _very_ simple, which can't really be said for Go, though the advantages of Go probably out weigh the advantages of C for many people.

Re: Go is amazing, period.

#140
post #72

Earlier quoted context omitted.

What's it like to use a compiled language for a web server?

It'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.

No need to hide it behind nginx or some other dedicated web server.

So, how do you serve static files?

Post reply on HN