JUGNsk Meetup #1. Тагир Валеев: "Nullability: между добром и злом"
Рассказ о том, как в различных языках программирования, в том числе в Java, выражается "ничто", к каким проблемам это может привести, можно ли избежать этих проблем и жить вообще без этого самого "ничто".
points to a function, the result is a function designator; if it points to an object, the result is an lvalue designating the object. If the operand has type ‘‘pointer to type’’, the result has type ‘‘type’’. If an invalid value has been assigned to the pointer, the behavior of the unary * operator is undefined. 84) 84) ... Among the invalid values for dereferencing a pointer by the unary * operator are a null pointer, an address inappropriately aligned for the type of object pointed to, and the address of an object after the end of its lifetime. ISO/IEC 9899 International Standard – Programming Languages – C 27
points to a function, the result is a function designator; if it points to an object, the result is an lvalue designating the object. If the operand has type ‘‘pointer to type’’, the result has type ‘‘type’’. If an invalid value has been assigned to the pointer, the behavior of the unary * operator is undefined. 84) 84) ... Among the invalid values for dereferencing a pointer by the unary * operator are a null pointer, an address inappropriately aligned for the type of object pointed to, and the address of an object after the end of its lifetime. ISO/IEC 9899 International Standard – Programming Languages – C 28
of the null reference in 1965. At that time, I was designing the first comprehensive type system for references in an object oriented language (ALGOL W). My goal was to ensure that all use of references should be absolutely safe, with checking performed automatically by the compiler. But I couldn't resist the temptation to put in a null reference, simply because it was so easy to implement. This has led to innumerable errors, vulnerabilities, and system crashes, which have probably caused a billion dollars of pain and damage in the last forty years. Tony Hoare, 2009 32
[1 of 1] Compiling ParentChild (ParentChild.hs, interpreted ) Ok, modules loaded: ParentChild. *ParentChild> (p, c) = create "Курица" "Яйцо" *ParentChild> p Parent named Курица *ParentChild> c Child named Яйцо *ParentChild> child p Child named Яйцо *ParentChild> parent c Parent named Курица *ParentChild> child (parent (child p)) Child named Яйцо 103
Используйте статический анализ • Верьте спецификации, а не реализации • Учитесь пользоваться и не пользоваться новыми API • Изучайте языки программирования • Расширяйте кругозор 104