Earlier quoted context omitted.
This has perhaps been my biggest pain-point with Golang.. Woe unto those who do not follow the idiosyncrasies of how golang handles versioning, package management, tooling etc. if this is really your most important part of a language I would whole-heartedly recommend looking at rust which has been a breathe of fresh air in terms of package management and tooling.
Golang has the most hilarious approach to date formatting
Lies we tell ourselves to keep using Golang
531–540 of 561 posts
Re: Lies we tell ourselves to keep using Golang
#532Earlier quoted context omitted.
I've come to the conclusion that, for the most part, option types make no sense in object-oriented languages. There are exceptions, but they tend to fall into "proves the rule" territory. OCaml, for example. Not just because of the null problem. It's also that option types push you toward a "conditional logic everywhere" way of doing things, because that's how you handle the options. That's all well and good and holy…
> it's the opposite of good object-oriented design. So what is good OO design? NPEs? Nil checks?
- nil
- None
- Some(nil)
- Some(non-nil)
As far as how to do good OO design, ideally you try to avoid explicit branching whenever possible, and instead use dynamic dispatch to decide what to do. In principle, if you've architected things well, you should generally be able to avoid conditional branching.An ironically useful example of how this works is Smalltalk's implementation of Booleans and conditionals. Smalltalk doesn't actually have an if statement. Instead, it has a Boolean class that defines three methods: ifTrue:, ifFalse:, and ifTrue:ifFalse:. Each takes one or two blocks, which are effectively anonymous functions.
And then the implementation is that the True subclass as an ifTrue: that executes the block, an ifFalse that doesn't, and an ifTrue:ifFalse: that executes its first argument. And the False implementation does the opposite.
This isn't meant to be an example of "look, OOP doesn't need conditional branching, just use {library implementation of conditional branching}," so much as a small, self-contained example of the kinds of ways that you can achieve conditional-style logic without explicit branch statements. A more real-world example might be something like having separate NotLoggedInUser and LoggedInUser classes that behave differently in relevant situations, rather than having an isLoggedIn field to have to keep checking at every use site.
The big thing working against us on this is that most the popular OO languages - C++, Java, Python, C#, etc - come from the same approach of trying to layer object-oriented features on top of a procedural core. In my not-so-humble opinion, this has been about as successful as more recent efforts to support functional programming by pulling a mess of functional features into existing OO languages. Technically it gets you somewhere, but the resulting language is not an ergonomic pit of success.
Re: Lies we tell ourselves to keep using Golang
#533Earlier quoted context omitted.
I've come to the conclusion that, for the most part, option types make no sense in object-oriented languages. There are exceptions, but they tend to fall into "proves the rule" territory. OCaml, for example. Not just because of the null problem. It's also that option types push you toward a "conditional logic everywhere" way of doing things, because that's how you handle the options. That's all well and good and holy…
How does an OO language handle a case like "Do you want fries with that?" Without conditional logic? BurgerWithFriesMeal subclasses BurgerMeal? "Object oriented design", in the religious sense, is an obsolete 1980s fad that took a good idea (encapsulation of mutable state) to comical extremes.
The original idea of OO design was to strive to eliminate stateful idioms. Which is a slightly different idea than what we're used to. The state existed, but the point was that you were supposed to design your system so that objects didn't need to know - or even attempt to infer - information about other objects' state.
The whole intellectual lineage that includes pervasive use of explicit state querying and manipulation methods such as getters and setters could be characterized as a whole lot of procedural programmers collectively missing the point. It's right up there with when people over-use the State monad in Haskell, effectively doing their darnedest to Greenspun imperaive programming on top of a lazy functional language because they haven't quite internalized this new paradigm yet.
Re: Lies we tell ourselves to keep using Golang
#534Earlier quoted context omitted.
If you enable nullness checks, Java is the same.
No such thing as nullness checks in Java. At best, your IDE is taking the annotations into account and giving you warnings. At worst, you have to run ErrorProne and have it yell at you. Additionally, all Java code (including the one you wrote) is only optionally null checked. All Kotlin code _is_ null checked, no matter what.
Re: Lies we tell ourselves to keep using Golang
#535Earlier quoted context omitted.
> it's the opposite of good object-oriented design. So what is good OO design? NPEs? Nil checks?
I have yet to encounter an OO-first language for which Optional provides any real difference from nil checks. Often, it actually makes it all worse. Layering optional types on top of a system that allows any value to be nil tends to just produce a situation where there are more conditions you have to consider if you want to code defensively. As many as four: - nil - None - Some(nil) - Some(non-nil) As far as how to d…
Re: Lies we tell ourselves to keep using Golang
#536Re: Lies we tell ourselves to keep using Golang
#537The author writes well and makes compelling points. His "I want to get off Mr Golang's Wild Ride" post is good too. But I don't find myself agreeing with his position, which is "you shouldn't use Go for production services" (he explicitly says this in one of his Go posts, I forget which one and don't have time to look right now). The better alternative to Go is Rust. Okay, sure, I'm willing to admit that in the examp…
>you use the stdlib * First you construct a request, and check the error on that * Then you "Do" the request and check the error on that * Then you check the status code (you did check it, right?) * Then you deserialize the response and check the error on that * Then you close the response body (you did remember to close it, right?) and check the error on that Actually making an HTTP request with Go stdlib is a many-…
I kinda get it though, because the compiler or linters will show that as a warning or error going "bruh you forgot to handle this error", and as a perfectionist one wants to get rid of all of those.
I mean IMO those should be logged anyway, if only so you get some data on how often it happens, if there's anything that can be done about it, and if it's harmless, to ignore the error - but make it explicit.
Re: Lies we tell ourselves to keep using Golang
#538Earlier quoted context omitted.
No such thing as nullness checks in Java. At best, your IDE is taking the annotations into account and giving you warnings. At worst, you have to run ErrorProne and have it yell at you. Additionally, all Java code (including the one you wrote) is only optionally null checked. All Kotlin code _is_ null checked, no matter what.
ErrorProne is part of the compiler suite.
- Know about it (first, big problem for many java shops)
- Integrate it with Gradle/Maven/Ant/yourbuildtool
- Enable the null checks because they are not enabled by default.
Compare this with "it's already in the compiler"
Re: Lies we tell ourselves to keep using Golang
#539Re: Lies we tell ourselves to keep using Golang
#540Earlier quoted context omitted.
Quoted post unavailable.
> Their comment is about the (almost universally straight) people who demand to be called 'xe' or 'qwerty' or whatever. The vast majority of people I’ve seen using neopronouns, or “it” or “they” pronouns (either exclusively or alternatively with classical gendered pronouns, e.g., “she/they”) have nonbinary gender identity or agender identity, and the vast majority of the exceptions are trans, and all the rest (i.e.,…
Yes, I'm talking about sexuality, not gender. Most of the people I know, and/or have met, who identify as 'xe' and suchlike, are straight and usually cis (in the sense of 'not actually trans' - they do often have 'gender identities' like 'genderqueer' which amount to 'I wear heels sometimes').
It's predominantly - in my experience - straight people who covet the counter-cultural aspect of being 'queer', but who face the small problem of not actually being gay or trans or anything else, which is easily remedied by adopting one of those slightly-meaningless 'gender identities' which uniformly amount to 'I'm a teeny bit [masc/femme] sometimes'.
(I literally had a conversation with someone once who argued that watching porn didn't mean they weren't asexual. They also happened to be in a long marriage with a husband they no longer slept with, though they once had. It took all my strength not to say "lady, you're not asexual or queer, you're just a bored housewife in a dead marriage".)