4 ms·
If I throw a dart randomly at the Big Board O' Language Features: It is the only optionally typed language in common use whose types are checked at runtime. O
by pie_flavor 5y ago
If I throw a dart randomly at the Big Board O' Language Features:
It is the only optionally typed language in common use whose types are checked at runtime.
Or:
Its type system has notation for 'the concrete type of `this`', what Rust calls `Self`, and no OO language in common use other than Swift has.
It's actually pretty easy to find something nice about PHP.
- zelphirkalt 5y agoTypes being checked at runtime seems like a bad idea, because it wont help you discover mistakes before the program runs. Ideally it would check types before the program runs and give an option to have checks at runtime in parts, for when you cannot know at compile time. The type system also does apparently not provide a common Object kind of type. So Object cannot be used to work around the lack of generics. Making it difficult (impossible?) to create abstract data structures and making sure, that the functions for that ADT only accept things that adhere to some interface. This makes the type system rather less useful in general. I guess it all stems from the earlier days of PHP, where OOP was added badly and in hindsight. It still shows.
- pie_flavor 5y agoTypes are checked both statically and at runtime. Having only static checking like TS does means that when someone fits untyped code in via a type hole, they stand the same chance of getting it wrong as the untyped code did. I was convinced of the merits of this by dealing with nonnullable code in Kotlin vs C# - the former checks at runtime too, the latter does not, the latter makes it far harder to find and debug the lingering NullReferenceExceptions. There is a common type, `mixed`. A common superclass fills that role in some OO languages, and not in others. The practical purpose of a common superclass is to provide builtin functions like C#'s object.ToString(). You don't need to do that when working with generics, and __toString is a magic function instead. So `mixed` fills that role perfectly fine.