Live data from Hacker News

My Opinionated Guide To Go

blog.hackingthought.com

11–20 of 73 posts

Re: My Opinionated Guide To Go

#11

Have noted this 'opinionated' trend going for quite a while, so this comment isn't about this article in particular, but can someone break down why an opinionated guide to something technical would be preferable to an impartial one? The only thing it seems to imply is that bias adds value in its own right.

It's a pre-emptive disclaimer "I know this isn't objective, don't complain about that". And it tells you that the guide isn't going to offer you confusing choices, it's going to tell you one way to do things. For some people that's an advantage.

Re: My Opinionated Guide To Go

#12

Not entirely on-topic, but the mention of the various language "stacks" at the beginning of the article reminded me of something I've been wondering. Why does the de facto standard for web apps in Go-land seem to be using the built-in HTTP server provided by net/http, or otherwise having the program server as its own HTTP server? Most other languages seem to have converged on FastCGI or some similar model ({W,P}SGI,…

Well, I think one answer if that you can quickly have a running web app without another piece of software. This is an attractive quality of Node, too. In fact, if a language doesn’t have a “5 lines to a web app” demo, I consider it insufficient.

I’d posit that 90+% of apps don’t need another http server. Big apps have good reasons for a dedicated http server – unifying SSL termination, load balancing – but they are a minority.

There is nothing to to prevent you from putting nginx in front of the Go app if that’s better.

Re: My Opinionated Guide To Go

#13

Not entirely on-topic, but the mention of the various language "stacks" at the beginning of the article reminded me of something I've been wondering. Why does the de facto standard for web apps in Go-land seem to be using the built-in HTTP server provided by net/http, or otherwise having the program server as its own HTTP server? Most other languages seem to have converged on FastCGI or some similar model ({W,P}SGI,…

I guess it's because the HTTP module works out of the box and you can still have the dedicated HTTP server using a reverse proxy like Nginx.

Re: My Opinionated Guide To Go

#14
post #3

I just wish Go would let me compile and run with a flag -allowing- unused imports. I find myself wasting a lot of time hunting down unused imports or variables and commenting them out. Maybe that'll be a non-issue the more I use Go, but so far it's a bit of a time waster.

https://github.com/bradfitz/goimports

To explain to those who may not know what's going on here:

Go forbids importing modules that you then don't use in the source code. This is particularly annoying with the "fmt" module, which contains things like Printf that are useful for debugging, but you may only be using fmt.Printf for one debugging statement in the code. Consequently, if you're developing, and you're adding and removing it over and over you also have to add and remove it to and from your import list over and over, which is very annoying since it's likely to be relatively distant from your use location, and it's mandatory that all imports are listed at the top of the file. (So, you can't do what you can do in perl and say "use Data::Dumper; print Dumper($debugging_stuff);" all on one line, without even being concerned about whether Dumper may already be imported.)

