Live data from Hacker News

I Want Off Mr. Golang's Wild Ride

fasterthanli.me

311–320 of 508 posts

Re: I Want Off Mr. Golang's Wild Ride

#311

Earlier quoted context omitted.

Isn't the point of OsString that it's essentially a faux-union type that is intended to be immediately converted to some concrete representation which /is/ richly manipulable?

The problem is that this is not good enough. It’s not uncommon to need to do a small amount of manipulation of OsString and there is no good way to do it. In C++, it’s fairly easy. In Rust, it’s a damn nightmare. In theory, in Rust, since OsString is basically Vec on the inside (like String), you could implement e.g. Path::has_extension in the same way as str::ends_with. However, anyone who has gone in and tried to i…

Is that not the point? That you ought to map out that complexity in a type whose constraints must be satisfied in order to have a valid instance?

If your string is invalid to start with and you need to correct it, then yes, you need to wrangle that complexity yourself. If you need some tools from another toolset - eg. String functions that can help you make a valid Path - then you will make multiple type conversion hops to arrive at your destination. But trying to use String methods on something that may not be a valid string is no solution to the original problem, and would merely be hoping you could get away with the assumption.

Re: I Want Off Mr. Golang's Wild Ride

#312
post #83

I think the mistake may be assuming that Go is meant to be a general-purpose language. From what I can tell, it's purpose-built to be a "web services" language, and its design-decisions center around that. What does that mean? - It's expected to be run on Linux servers (not Windows) and developer workstations (probably not Windows). - It needs to be fast but not blisteringly fast. Micro-performance concerns like the…

If the language was meant to be run on unix machines for web services, it shouldn't support anything else in a half-done manner with silent errors and corruption. The situation as it is now is just poor language and/or library design - choosing to support different operating systems with an API that requires the wrong thing to happen in some cases.

If you workstation does happen to be Windows, support-with-edge-cases may be plenty good enough for you to get your work done and if you run into a problem on your dev machine, it's much less of a big deal

Re: I Want Off Mr. Golang's Wild Ride

#313
post #83

I think the mistake may be assuming that Go is meant to be a general-purpose language. From what I can tell, it's purpose-built to be a "web services" language, and its design-decisions center around that. What does that mean? - It's expected to be run on Linux servers (not Windows) and developer workstations (probably not Windows). - It needs to be fast but not blisteringly fast. Micro-performance concerns like the…

Except docker is written in go. Guess they never got the memo to not use go for non-webservices...

Fair, although it has very similar constraints/goals to those listed above

Re: I Want Off Mr. Golang's Wild Ride

#314

> Nine out of ten software engineers agree: it's a miracle anything works at all There was a beautiful rant about a decade ago called something like "everything's broken all the time and nobody cares." The gist of it is that all software is written by people. Anyone who's written software knows that it's usually riddled with hidden corner cases, unfortunate tradeoffs, rushed deadlines, etc. Software is also moving in…

> Software is also moving into critical spaces like aerospace, medicine, banking, etc. The thrust of the article is that we're trusting more-and-more critical infrastructure to a discipline that anyone who's worked in knows is untrustworthy.

"Anyone" who's worked in those industries knows SW can be done in a trustworthy way.

At least not less than other engineering disciplines.

"hidden corner cases, unfortunate tradeoffs, rushed deadlines" in uncontrolled proportions are a symptom of lack of discipline, either originating directly at low level (even if maybe mainly because of cultural influences, but I mean, what is not?), or under pressure from the hierarchy. The same conditions can led to critical failures of other kind of engineering realisations. One key point of critical failures resulting from hierarchy pressure is that it does not absolves the engineers doing the work, and some engineering culture actually recognize and teach that. Other cultures mixe everything in the same pot without even an once of ethics nor serious reliability thinking, and you get people maintaining the myth that software just can't be reliable, that the whole industry - without exception - is in an eternal crisis, and that that's even normal because the field is "young". None of that is true; you even have plenty examples around you, and decades of history to study. And of course, we must remain exigent so that the quality does not decline just because of a kind of self prophecy.

