Live data from Hacker News

Four days of Go

evanmiller.org

51–60 of 187 posts

Re: Four days of Go

#51
post #44
post #33

Earlier quoted context omitted.

Goto's create unreadable code and are unnecessary. They're there to encourage the writing of bad code. You can pass a pointer over a goroutine channel. That's my main issue with them, beside the fact that we should be past this needless complication of our code. Again, they're unnecessary and encourage bad code.

No, gotos are present to allow you to use programming paradigms other than structured programming, isolated within the confines of a structure-programming function. The most popular such alternative paradigm that can be written by a human being a finite-state machine, which can be quite clearly and efficiently expressed via goto. Generated code can also get a lot of mileage out of goto, and this is usually code you'r…

I do see a bit of goto use in the PHP community, but it tends to be used by well-known and respected programmers, sometimes just to make the point that goto isn't evil in and of itself.

https://github.com/guzzle/guzzle/pull/965 https://github.com/igorw/retry/issues/3

Re: Four days of Go

#52
post #47
post #33

Earlier quoted context omitted.

Goto's create unreadable code and are unnecessary. They're there to encourage the writing of bad code. You can pass a pointer over a goroutine channel. That's my main issue with them, beside the fact that we should be past this needless complication of our code. Again, they're unnecessary and encourage bad code.

> Goto's create unreadable code and are unnecessary. They're there to encourage the writing of bad code. Goto's are seldom used by bad programmers anyway - most of them wouldn't even be aware of them. They generally exist in languages as a niche feature used be experienced developers for those rare situations where a goto results in cleaner code. You definitely don't see Go developers sprawling goto's everywhere just…

> Goto's are seldom used by bad programmers anyway - most of them wouldn't even be aware of them.

.....yeah.

I've seen too many internal codebases where "goto" was used so horrifically I want that feature to die in a fire just to prevent such malignancy in the future.

Golang only hasn't reached that stage because its young enough there isn't heavy maintenance work over a 10+ year period yet.

Re: Four days of Go

#53
post #33
post #30

Earlier quoted context omitted.

Go's goto is the standard structured-programming-limited goto which is not allowed to violate blocks, which means it is not the goto that is "considered harmful". Go's "pointers" are not allowed to do pointer arithmetic, which basically means that they are references. As they are also backed by a garbage collector, this means you can't do any of the nasty C things you can do with them, not even "fail to deallocate" t…

Goto's create unreadable code and are unnecessary. They're there to encourage the writing of bad code. You can pass a pointer over a goroutine channel. That's my main issue with them, beside the fact that we should be past this needless complication of our code. Again, they're unnecessary and encourage bad code.

Goto's are used extensively in the Linux kernel for clean exits from functions (typically system calls) that must validate parameters, allocating resources as they go, but then abort if there are any errors in the parameters. For example: http://lxr.free-electrons.com/source/kernel/fork.c?v=3.3#L42...

Re: Four days of Go

#54
post #41
post #35

Earlier quoted context omitted.

I find it amusing that people would use the term "incompetence" to describe Ken Thompson and Rob Pike. These two guys have been as instrumental in shaping modern computing as Linus Torvalds, Bill Gates and Steve Jobs. But I guess it's easy to be critical of other peoples output when you're an anonymous internet user yourself.

Sorry, I thought it was clear - incompetence regarding [modern] language design. They don't deny this neither. And it seems they're even proud of this. > when you're an anonymous internet user It is easy to be honest, yes.

[deleted]

Re: Four days of Go

#55
post #41
post #35

Earlier quoted context omitted.

I find it amusing that people would use the term "incompetence" to describe Ken Thompson and Rob Pike. These two guys have been as instrumental in shaping modern computing as Linus Torvalds, Bill Gates and Steve Jobs. But I guess it's easy to be critical of other peoples output when you're an anonymous internet user yourself.

