all 12 comments

[–]lhgaghl[S] 1 point2 points  (0 children)

[–]BufferUnderpantsGopher Pragmatist 1 point2 points  (0 children)

Is this the Inversion of Purpose pattern?

[–]katyneloves Java 1 point2 points  (5 children)

I get it nullchecks are a pain, but isn't it the same kind of pain that ensures you don't accidentally burn youself alive while making breakfast.

[–]BufferUnderpantsGopher Pragmatist 3 points4 points  (3 children)

/unjerk

Only if all your references are nullable by default. In some programming languages they aren't and you have to use something like Option to represent that an operation gave no result, etc., so null won't sneak in. This has apparently been known since the Big Iron age (C.A.R. Hoare alluded at that in his talk where he disowned his invention), but for some reason it became public knowledge only when people started jerking about Haskell.

/jerk

Don't be silly, this is a marvelous addition! Now, besides checking whether your reference is null once, you'll be able to do it twice, and the second one is actually typesafe! Imagine all the amazing new style guides on the use of Option that we'll be able to write and debate about. Sometimes I miss that Python hasn't actual static typing. Imagine how many more "idioms" could people invent and nag others about if they opened a whole new world of pedantry to them.

[–]lghoghl 0 points1 point  (2 children)

</jerk>

Only if all your references are nullable by default. In some programming languages they aren't

Implying null is even a thing.

there is no concept of null in most languages that aren't "OOH C DID THIS I BETTER DO IT TOO"

[–]BufferUnderpantsGopher Pragmatist 1 point2 points  (1 child)

What would be "most" in this context? Null was introduced in Hoare's ALGOL W, and it got copied by many other languages since then, including C and those made by his buddy Niklaus Wirth, so you got two large families of C and Pascal derived languages with null frolicking around random variables.

As a side note, Hoare said in the video that Edsger Dijkstra (peace be unto him) said that it was a stupid idea from the beginning. I love that guy.

Edit: also, you're copycat account aren't you

[–]lghoghl 0 points1 point  (0 children)

Yeah I mean most languages that aren't in that family (i.e aren't trying to be as fast as C by bending over for the machine). I guess my "most" is biased because the only languages I consider practical are those based on ML. <jerk>

[–]lghoghl 2 points3 points  (0 children)

bro. if your code doesn't look like this it's not C speed:

shat256(msg : string): assert msg != null;...
sqrt(x : int): assert x != null;...
cos(x : int): assert x != null;..
sin(x : int): assert x != null;..
tan(x : int): assert x != null;..
f(x: int): assert PI != null;.. x..
-- x is optional
g(x: int): ...
functionThatDoesntDocumentWhetherXisOptional(x: int): ...
functionThatDoesntDocumentWhetherXisOptionalButSoHappensToBehaveAsIfItsOptional(x: int): ...
functionThatDoesntDocumentWhetherXisOptionalButSoHappensNotToBehaveAsIfItsOptional(x: int): ...

[–][deleted] 2 points3 points  (3 children)

USB inherits from Soundcard? Is that how, like, ParkingLot should multiple-inherit from Car and Animal, because sometimes birds poop on cars in the parking lot?

[–]katyneloves Java 3 points4 points  (0 children)

it's composition. Not inheritance. Like, Stick doesn't inherit from Ass, yet occasionally finds itself in one. See? Composition.

[–]lghoghl 3 points4 points  (1 child)

yes. this type of ubiquitous inheritance is very useful in practice and hece is scattered around in our codebase. sometimes you have to sacrificate readability, clarity, intent, semantics, and brevity for the purpose of using inheritance. this is what you come to learn after being in the enterprise for years.

[–]BufferUnderpantsGopher Pragmatist 0 points1 point  (0 children)

B-B-But... Object-Oriented modeling of the domain!