Live data from Hacker News

Four days of Go

evanmiller.org

141–150 of 187 posts

Re: Four days of Go

#141
post #8

no ternary is a smart move tho. makes code more readable for all skill levels.

I'm completely baffled that people find the ternary operator difficult to scan. The concept is simple. The syntax can be terse, but it doesn't have to be. Modestly capable Excel users take advantage of something just like it. The only time I've ever seen it become difficult is when either the conditional or result expressions get hairy or depend on undescriptive variable names. And when that's the case, well, you're…

It's not a cargo cult thing, it's inherited wisdom borne out by painful experience. Like goto and braceless single-expression blocks they are so easy to misuse that they can easily be much more trouble than they're worth.

Simple ternaries can be useful in trading off the unreadability of verbosity for the unreadability of compactness. Real Programmers should know how and when to use them. But nested ternary expressions are basically trolling...

Re: Four days of Go

#142
post #68

Earlier quoted context omitted.

I agree with a lot of these (and would be interested in adopting a language that followed them - but one with a decent type system), but I don't think that's the Go innovation. Python had opinions about whitespace and never attracted the same level of hate.

Python's whitespace has arguably produced metric tons of heated discussion on the net since Python's inception. Back in the day it was often the main thing outsiders (jwz comes to mind) rejected.

That and also, that Python has a very Go-like attitude of "do it our way, no, your way has been disabled, our way is the only way."

Arguably, that also explains its success.

Re: Four days of Go

#143
post #45

Earlier quoted context omitted.

> Go makes coordinating with them a lot easier. What I like about strongly opinionated languages in general is that most of the strong opinions are around trivial features of the languages relative to the complexity of a decently interesting programming problem. Features like formatting, no unused imports, etc. These are typically areas in a project where Parkinson's Law of Triviality rears its ugly head in project p…

I'd also say that many of these things are trivially fixed in other languages using tools. Most big projects have some code style guidelines which can be enforced using a linter and any good Java IDE can auto-clean imports lists for you at commit time (IntelliJ can be configured to auto-optimise imports just before commits for instance). Making the compiler super strict about it seems like a good way to make quick ch…

Both Eclipse and IntelliJ have supported cleaning up imports and running style tools on every save for years.

I have no idea why this would be a core part of any language.

Re: Four days of Go

#144
post #92
post #68

Earlier quoted context omitted.

I agree with a lot of these (and would be interested in adopting a language that followed them - but one with a decent type system), but I don't think that's the Go innovation. Python had opinions about whitespace and never attracted the same level of hate.

I think Python's mandatory whitespace has a similar nature as Go's unused-as-an-error. They are definitely great in production code, but when I play with code, sometimes I do want to mess them up while adding and removing the parts of the code. Even though I've used Python for more than 10 years, I often feel like "I don't want to indent these lines for now. I wish there were a way to wrap them up without changing th…

Your editor can indent / dedent whole regions of code with just a few keystrokes. If this is not true, find another editor.

Re: Four days of Go

#145

Earlier quoted context omitted.

> I suspect will get resolved much more quickly and cleanly It's pretty easy. You just add this line to your Cargo.toml: hyper = "0.3.14" And the next time you build, Cargo handles everything. You can now use hyper like any other library that's included with Rust, no biggie. This is one reason we've chosen minimalism for the standard library: It's really easy to use external libraries, and once things land in the sta…

no. there is a HUGE difference between std lib and third-party libs. Std lib is like a contract - maintainers of language have to keep all parts up to date and working. Maintainers of third-party library can write "Farewell Rust" blogpost and all projects, based on that library will be in trouble. And as http is a very important thing for web-programs, it's much better to see support of http in std lib.

I would argue that Rust's approach is perfectly fine so long as they have strong organisational support around third party libraries. Look to Java for how to do this. Many core Java libraries are managed by Apache or Eclipse e.g. HTTPClient who manage the process around open source projects.

HTTP clients are not something I would want in a standard library to be honest. Since there are so many different ways to implement them. And not all work for all use cases. It's not the same as StringUtils or ArrayUtils.

Re: Four days of Go

#146
post #77

Earlier quoted context omitted.

> unless of course you're a masochist and ... want static typing Some people say to prototype in a dynamically-typed language and then switch to a static language later. Dynamic typing might save keystrokes, but typecasting and type-checking do require lots of typing, and who cares that much about a few hundred extra keystrokes anyway? Some people say to create whole, large apps in dynamically-typed languages, but th…

I think you left off the key part of his point, namely "when recursively parsing unknown json data structures". json parsing in Go uses reflection, which not only means it is slow, but if your input is not consistent (like say.. a log file with 20 different possible formats), it can be quite painful and very verbose.

Do you have any resources demonstrating that JSON parsing in Go is slow?

Re: Four days of Go

#147

Earlier quoted context omitted.

no. there is a HUGE difference between std lib and third-party libs. Std lib is like a contract - maintainers of language have to keep all parts up to date and working. Maintainers of third-party library can write "Farewell Rust" blogpost and all projects, based on that library will be in trouble. And as http is a very important thing for web-programs, it's much better to see support of http in std lib.

> Std lib is like a contract - maintainers of language have to keep all parts up to date and working. Rust has language stability (in practice right now, and officially once we hit 1.0 in a month), so we in fact do guarantee this. > Maintainers of third-party library can write "Farewell Rust" blogpost and all projects, based on that library will be in trouble. Languages can do that too, in which case the entire langu…

Hmm... Windows has part of a HTTP stack in the kernel, which I know solely based on hearing about the recent vulnerability in it. And OS X's kernel, IIRC, can load disk images over HTTP for netboot purposes. That leaves Linux as the odd one out :)

(Yes, I know that's completely tangential to the point you're making.)

Re: Four days of Go

#148

> It’s also worth mentioning that you can get Go-style M:N concurrency model in C by using Apple’s libdispatch. Not so fast. That library is only available for OS X and FreeBSD.

There are ports:

Linux: https://github.com/nickhutchinson/libdispatch

Windows: https://github.com/DrPizza/libdispatch

Re: Four days of Go

#149
post #92

Earlier quoted context omitted.

I think Python's mandatory whitespace has a similar nature as Go's unused-as-an-error. They are definitely great in production code, but when I play with code, sometimes I do want to mess them up while adding and removing the parts of the code. Even though I've used Python for more than 10 years, I often feel like "I don't want to indent these lines for now. I wish there were a way to wrap them up without changing th…

Your editor can indent / dedent whole regions of code with just a few keystrokes. If this is not true, find another editor.

But then again, unfortunately, Python's significant whitespace makes automatic indentation hard, because there are some edge cases that an editor cannot extract the actual intention by the programmer well. For example, if there is a code as:

  for i in range(10):
      if i % 2 == 0:
          print('hello')
and I paste `print('world')` after that, there are at least three possibilities of the proper indentation of the line. It can match with `print('hello')`, or with `if`, or even with `for`.

That's because Python encodes block information solely using whitespace. So, if the indentation changes, the actual meaning of the code also changes! In fact, that's why it is called "significant". You cannot automate it, just like you cannot automate writing code.

Re: Four days of Go

#150
post #92

Earlier quoted context omitted.

I think Python's mandatory whitespace has a similar nature as Go's unused-as-an-error. They are definitely great in production code, but when I play with code, sometimes I do want to mess them up while adding and removing the parts of the code. Even though I've used Python for more than 10 years, I often feel like "I don't want to indent these lines for now. I wish there were a way to wrap them up without changing th…

Your editor can indent / dedent whole regions of code with just a few keystrokes. If this is not true, find another editor.

[deleted]
Post reply on HN