Sorry, I thought it was clear - incompetence regarding [modern] language design. They don't deny this neither. And it seems they're even proud of this. > when you're an anonymous internet user It is easy to be honest, yes.

I don't think your amended statement is much better. They have designed a language that meets their goals. They have decided not to include many things, but that does not mean that they are not aware of them, or are incompetent for doing so.

Re: Four days of Go

#56
> Go basically forces you to have clean code all along, > which is a bit like forcing a scientist to wipe down the > workbench and rinse all the beakers between every experiment, >or forcing a writer to run the spell checker after every cigarette.

As usage of gofmt is idiomatic Go, simply using the superset goimports handles all of this for you.

Sure, any language has tools to reformat code for you in some magic ways - but what makes Go special is that it takes this kind of tooling seriously enough by making it standard right out-of-the-box and right when initiating new users to the language (notice the [Format] button on the first slide of the official Go tutorial http://tour.golang.org/welcome/1 ).

https://github.com/bradfitz/goimports

http://michaelwhatcott.com/gosublime-goimports/

Nevertheless, this new article from Evan is a marvel, a must-read, as usual.

Re: Four days of Go

#58

Earlier quoted context omitted.

Of course - absolutely. No-one disputes that (seriously). The difference ends up being between a 5 line function, which does 5 simple things, and a 20 line function that does 5 simple things. In my previous example, it was 1 line which returned either the name, or 'New Name', or else 5 lines to do the same. In the end, not a big deal. A matter of taste, rather than judgement, I feel.

I suppose one could argue that it's one line actually doing 3 things... but anyway. Not a big deal, at the end of the day.

I guess that means you have to move that logic to it's own go file.

kinda mimics c in that way.

Re: Four days of Go

#59
post #2

In other words, Go represents a kind of Machiavellian power play, orchestrated by slow-and-careful programmers who are tired of suffering for the sins of fast-and-loose programmers. The Go documentation refers quite often to intolerable 45-minute build times suffered by the original designers, and I can’t help but imagine them sitting around and seething about all those unused imports from those “other” programmers,…

An involuntarily funny quote from the article:

> Their solution was not to engage and educate those programmers to change their habits.

I wish the blog author good luck in educating masses of programmers, even smart ones :)

Re: Four days of Go

#60
post #2

In other words, Go represents a kind of Machiavellian power play, orchestrated by slow-and-careful programmers who are tired of suffering for the sins of fast-and-loose programmers. The Go documentation refers quite often to intolerable 45-minute build times suffered by the original designers, and I can’t help but imagine them sitting around and seething about all those unused imports from those “other” programmers,…

Personally, I think people dislike Go because they try using it for tasks where it makes their life miserable. Mainly for web programming. (unless of course you're a masochist and enjoy not having a repl and want static typing and a compilation step when recursively parsing unknown json data structures).

In my experience, Go is a tool thats really good for a certain set of programming tasks and like all other languages really bad or annoyingly painful for others.

For me, Go is my number one tool for creating command line apps now. I get immediate cross-platform cli tools with zero headache. Its also a really nice fit for lower level networking/distributed applications where you are working with byte protocols (things like mozillas heka, or docker, proxy servers, chat clients, etc), the networking server-side stuff where you would probably have used C++/Java.

My recommendation would be, if you work a lot on this kind of software seriously start using Go, you will love it and think everyone is crazy for hating on Go.

The problem is I think lots of people are trying to use Go for stuff it is not designed for and where, compared to the alternatives, it is a rather bad fit. For instance Go is zero fun for: Compiler Programming (Haskell/C++ have way better tooling), Games (libs are one thing but Go cannot compete with C++ perf here), Desktop GUI apps (Just use QT), Mobile Apps, and Web Programming (take your pick of python,ruby,js,clojure,php - your life will be much easier), Hardware/Low Level Systems programming (Obviously you can't use a GCed lang here).

I haven't found another area where I really like programming in Go besides CLI and networking I mentioned above. It could have another sweet spot I've missed...

Post reply on HN