Тёмный

Null References The Billion Dollar Mistake 

Hoigim Dang
Подписаться 38
Просмотров 18 тыс.
50% 1

lecturer:Tony Hoare
conference:QCon London 2009
topic:null reference in programming language design

Опубликовано:

 

5 окт 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 63   
@twincherries6698
@twincherries6698 2 месяца назад
This has aged well
@cece-yd3bo
@cece-yd3bo 2 месяца назад
First one to comment on time 😂😂
@Esloquees
@Esloquees 16 дней назад
41.39 At that moment, he struck me as the Architect from *The Matrix*-calm, calculating, and omnipotent, weaving the fabric of this digital reality. Honestly, that’s probably one of the highest compliments I could give. Ø
@ezg5221
@ezg5221 2 года назад
"Removing type checking from your running programs is like wearing a life jacket for your practice emergency drills and then taking it off as soon as your ship was really sinking" RIP Typescript. The rot goes too deep
@9SMTM6
@9SMTM6 2 года назад
That does not apply. Neither is what he's talking about specifically an issue in even Javascript (Javascript and by extension Typescript will throw an error if you access outside of array or list limits) , nor is it difficult to break the type system of Java for that manner (just inherit some class and override its methods to do stupid shit, which is actually not difficult with many Java Classes as they're often quite complex in amalgation of what they inherit and inheritance gives you access to their whole inner workings that only work correctly in specific configurations). Typescript actually fixes the general issue he described in this talk, which is something that Java, which he praises so much to this day doesn't. Well, I guess yeah it will not do random stuff, crashing and burning alone is better than setting fire to the whole neighborhood, but it's still very difficult to write a program in Java that DOESN'T in some "bordercases" crash unexpectedly. And on any Computer that uses a modern OS the behavior of code in eg C that doesn't do any null checking or Java is pretty much identical. Because the nullptr is part of a forbidden memory range and your program will be terminated by the OS if it tries to dereference null. So unless you do some embedded stuff (with Java? Youre crazy), Java, in terms of NULL specifically is on one level with C and C++, and worse than that Typescript you seem to hate so much.
@ezg5221
@ezg5221 2 года назад
@@9SMTM6 wow, you took that personally. "Type checking" is a bit broader than bounds checking and null, so I don't really feel addressed by those paragraphs at all. If you wrote in more detail about TYPESCRIPT then maybe I'd have found some value in it.
@9SMTM6
@9SMTM6 2 года назад
@@ezg5221 the primary topic of that talk was null. And Java, unlike he theorized, has YET to adopt any solution to unexpected null exceptions. That is unlike C#, and namely Typescript. Then, that paragraph you mentioned was talking about bounds checking and the ability to disable it. There are only 2 languages amongst the most popular ones these days, that do not bounds check array access per default, and that is C and C++. But hell yes I'm taking it personally if people make stupid assertions. I don't actually do any Typescript of late, these days it's been Kotlin, Python and Rust. Rust being my favorite of the bunch, it famously has the most... "correct" type system amongst popularish languages. You know what is the language I feel the 2nd most certain that it's type system enforces that no type errors happen that stop program execution unexpectedly? Typescript. I used it with fairly strict rules, perhaps thats where your mistake was, but it has en excellent type system. It's quite different to how other languages do types, but once youre used to it its easy and ensures correctness of what it promises. You know why Kotlin isn't that language? Because of fucking Java. Kotlin itself is nullsafe, but Java isn't, and as kotlin selling point is Java interop, its null safety isn't ensured at the interop boundary, breaking it. But MORE importantly, Inheritance based type systems are horribly broken. Kotlin also improves on Java in that regard, by default you can't inherit from its classes, breaking Kotlin Class instance typesafety, but again Java is here to ruin the party, FORCING you to use Inheritance in many APIs, and having super popular packages like spring regularly break type safety in dirty ways, like with JPA implementations. All this leads to Kotlin, by fault of Java, making promises it can't hold and generating random fail conditions you'd never expect, like serialization of some objects you obtained from the database randomly failing serialization. You might think Typescript with many Javascript libraries should have the same issue, but that has not been my experience. Javascript libraries due to the historic lack of safety offer simpler APIs, and they have well maintained API descriptions in Typescript that tend to be on point, because they only make structural promises. Yes, if people put type assertions everywhere that breaks things, but Java isn't different in that regard, and the simple solutions is: Don't fucking do type assertions unless you the fuck know what you're doing, and it's easy to find the sources of the resulting issues as it's these type assertions. Some libraries like Redux make it difficult to do that, but I and plenty other people have found their ways to archive it. Ive yet to find a way to use Java APIs in anything but toy projects without it breaking. It's type system is just not expressive enough, while being much needier than Typescript on top of it. The ONE area where typescripts at Runtime missing types are annoying is at network APIs where they require a bit more effort to ensure correctness. I don't know what you want to hear from me regarding Typescript. You would have to ask questions or criticize it, I won't try to guess what your issues are, as I said I've solved most of them. I will sleep now tho.
@ezg5221
@ezg5221 2 года назад
@@9SMTM6 I've re-watched it, and the paragraph was about pointers knowing what types they should be pointing to, but in the context of a typed array, it's either right, null, or out of bounds, yeah. And you know what, I've seen enough 'Promise's in my team's codebase to not question it, but I think I've been looking for the 'unknown' type this whole time. That basically handles my worst-case scenarios. I've also been treating function signatures like contracts, which is why I wasn't comfortable with their types going away, but I guess typescript can make enough guarantees about earlier checking, I'm just pessimistic.
@9SMTM6
@9SMTM6 2 года назад
@@ezg5221 hmm, I ale also rewatched it, and while he did also speak about this, I just inferred that he was only talking about array bounds checking, and while I still think that that was what he was talking about, even if he wasn't, it's all that is relevant. Reason being that due to the nature of how things work, array bounds checking being a dynamic runtime check, it can lead to type safety issues, WHILE typed references are checked statically by every compiler I know (that has a concept of references or pointers and doesn't abstract them away, the latter which still is typesafe in modern languages), meaning that there's nothing to leave away at Runtime, so it's perfectly safe. This is actually precisely how Typescript works, it checks stuff statically at buildtime and drops away at Runtime. Which is, btw, also how C, C++ and also Rust work. C++ and Rust have some extended concepts for dynamic dispatch where you have some type information at Runtime, which is actually the foundation for anything in eg. Java, but for these languages it's the exception. And yes. "any" is poison in TS. And "unknown" is fairly amazing, I was there when it got added and immediately was able to use it in a variety of places. Though it's mostly where I don't use the result, eg. when I want to accept functions that may or may not return whatever they want as I don't use the return (which I do for handler functions, allowing perfectly safe reuse of methods). As I said I used TS with strict rules, there is actually a list of Type checking options on their website (which I unfortunately can't link to as RU-vid deletes comments with links). But I've got to admit, I just realized that a small part of the checks that I require in TS are not provided by it but by ESLint, namely in my projects its forbidden to explicitly use any, combined with a TS rule that forbids implicit any, any is gone from my code basis entirely (well, with exception of badly typed library interfaces, but I can trace where that comes from and retrofit these). I used typescript with quite heavy type inference, with heavy reuse of types, in a structural way. That way actually most of my code looks and writes as easy as JS, but is Typechecked in its entirety. It does depend on apparently the presence of ESLint, and if your colleagues block safe settings, yeah, unfortunately Typescript does allow them to do things unsafely. But my colleagues (Java programmers that never spent any time learning TS) used it unsafely in a large code basis, and I was able to pice by pice convince them to enforce stricter rules, and now they're better off for it. I was also able to retrofit typesafety into that code basis by using the tools Typescript gave me (and at times a few other tools like regex search and replace and ESLint). I was able to do that as a Junior dev that had only studied Physics, that before that point had mostly used Python (back then there was no type system at all in Python, which they actually retrofitted these days, actually heavily based on TS, though unfortunately much more difficult to enforce). That is a success story in my eyes, and the reason I really like Typescript, as you probably spotted. It's not quite as correct as Rust, but with Rust the overhead for correct typing is a decent amount higher (due to it being a nominal type system as opposed to Typescripts structural type system which makes less promises but is able to infer most stuff from context).
@shoobidyboop8634
@shoobidyboop8634 2 года назад
Playback 1.5x.
@romerogoon
@romerogoon Год назад
my man 👑 also yeet
@BooBaddyBig
@BooBaddyBig Год назад
2x, but I use that on practically everything these days
@desertumvir1755
@desertumvir1755 Год назад
These comments with the RU-vid comment preview thing in mobile devices are gold
@justanotherhotguy
@justanotherhotguy 3 года назад
NullError: "yeet" not found
@Fanaro
@Fanaro 2 года назад
I think this is a trillion dollar mistake at this point.
@unskeptable
@unskeptable 2 года назад
Null had produced so many bugs Is it worth it ?
@aaqidmasoodi
@aaqidmasoodi Год назад
Rust devs?
@อนรรฆวรรณภาสชัยยง
Endding sentences in high notes kill me.
@adityaaggarwal5645
@adityaaggarwal5645 2 года назад
Yeet 11
@int32h60
@int32h60 2 года назад
yeet 10
@David_Raab
@David_Raab 3 года назад
This video is null
@peceed
@peceed 2 года назад
null is a great invention with easy hardware support
@raianmr2843
@raianmr2843 2 года назад
yeet 12
@wesleystudt8084
@wesleystudt8084 Год назад
yeet 15
@disculpa
@disculpa 2 года назад
So what is the alternative to having null? I didn't understand what he was droning on about.
@ccgarciab
@ccgarciab 2 года назад
Support for null safety operators, or optional types (which are easy to get if you have sum types in your language) Indeed, when he starts talking about classes as disjoint unions of composing classes, he's very close to sum types.
@affegpus4195
@affegpus4195 Год назад
Not allowing pointers to exist if they are not pointing at anything. Good ol resource aquisition is initialization.
@monk3y206
@monk3y206 Год назад
Not a programmer so I don't know what's the point of null or alternative to it, but I heard rust doesn't have the concept of null
@gJonii
@gJonii Год назад
Make all references valid. One tool to achieve this is by having algebraic data types, you can return Cat|Null if you want to return a Cat sometimes, but keep the option to have it uninitialized. In Java style languages, every instance of Cat is actually Cat|Null, and you have no way to enforce that you actually, seriously, for realsies this time, want a Cat. You can check each "Cat" at every handoff point if it's null in hiding, which is pointless and error-prone manual labour. You could instead make it explicit, and also guarantee that every Cat is actually a Cat.
@izd4
@izd4 Год назад
@@monk3y206 Rust has Option, which is an enum (or, for Rust, a tagged union) with variants Some and None. That makes two things explicit: 1. With a variable of type Option, you may or may not have a value of type T, and can use pattern matching to handle it appropriately. 2. With a variable of type T, you do not have to guess whether it is T or null, which is the issue @gJonii points out with Java.
@lukassalzman4938
@lukassalzman4938 10 месяцев назад
Playspeed at 2.0x is Vetter to listen to this grandpa
@amananifer3511
@amananifer3511 3 года назад
yeet 2
@Aayush-fn5se
@Aayush-fn5se 2 года назад
yeet 13
@AlfredGuimaz
@AlfredGuimaz 3 года назад
yeet 7
@yatiacdev
@yatiacdev 3 года назад
yeet 4
@AmitKumar-mc4ww
@AmitKumar-mc4ww 3 года назад
yeet 3
@rishikeshkanabar4650
@rishikeshkanabar4650 3 года назад
yeet 5
@kovacsgyorgy5043
@kovacsgyorgy5043 3 года назад
yeet 8
@inuke4fun832
@inuke4fun832 4 года назад
yeet
@tiqur8157
@tiqur8157 4 года назад
yeet
@smithpereira7117
@smithpereira7117 4 года назад
yeet
@tiqur8157
@tiqur8157 4 года назад
yeet
@mercurybrothers9483
@mercurybrothers9483 3 года назад
yeet
@danieru3
@danieru3 3 года назад
yeet
@Shri22gokarna
@Shri22gokarna Год назад
yeet 16
@bartdenhartog6466
@bartdenhartog6466 Год назад
Without a doubt interesting stuff, but 137 ehm's in the first five minutes made me quit...
@tomekk.1889
@tomekk.1889 Год назад
You're talking about the guy who created null refferences. Have some respect
@jobosan4855
@jobosan4855 2 года назад
yeet 14
@EduardoMengesMattje
@EduardoMengesMattje Год назад
falou, falou, e não disse porra nenhuma 👏👏👏👏
@guymoses8727
@guymoses8727 3 года назад
yeet 9
Далее
Being Competent With Coding Is More Fun
11:13
Просмотров 89 тыс.
The Worst Typo I Ever Made
11:25
Просмотров 6 млн
How Many Twins Can You Spot?
00:17
Просмотров 23 млн
POLI и Маша - Сигма бой
00:20
Просмотров 154 тыс.
I tried using AI. It scared me.
15:49
Просмотров 7 млн
Nullable Reference Types - The Good, The Bad, The Ugly
26:24
ARRAYLIST VS LINKEDLIST
21:20
Просмотров 64 тыс.
Birth of BASIC
38:13
Просмотров 1,2 млн
Brian Kernighan's Programming Setup | Lex Fridman
4:57