Post 9lp98aaQF0QaNwZbeK by will@catgirl.science
(DIR) More posts by will@catgirl.science
(DIR) Post #9lp7K1nZCx8u3i33i4 by natecull@mastodon.social
2019-08-12T21:57:52Z
0 likes, 0 repeats
Language designers:Behold, my vast wobbly tower of static types ascending to the heavens, all to ensure that (if the stars align and the wind doesn't blow) you can never dereference a null pointer and crash!Me:But what if dereferencing a null pointer didn't crash but just.... gave you null.
(DIR) Post #9lp8ammgNqpQN0BnlI by dredmorbius@mastodon.cloud
2019-08-12T22:27:47Z
0 likes, 0 repeats
@natecull Oh by the way, "Vader" means "father".Biggest fucking spoiler evar.https://www.etymonline.com/word/father
(DIR) Post #9lp98aaQF0QaNwZbeK by will@catgirl.science
2019-08-12T22:32:19.299707Z
0 likes, 0 repeats
@natecull implicit Maybe monad huh
(DIR) Post #9lp98jL9h8YzXCV2bQ by pea@fuckonthefirst.date
2019-08-12T22:33:50.995118Z
2 likes, 0 repeats
@will @natecull it ends me how the maybe monad is like the super easy solution to everything null but for some reason so few languages implement anything like it
(DIR) Post #9lp9QkCxCuhlREFlOi by will@catgirl.science
2019-08-12T22:35:20.543956Z
1 likes, 0 repeats
@pea @natecull people are too wedded to the implementation of null in the hardware to think about it on a higher level maybe? dunno
(DIR) Post #9lp9g4qqjn5ho4E2TY by Senkowo@letsalllovela.in
2019-08-12T22:38:59.354216Z
0 likes, 0 repeats
@pea @will @natecull literally every popular modern programming language (except go lol) has a solution to nulleven java has a maybe monad these days
(DIR) Post #9lp9g6vt02JAGGb5bU by pea@fuckonthefirst.date
2019-08-12T22:39:57.136150Z
0 likes, 0 repeats
@Senkowo @natecull @will in that case no one uses it and the reality of the maybe monad is that it has to be embedded into stdlib and library design to be remotely useful
(DIR) Post #9lpAQteUC774gNlek4 by Senkowo@letsalllovela.in
2019-08-12T22:41:27.799771Z
0 likes, 0 repeats
@pea @natecull @will yeah in java it's not used pervasiblybut when i say modern language, i talk about go, rust, swift, kotlin, etc.
(DIR) Post #9lpAR5KMmk9KtSRl32 by Senkowo@letsalllovela.in
2019-08-12T22:43:42.254785Z
0 likes, 0 repeats
@pea @natecull @will rust has maybe monadswift and kotlin have the concept of explicit nilabilitygo is banging it's pots and pans together in the corner
(DIR) Post #9lpARG0Z4hqW1EGbD6 by pea@fuckonthefirst.date
2019-08-12T22:48:19.640016Z
0 likes, 0 repeats
@Senkowo @natecull @will ah, so you mean bleeding edge languageRust is a notable example of a language that does a good job with this, although i think the explicit handling is a bit ugly if I recall correctly from last time I used it
(DIR) Post #9lpAr2lyuDHKV2k1ya by Senkowo@letsalllovela.in
2019-08-12T22:50:18.435475Z
1 likes, 0 repeats
@pea @natecull @will rust does a lot of hacks specifically for Optional<T>(which is why I love the type unions approach but they're not popular)
(DIR) Post #9lpAyR7mlUr63ISuY4 by Senkowo@letsalllovela.in
2019-08-12T22:53:04.855973Z
0 likes, 0 repeats
@pea @natecull @will i hardly call kotlin or swift bleeding edge any morerust, at a stretchgo definitely isn'twhen i think of bleeding edge i think of like, crystal
(DIR) Post #9lpAyc1oE3bvrwknGC by pea@fuckonthefirst.date
2019-08-12T22:54:25.118658Z
1 likes, 0 repeats
@Senkowo @natecull @will kotlin and swift are barely not bleeding edge, and only on the technicality that they were championed by major mobile OS companies for developing on that mobile OS
(DIR) Post #9lpB96XVdlBdOUaHui by espectalll@mstdn.io
2019-08-12T22:13:23Z
0 likes, 0 repeats
@natecull I mean, I guess you don't want things to unexpectedly return null, so I guess crashing is a really forceful and expensive way to tell programmers to not do bad coding practices?
(DIR) Post #9lpB9KZRTN3EuXb1s0 by natecull@mastodon.social
2019-08-12T22:56:20Z
0 likes, 0 repeats
@espectalll But why don't you want things to return null?Null is just a value. A perfectly good value. If it's important to you that a value not be null, at the place where you care, you can test whether it is nor isn't null.What I'm saying is that 'dereferencing null' is like multiplying by zero, not dividing by zero. It's asking 'does nothing have this property?' And the answer to that question is no. The value for 'no' is null.You don't crash mathematics if you multiply by zero.
(DIR) Post #9lpBAKkaI2nrl3HnqS by natecull@mastodon.social
2019-08-12T22:56:32Z
0 likes, 0 repeats
@espectalll But why don't you want things to return null?Null is just a value. A perfectly good value. If it's important to you that a value not be null, at the place where you care, you can test whether it is or isn't null.What I'm saying is that 'dereferencing null' is like multiplying by zero, not dividing by zero. It's asking 'does nothing have this property?' And the answer to that question is no. The value for 'no' is null.You don't crash mathematics if you multiply by zero.
(DIR) Post #9lpERWWg3rBr45faD2 by espectalll@mstdn.io
2019-08-12T23:33:17Z
0 likes, 0 repeats
@natecull Basically, null is a very easy way to get unexpected behavior, because a lot of times you might expect things to always happen when the reality isn't quite true. It's called the billion dollar mistake for a reason, and things like Optional seem like the better way to go.
(DIR) Post #9lpEmB0NGrUyOrPNCq by espectalll@mstdn.io
2019-08-12T23:37:04Z
0 likes, 0 repeats
@natecull You are right that you would expect things that don't exist to be null, but null is too generic and doesn't enforce by what the type *should* be, which in turn also makes error handling harder.JS is doing it wrong, sure, but it's not like null is innocent.