

(* These are code samples from an Ocaml REPL session. It has a low cognitive load compared to, say, OCaml where arithmetic operators are in fact regular infix functions which aren’t polymorphic over their arguments.

This is the easiest way to bypass PHP’s gradual type system since operators are baked into the language and their semantics are exempt from the type system itself. Even more interesting is the fact that it’s still there in PHP 7.4. The not so good thing about type juggling is the mental juggling you need to perform in your head when your script goes astray without throwing any exceptions.
#Free pascal file time resolution manual
The old PHP 3 manual explicitly mentions type juggling as a language feature. Now, let’s go back in time a bit, to year 2000 when PHP 3 was still in the game and its successor, PHP 4 was released. Also, there exist many peculiarities within the type system itself - when talking about generics it’s needless to say that the inability to express object boxing and unboxing is a bit surprising. Recent addition of gradual typing is not sufficient considering it still lacks generics. In today’s world where strong static typing is becoming more and more crucial to creating robust, performant and secure applications, it’s probably well-grounded to say that PHP’s type-juggling might not be the best fit. And when they woke up it was way too late to catch up.

There are languages still in use today that somehow overslept this phase of accelerated growth. Another thing that cannot be neglected is a common attempt at standardizing languages and their tooling - formal specifications (even PHP got an a posteriori one), linters, tools for auto-formatting the code and building pleasant-looking documentation. Most of them have acquired some new interesting features usually inherited from functional languages derived from the lambda calculus - lambda expressions (so called arrow functions), immutability, referential transparency, list comprehensions oftentimes structures from category theory have been incorporated as well - algebraic data types (product types also called tuples and sum types often called discriminated unions), functors, applicatives (applicative functors) and monads to name a few. Yet in some ways (with numerous exceptions of course) we still use the same programming languages as we did twenty or so years ago. Be it support for seamless modular programming, static type system or concurrency and parallelism with robust ways of maintaining state in distributed systems. With modern codebases growing at an insanely fast pace we have generally come to terms with the fact that certain traits in our beloved programming languages determine the quality of the end product in one way or another. A nonsensical ramble on type systems Introduction
