Live data from Hacker News

From zero to Go: launching on the Google homepage in 24 hours

blog.golang.org

41–50 of 78 posts

Re: From zero to Go: launching on the Google homepage in 24 hours

#41

I can't help but cringe whenever I read Go code because the following: paths, err := filepath.Glob(dir + "/*.png") if err != nil { panic(err) } is repeated over and over again. Didn't we learn in the 90's that exceptions are far, far superior to return codes?

Bruce Eckel on exceptions and Go: http://www.artima.com/weblogs/viewpost.jsp?thread=331407

Re: From zero to Go: launching on the Google homepage in 24 hours

#42

I really liked the turkey, and I thought the solution looked elegant, so I had a go at it in CoffeeScript and node-canvas: https://gist.github.com/1475034 All requests in less than 66 ms, mean less than 19 ms.

What was the median response time?

Re: From zero to Go: launching on the Google homepage in 24 hours

#43
post #17
post #12

Earlier quoted context omitted.

Well I'm the guy who runs that particular blog, and I can tell you I'm no marketing guru. While Reinaldo and I edited the post together, I'm pretty sure that the line was in his original text. (Just checked: it was.) Maybe people keep saying Go feels like an interpreted language because it feels like an interpreted language? :-)

I've done a fair bit of Go programming ( https://github.com/jbarham ), but have programmed professionally mostly in Python for the past 10 years, and for me Go does feel an interpreted language because it requires so few type declarations compared to mainstream statically typed languages like C++ or Java. Checking the app source code for the article at http://code.google.com/p/go-thanksgiving/source/browse/app/a... ,…

C++11 has support for inferring types; http://en.wikipedia.org/wiki/C%2B%2B11#Type_inference.

Re: From zero to Go: launching on the Google homepage in 24 hours

#44

I can't help but cringe whenever I read Go code because the following: paths, err := filepath.Glob(dir + "/*.png") if err != nil { panic(err) } is repeated over and over again. Didn't we learn in the 90's that exceptions are far, far superior to return codes?

Reading the same code I also cringed, but for a different reason: the validity of `paths` is tied to the validity of `err`; you should never look at at `paths` without first checking `err`. We can solve this much better using sum types (also known as discriminate unions):

    // Pseudo Go:
    maybe_paths := filepath.Glob(dir + "/*.png")
    case maybe_paths of {
      Some paths: {
        // Do things with paths
      }
      None: {
        // Handle error case
      }
    }
This makes it impossible to use `paths` if `Glob` returns an error, as `paths` won't be in scope!

Furthermore, not having sum types forces us to include a distinguish value `null` for reference (pointer) types, as a way to communicate "no value". This is bad as now we cannot distinguish references that should never be `null` from those than can be `null`.

Re: From zero to Go: launching on the Google homepage in 24 hours

#46

I can't help but cringe whenever I read Go code because the following: paths, err := filepath.Glob(dir + "/*.png") if err != nil { panic(err) } is repeated over and over again. Didn't we learn in the 90's that exceptions are far, far superior to return codes?

A lot of people in this sub-thread don't buy that return codes are inferior, but they really are. The issue is that the low level code can detect the error and knows some strategies that could be done about it but it's only the high level code that knows what's best (here's the best possible approach [1]). If your library is used by a batch job running on some network-detached headless server it will probably have to handle errors differently than a fat client would.

[1] http://www.gigamonkeys.com/book/beyond-exception-handling-co...

Re: From zero to Go: launching on the Google homepage in 24 hours

#47
post #35

This is quite offtopic, but if even programmers are using jpeg when they should use png, what hope is there for anyone else? The images this generates have mostly flat areas of all one color - it should have been a png.

Would the size of the png's be smaller?

Re: From zero to Go: launching on the Google homepage in 24 hours

#48
post #37

Earlier quoted context omitted.

AppEngine instances, unless they're running in a special backend instance, exist in a special containerized machine. These machines are very slow and don't have much RAM - 600 MHz and 128 MB. Based on the source that was posted on the blog, this app was running on a normal instance, as the source did not contain a backends.yaml file. So it makes sense that a Core 2 Duo running at 2.13 GHz and slow CoffeeScript would…

This isn't true any more. They recently announced faster frontend instances with more memory ( http://googleappengine.blogspot.com/2011/12/app-engine-161-r... ), and I'm willing to bet this has been available internally since long before Thanksgiving. I'd bet money that this app used the beefiest class of frontend instances.

Nope, it's just a standard app engine set up.

Re: From zero to Go: launching on the Google homepage in 24 hours

#49
post #41

I can't help but cringe whenever I read Go code because the following: paths, err := filepath.Glob(dir + "/*.png") if err != nil { panic(err) } is repeated over and over again. Didn't we learn in the 90's that exceptions are far, far superior to return codes?

Bruce Eckel on exceptions and Go: http://www.artima.com/weblogs/viewpost.jsp?thread=331407

A lot of those criticisms seem to be based largely on Java - which, with its checked exceptions, is pretty much the worst case in the use of exceptions in a language design.

Re: From zero to Go: launching on the Google homepage in 24 hours

#50
post #30

I can't help but cringe whenever I read Go code because the following: paths, err := filepath.Glob(dir + "/*.png") if err != nil { panic(err) } is repeated over and over again. Didn't we learn in the 90's that exceptions are far, far superior to return codes?

Not really, no. I've always found them more trouble than they're worth. Explicit, in-line error handling works much better for me. I'm not sure what you mean by "over and over again," in this context, though. There are only three error checks of that kind in this program. It's an unusual program anyway, in that _any_ error condition jumps to the same path: displaying the default image. In most programs you want finer…

I doubt that's really the case in proportion to lines of code. Three error conditions handled by one and the same handler doesn't seem unusual at all. Even 10 to 1 or more wouldn't be unusual I believe.

In my view, all attempts at making a distinction between recoverable and non recoverable errors inevitably fail simply because it is a non local distinction that cannot be made for any particular piece of code in isolation.

Post reply on HN