8,634 karma · joined Jun 23, 2011 (15y ago) · 7,679 submissions
comment 2y ago · link · parent
Toggle switches are for giving instructions to a machine. Programming languages are a higher level abstraction over the toggle switches so that the intent of the toggling can be communicated with other people. You don't just write code, run it through the machine, and then throw it away. Other people, and probably even yourself, will read what was written again and again and again. The language is very much for people first and foremost, with the side effect of also being understandable by machine.
> I think it is just a bad language.
It is – nobody is suggesting otherwise – but you didn't answer the question. Are you writing Go with Go syntax, or another language with Go syntax? Perhaps the best way to answer, if it is that you just didn't know how, is to post some sample code that you find to be obnoxious and tedious and we can see if it is that way because of Go, or if it is because you are trying to use patterns from other languages that don't fit the language.
comment 2y ago · link · parent
Realistically, there is no such thing as a wrong choice, only different tradeoffs. I assume "wrong" here means wishing you made different tradeoffs later on. But will you feel real consequences if that happens, or just a casual feeling of "I wish I'd have done it differently, but oh well" in passing?
> What limitations do either of them have when scaling?
What, specifically, are you trying to scale? What scale-related problems do your customers have?
Do you even have a product yet? If no, perhaps the best tradeoff you can make right now is the one that compels you to get started instead of worrying about it? Ask yourself: Will you be more apt to actually build it if you choose Go, Rust, or perhaps with another tool entirely? It doesn't matter if X is the unquestionably best choice if you never get around to using it.
You might still want to be mindful of what risk there may be. I expect you can tell me what risks there are if you chose Brainfuck, and I expect you would tell me that is a risk too great. But, without understanding your problem in depth to know what nuance needs to be considered, there is probably no meaningful risk difference between Rust and Go.
comment 2y ago · link · parent
Legend has it that Go was conceived while waiting for a C++ program to compile, if that's what you are thinking of?
comment 2y ago · link · parent
But I'm not sure it matters. Go was created to test the theory, not because a theory was proven. It didn't have to be successful. It may be that the studies didn't happen even within Google, although that is our greatest chance. We do know Google actually cares about data, unlike programmers.
That said, since Go was released it seems every other language has tried to copy it with their own twist, so while that may not come from a place of evidence, it would appear that the feeling of increased productivity[1] was felt.
[1] Or something adjacent. Focusing on engineering isn't necessarily about productivity. You can't discount productivity, but it is not the top engineering concern, especially in a place like Google.
comment 2y ago · link · parent
This is the exact same thing, except in addition to the tag there is also a data component. Yes, this is the more traditional representation of sum types, but having an "undefined" data component is still identifiable as a sum type. It is the tag that makes the union a sum type.
In Typescript terms, which I think illustrates this well, it is conceptually the difference between:
{ kind: 0 } | { kind: 1 }
and { kind: 0; data: T } | { kind: 1; data: U }
Which is to say that there is no difference with respect to the discussion here.> They are an enumeration of discrete values
Yes, the "tag" is populated with an enumerator. There is an enumerator involved, that it is certain, but it is outside of the type system as the user sees it. It's just an integer generated to serve as an identifier – an identifier like seen in the above examples – but provided automatically. The additional information you can gain from it, like exhaustive matching, comes at the type level, not the number itself.
> Rust conflates the 'enum' keyword with sum types.
Right, because it too uses an enumerator to generate the tag value. Like Ord(foo) before, you can access the enumerated in Rust with something like
mem::discriminant(&foo)
The spoken usage of 'enum' in Rust is ultimately misplaced, I agree. An enumerator is not a type! But it is not wrong in identifying that an enumerator is involved. It conflates 'enum' only in the very same way you have here.comment 2y ago · link · parent
Do people actually care that much about languages? I mean, we're here writing English, which is a complete dumpster fire. Go is undeniable perfection compared to the horror that is English. Clearly you and I don't care that much about languages.
I expect people like Go because of its tooling (what also saves English), which was a million miles ahead of the pack when it first came out. Granted, everyone else took notice, so the gap has started to narrow.
> It feels like it fights any attempt at using it to do things optimally or quickly.
Serious question: Is that because you are trying to write code in another language with Go syntax? Go unquestionably requires a unique mental model that doesn't transfer from other languages; even those that appear similar on the surface. Because of that, I posit that it is a really hard language to learn. It is easy to get something working, but I mean truly learn it.
While every programming language requires its own mental model, Go seems to take it to another level (before reaching a completely different paradigm). I expect that is because its lack of features prevents you from papering over "misuse" like is possible in other, more featureful languages, so you feel it right away instead of gradually being able build the right mental model.
comment 2y ago · link · parent
The purpose of creating yet another language with Go was to break from what everyone else was doing, to see if a "simple" language would stop developers from playing with fun language toys all day to instead focus on actual engineering.
Arguably it was successful in that.
comment 2y ago · link · parent
Normally in Pascal you would not match on the enumeration at all, but rather on the sum types.
type
Foo = (Bar, Baz)
case foo:
Bar: ... // Matches type Bar
Baz: ... // Matches type Baz
The only reason for enumerations in Pascal (and other languages with similar constructs) is because under the hood the computer needs a binary representation to identify the type, and an incrementing number (an enum) is a convenient source for an identifier. In a theoretical world where the machine is magic you could have the sum types without enums, but in this reality...Thus, yes, in practice it is possible to go around the type system and get the enumerated value out with Ord(foo), but at that point its just an integer and your chance at exhaustive matching is out the window. It is the type system that allows more flexibility in what the compiler can tell you, not the values generated by the enumeration.
> Go only has enums by convention
"Enums by convention" would be manually typing 1, 2, 3, 4, etc. into the code. Indeed, that too is an enumeration, but not as provided by the language. Go actually has enums as a first-class feature of the language[1]. You even say so yourself later on, so this statement is rather curious. I expect you are confusing enums with sum types again.
[1] Arguably Pascal doesn't even have that, only using enums as an implementation detail to support its sum types. Granted, the difference is inconsequential in practice.
comment 2y ago · link · parent
comment 2y ago · link · parent
The term you are looking for is sum types (albeit in a gimped form in the case of Pascal). Enumerations refer to the value applied to the type, quite literally, and is identical in Pascal as every other language with enumerations, including Go. There is only so much you can do with what is little more than a counter.
comment 2y ago · link · parent
Go calling convention is that you have to assume T is invalid, unless proven otherwise, because we know there are developers who have no business being developers that will screw you over if not careful. The Go style guide promotes documenting in a function comment that your function does return a valid T so that users don't have to guess about whether or not you are competent.
But the convention on the function authoring side is to always ensure T is valid. Just because others shouldn't be writing code does not mean you need to be among them.
As Go promotes limiting use of third-party packages by convention, as a rule most of the functions you call are going to be your own. So most of the time you can be sure that T is valid, regardless of error state. Yes, sometimes you are forced to rely on the error, as we discussed already in earlier comments. Such is life.
comment 2y ago · link · parent
Only in the same way that a cook that has spent his career in an Italian restaurant doesn't have expertise in cooking Chinese food. An employer on the hunt isn't going to care about such trivial differences (HR box tickers might, but crypto startups probably don't have that).
Granted, I can understand why you'd be leery about working at such places.
comment 2y ago · link · parent
You can. But making radio waves does not imply a broadcast. At least not in the traditional sense. I'll grant you that colloquially we have sometimes come to refer to any radio transmission as a broadcast, but that is not the usage here.
> BUT, if you don't know you are making radio waves are you still a broadcaster?
If you didn't know a chicken emerged from an egg, is it still a chicken? My experience with young children who don't yet understand that process would say yes. No doubt there are career radio broadcasters out there who are not familiar with the science of radio.
It's not about not knowing of the existence of something, though. We know the chicken came from an egg. We just don't know what kind of egg it was. Was it a chicken egg or was it a flibberdoodle egg? If it was a chicken egg, how did the flibberdoodle lay a chicken egg? If it was a flibberdoodle egg, how did a chicken come out?
comment 2y ago · link · parent
I'm not sure that is analogous. The chicken/egg question is about at what point we started identifying an egg as being a chicken egg as opposed to being an egg from another animal. In other words, did the first chicken egg come from a chicken (meaning the chicken came first), or from a proto-chicken (meaning the egg came first)?
A closer variation might be: Which came first, the radio broadcast or the radio broadcaster? Before the radio broadcast and radio broadcaster there was radio and people using radio, but they did not reach a wide public audience. At some point the early small-scale experimental radio use turned into broad utilization, but when and which was earlier on the timeline?
comment 2y ago · link · parent
Anyway, the veracity of that legend doesn't matter, but it is here merely to illustrate the idea that perhaps we subconsciously build our roads on lines that chickens won't cross, rather than them being aware of the road?
comment 2y ago · link · parent