goimports is a source filter that cleans out any unused modules, and tries its best to add modules that you only reference. It's pretty good. You can confuse it if you have two modules with the same last bit of the name, but the standard library doesn't have that anyhow, and for the most part you can deal with that. Since it also runs gofmt for you on save, it's also a drop-in replacement for gofmt, which you should configure your editor to run on every save even if you for some reason don't want the goimports functionality. (Seriously. Just do it. There's no excuse not to. There's no excuse to ever commit code that was not gofmt'ed.)

If you do that, the problem goes away. Typing "fmt.Printf" pulls fmt in automatically, removing the one line removes it automatically, the import list is always accurate, and it's smart enough that if it isn't the only usage it doesn't remove it.

That said, I also strongly recommend setting up automatic syntax checking by compilation (flymake in emacs, don't know what in vim, etc), so that you also avoid the "Save -> switch windows to terminal -> compile -> get smacked in face with an error that feels stupidly persnickety" psychological torture. If the errors highlight in your editor on save or something, you go through that much less. Those who lived in the C#/Java etc world have long had this... a lot of people coming from the scripting side would be advised to pick up a bit more of the helpful tools the static side has to offer.

Re: My Opinionated Guide To Go

#15
post #5

Why does this article only compare Go with interpreted languages at the top? Go is a compiled language; wouldn't it be more fair to compare it with other languages that can be compiled, like C++, Rust, Haskell, or Lisp/Scheme? I mention this because the article acts as if getting rid of abstraction layers between the OS and the code is a new idea. No, that's how all compiled languages are... that's the point of compi…

Well to be fair it does mention Java (though the deployment model expressed is, shall we say, Byzantine).

Java, while compiled, isn't compiled to machine code, and the bytecode to which it is compiled is run on a virtual machine. For this reason, I consider Java more of an interpreted language than a compiled language per se.

Re: My Opinionated Guide To Go

#16
"Go: Code -> Operating System -> Hardware"

Is there any reason to use RVM, PVM on production while Go does not required one?

I believe should be install one and only one Ruby/Python version on production.

Why Ruby/Python does not required application server like unicorn/wcgi, etc?

The article clearly try to make other deployment more complicated.

Re: My Opinionated Guide To Go

#17

Have noted this 'opinionated' trend going for quite a while, so this comment isn't about this article in particular, but can someone break down why an opinionated guide to something technical would be preferable to an impartial one? The only thing it seems to imply is that bias adds value in its own right.

I see value in educated opinions. For instance a while back I was trying to figure out how to make a web app in Python (keep in mind that, while I can program, I have zero knowledge about web things). This is what I saw: https://wiki.python.org/moin/WebFrameworks

Which framework is the best? Why are there so many? Which is the easiest for my specific goals? An opinionated guide that said something like "Use Flask because X" or "Use Django because Y" would have been pretty useful.

Re: My Opinionated Guide To Go

#18

Not entirely on-topic, but the mention of the various language "stacks" at the beginning of the article reminded me of something I've been wondering. Why does the de facto standard for web apps in Go-land seem to be using the built-in HTTP server provided by net/http, or otherwise having the program server as its own HTTP server? Most other languages seem to have converged on FastCGI or some similar model ({W,P}SGI,…

Custom windows servers that do failover and interceptor pattern at the same time. Try that with IIS without pulling your hair out.

Re: My Opinionated Guide To Go

#19

Earlier quoted context omitted.

Well to be fair it does mention Java (though the deployment model expressed is, shall we say, Byzantine).

Java, while compiled, isn't compiled to machine code, and the bytecode to which it is compiled is run on a virtual machine. For this reason, I consider Java more of an interpreted language than a compiled language per se.

There are quite a few comercial JVMs with native compilers the HN crowd tends to ignore.

Re: My Opinionated Guide To Go

#20

Not entirely on-topic, but the mention of the various language "stacks" at the beginning of the article reminded me of something I've been wondering. Why does the de facto standard for web apps in Go-land seem to be using the built-in HTTP server provided by net/http, or otherwise having the program server as its own HTTP server? Most other languages seem to have converged on FastCGI or some similar model ({W,P}SGI,…

"Most other languages seem to have converged on FastCGI or some similar model ({W,P}SGI, Rack, etc.)."

The languages you are citing are slow enough that the scripting language would like to slice away as much of the brute web serving load as possible so the slow scripting language can concentrate its power on the real task at hand.

Go is more on the compiled side. It's not C-fast quite yet (I expect it to eventually converge somewhere around 1.5x as fast, it's not quite there yet), but currently around 2-3x slower only (and net/http is seeing a lot of direct work on it, it's quite fast now). You don't get the big win that you get with letting nginx handle the brute string manipulation of HTTP and prechewing on it for the 20-100x slower scripting language.

Also, remember that you can view HTTP itself as a form of CGI request... really, FastCGI etc. doesn't do anything that an already very multi-threading-friendly language can't do with straight HTTP. Those standards are solving a lot of problems that Go just doesn't have, and straight HTTP is actually more general and flexible if you can afford it (no problems with Nginx being unable to stream FastCGI, etc).

Post reply on HN