▲ 543 ▼ 0 vs null vs undefined - explained with toilet paper (i.stack.imgur.com) submitted 3 years ago by jeff@programming.dev to c/programmer_humor@programming.dev 39 comments fedilink hide all child comments
[–] traches@sh.itjust.works 2 points 3 years ago (7 children) Rust is neat because it doesn't have the bottom 2 permalink fedilink source hideshow 7 child comments replies: [–] deegeese@sopuli.xyz 2 points 3 years ago (6 children) Lack of support for nulls sounds like a huge pain in the ass. permalink fedilink source parent hideshow 6 child comments replies: [–] labsin@sh.itjust.works 5 points 3 years ago* (3 children) It has std:option So every object that can be None or Some, needs to be checked when used. And only options can be set to None permalink fedilink source parent hideshow 3 child comments replies: [–] CanadaPlus@lemmy.sdf.org 5 points 3 years ago* (last edited 3 years ago) (2 children) Yeah it's a bit inaccurate to say it's not supported. It just has edge case handling written explicitly into whatever thing you're building (I assume it's required to do so in order to be well-typed). It took this idea from Haskell, which might have gotten it from Miranda or something. permalink fedilink source parent hideshow 2 child comments replies: [–] labsin@sh.itjust.works 2 points 3 years ago (1 child) I like the pattern a lot more. It makes you just initialize the value and only keep it 'nullable' for where it's needed and then you need to check. Even .net implemented it (but a bit more awkward) permalink fedilink source parent hideshow 1 child comment replies: [–] CanadaPlus@lemmy.sdf.org 1 point 3 years ago Yup. Programmers are really stupid, if the compiler forces us to explicitly handle weird situations that's a feature. permalink fedilink source parent [–] traches@sh.itjust.works 3 points 3 years ago It also doesn't have throw/try/catch. If a function can fail, it returns a Result and you have to deal with the failure case explicitly. permalink fedilink source parent [–] lavafroth@programming.dev 3 points 3 years ago *Laughs in Option* permalink fedilink source parent
[–] deegeese@sopuli.xyz 2 points 3 years ago (6 children) Lack of support for nulls sounds like a huge pain in the ass. permalink fedilink source parent hideshow 6 child comments replies: [–] labsin@sh.itjust.works 5 points 3 years ago* (3 children) It has std:option So every object that can be None or Some, needs to be checked when used. And only options can be set to None permalink fedilink source parent hideshow 3 child comments replies: [–] CanadaPlus@lemmy.sdf.org 5 points 3 years ago* (last edited 3 years ago) (2 children) Yeah it's a bit inaccurate to say it's not supported. It just has edge case handling written explicitly into whatever thing you're building (I assume it's required to do so in order to be well-typed). It took this idea from Haskell, which might have gotten it from Miranda or something. permalink fedilink source parent hideshow 2 child comments replies: [–] labsin@sh.itjust.works 2 points 3 years ago (1 child) I like the pattern a lot more. It makes you just initialize the value and only keep it 'nullable' for where it's needed and then you need to check. Even .net implemented it (but a bit more awkward) permalink fedilink source parent hideshow 1 child comment replies: [–] CanadaPlus@lemmy.sdf.org 1 point 3 years ago Yup. Programmers are really stupid, if the compiler forces us to explicitly handle weird situations that's a feature. permalink fedilink source parent [–] traches@sh.itjust.works 3 points 3 years ago It also doesn't have throw/try/catch. If a function can fail, it returns a Result and you have to deal with the failure case explicitly. permalink fedilink source parent [–] lavafroth@programming.dev 3 points 3 years ago *Laughs in Option* permalink fedilink source parent
[–] labsin@sh.itjust.works 5 points 3 years ago* (3 children) It has std:option So every object that can be None or Some, needs to be checked when used. And only options can be set to None permalink fedilink source parent hideshow 3 child comments replies: [–] CanadaPlus@lemmy.sdf.org 5 points 3 years ago* (last edited 3 years ago) (2 children) Yeah it's a bit inaccurate to say it's not supported. It just has edge case handling written explicitly into whatever thing you're building (I assume it's required to do so in order to be well-typed). It took this idea from Haskell, which might have gotten it from Miranda or something. permalink fedilink source parent hideshow 2 child comments replies: [–] labsin@sh.itjust.works 2 points 3 years ago (1 child) I like the pattern a lot more. It makes you just initialize the value and only keep it 'nullable' for where it's needed and then you need to check. Even .net implemented it (but a bit more awkward) permalink fedilink source parent hideshow 1 child comment replies: [–] CanadaPlus@lemmy.sdf.org 1 point 3 years ago Yup. Programmers are really stupid, if the compiler forces us to explicitly handle weird situations that's a feature. permalink fedilink source parent
[–] CanadaPlus@lemmy.sdf.org 5 points 3 years ago* (last edited 3 years ago) (2 children) Yeah it's a bit inaccurate to say it's not supported. It just has edge case handling written explicitly into whatever thing you're building (I assume it's required to do so in order to be well-typed). It took this idea from Haskell, which might have gotten it from Miranda or something. permalink fedilink source parent hideshow 2 child comments replies: [–] labsin@sh.itjust.works 2 points 3 years ago (1 child) I like the pattern a lot more. It makes you just initialize the value and only keep it 'nullable' for where it's needed and then you need to check. Even .net implemented it (but a bit more awkward) permalink fedilink source parent hideshow 1 child comment replies: [–] CanadaPlus@lemmy.sdf.org 1 point 3 years ago Yup. Programmers are really stupid, if the compiler forces us to explicitly handle weird situations that's a feature. permalink fedilink source parent
[–] labsin@sh.itjust.works 2 points 3 years ago (1 child) I like the pattern a lot more. It makes you just initialize the value and only keep it 'nullable' for where it's needed and then you need to check. Even .net implemented it (but a bit more awkward) permalink fedilink source parent hideshow 1 child comment replies: [–] CanadaPlus@lemmy.sdf.org 1 point 3 years ago Yup. Programmers are really stupid, if the compiler forces us to explicitly handle weird situations that's a feature. permalink fedilink source parent
[–] CanadaPlus@lemmy.sdf.org 1 point 3 years ago Yup. Programmers are really stupid, if the compiler forces us to explicitly handle weird situations that's a feature. permalink fedilink source parent
[–] traches@sh.itjust.works 3 points 3 years ago It also doesn't have throw/try/catch. If a function can fail, it returns a Result and you have to deal with the failure case explicitly. permalink fedilink source parent
[–] lavafroth@programming.dev 3 points 3 years ago *Laughs in Option* permalink fedilink source parent