News for hackers. Stuff that matters.
Re:Go nulls and SQL by avgcorrection on Monday May 23, 2022 @04:27PM (#31484412)
The comment that you respondend to:

> > Sane languages have pointers which either can't be null or require you to check explicitly.

You cannot try to dereference a nullable pointer in safe Rust. It has got nothing to do with Optional (Some/None).

Re:Go nulls and SQL by tedunangst on Monday May 23, 2022 @04:30PM (#31484439)
That would make a rust pointer rather less useful for representing sql null, no?
Re:Go nulls and SQL by avgcorrection on Monday May 23, 2022 @04:58PM (#31484687)
What?

The comment that you -- with aloof disbelief -- replied to only talked about pointers. I don't know what point you think you are proving with these pithy replies. It sure does go above my head. :)

Re:Go nulls and SQL by tedunangst on Monday May 23, 2022 @05:17PM (#31484862)
Well, this is a thread about storing sql null. I'm trying to suss out how sane languages represent sql null in a way that can't go wrong. So far the answers mostly seem to be use a type that can't represent sql null or use a type that explodes when you use it wrong. With a side of real programmers don't let bugs pass code review.
Re:Go nulls and SQL by stouset on Monday May 23, 2022 @05:48PM (#31485194)
With all due respect, it appears as if you have entered this conversation with this belief and have used that perspective as a filter when other commenters have tried to correct that perspective.

It may be surprising to learn that languages without implicitly-nullable types are real, but you should understand that none of these people would be trying to tell you about this if these languages simply exploded any time you used them the wrong way.

Re:Go nulls and SQL by avgcorrection on Monday May 23, 2022 @05:34PM (#31485040)
> I'm trying to [sass] out how sane languages represent sql null in a way that can't go wrong.

There is a difference between a type Pointer where `null` is an instance of that type and a type Box which only has valid (can be dereferenced) values. If the language has e.g. algebraic data types and pattern matching then Option(al)<Box> can be safely matched on and Box can be used in the branch (the pattern match arm) where Some(Box). Meanwhile in a language with Pointer and no flow analysis any dereference of Pointer could lead to some kind of "panic".

Say "unwrap()" all you want but the two approaches are clearly very different.

Re:Go nulls and SQL by winstonewert on Monday May 23, 2022 @11:13PM (#31487611)
Where did anyone anywhere in this thread claim that you could "represent sql null in a way that can't go wrong?"

Yes, Rust options explode if you unwrap a None. But that's explicitly what `unwrap()` does. It a big improvement over any random access potentially implicitly exploding.

Re:Go nulls and SQL by anonymoushn on Tuesday May 24, 2022 @12:10AM (#31487889)
It seems like sql types that include null and non-null values are a union of at least two different types. In general, if you write code to handle a tagged union that has "panic!" in one of the prongs, you'll get panics. Don't do that?
Re:Go nulls and SQL by imron on Monday May 23, 2022 @09:53PM (#31487168)
Correct, which is why you'd use Option<T> instead.