Re: I Want Off Mr. Golang's Wild Ride

#315

Earlier quoted context omitted.

Isn't the point of OsString that it's essentially a faux-union type that is intended to be immediately converted to some concrete representation which /is/ richly manipulable?

The problem is that this is not good enough. It’s not uncommon to need to do a small amount of manipulation of OsString and there is no good way to do it. In C++, it’s fairly easy. In Rust, it’s a damn nightmare. In theory, in Rust, since OsString is basically Vec on the inside (like String), you could implement e.g. Path::has_extension in the same way as str::ends_with. However, anyone who has gone in and tried to i…

[deleted]

Re: I Want Off Mr. Golang's Wild Ride

#316

Earlier quoted context omitted.

I have felt this pain for sure, but only really once. This is because, in languages with strings as paths I tend to use string manipulation to do operations on paths, but given that virtually all of my OsString usage is paths, which have specific manipulation functions already it’s lesser. This is also why the interface isn’t so rich, there just hasn’t been a lot of demand. That said I think some things are in the pi…

Do you have any more info about what's in the pipeline?

I thought that someone had recently sent in a PR adding some convenience functions, but I can't find them now, I must be imagining things :(

Re: I Want Off Mr. Golang's Wild Ride

#317

Earlier quoted context omitted.

C++ has been adding things like optional types; std::optional was released in C++17, there's talk of maybe pattern matching coming soon...

Java has Optional as well, but as you well know, you can't just bolt ADTs onto the side of a language and wash your hands of it. The whole system has to be designed around it to get the benefit of it. Java programmers will be checking for null until the last line of Java is written.

Sure, but the argument was that folks would reject it, when they in fact have explicitly added it. Its effectiveness is another story; not only along the axis you were talking about, but also others, but that's a separate conversation.

Re: I Want Off Mr. Golang's Wild Ride

#318
post #238

Earlier quoted context omitted.

Being unaware of an exception thrown by a function when calling it in Java will cause compilers to bark at you - while doing the same in go will work until it doesn't. I think this is even more insidious with changes in third party code over time though - did the package your gigantic product uses to validate that a phone number is in European time just add an error return value to a function that previously had none…

Go will most certainly notify you if a 3rd party API suddenly returns a new error. Typically you would see an assignment mismatch.

[deleted]

Re: I Want Off Mr. Golang's Wild Ride

#319
post #291

Earlier quoted context omitted.

No, the name is definitely mutable. Consider: x = 1 capture = lambda: x x = 'foo' print capture() If python were just shadowing, this would print 1. But it prints foo.

That's an issue of scoping, not capturing. The x in the lambda isn't scoped to the lambda, it's scoped to the surrounding environment. So the x closes not over the lambda but the outer scope. So it's as expected given shadowing. Edit: Since I'm getting throttled: No, I'm saying that scoping rules are different in python and rust. In Rust (and cpp) there's the concept of scopes/closures as a first class feature. This…

Setting aside any terminology for a second, consider this rust program:

  fn main() {
   let x = 1;
   let capture = || x;
   let x = 2;
   println!("{}", capture());
   println!("{}", x)
  }
This will print 1 and then 2, whereas python would print 2 and 2.

Hence, you can see that the formulation "let mut" is equivalent to python, not "let" followed by "let".

Here's the rust program that prints 2 and 2:

  fn main() {
   let mut x = 1;
   let ptr = &x as *const i32;
   let capture = || unsafe{ *ptr };
   x = 2;
   println!("{}", capture());
   println!("{}", x);
  }
(I had to use unsafe otherwise the borrow checker will complain will I modify x from underneath the closure; maybe a more elegant way to make the same point -- I don't really know rust...)
Post reply on HN