

Most of the time they need to be signaled explicitly - thus narrowing a long integer to short integer requires an explicit cast.

Of course, type promotions like widening or narrowing numeric values are prevalent in many strongly typed programming languages but do not escape the language’s type system as easily as in PHP. *) utop # (+) - : int -> int -> int = utop # 1 + 1 - : int = 2 utop # 1.0 + 1.0 Error: This expression has type float but an expression was expected of type int utop # (+.) - : float -> float -> float = utop # 1.0 +. (* 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.

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. 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. They will work to some extent, but if the application has heavy graphical needs, it's recommended to use another set of graphical routines, suited to the platform the program should work on.A nonsensical ramble on type systems Introduction The graph unit will allow to recompile old programs. The unit is provided for compatibility only: It is recommended to use more modern graphical systems. The unit was first written for dos by Florian Klaempfl, but was later completely rewritten by Carl-Eric Codere to be completely portable. This document describes the GRAPH unit for Free Pascal, for all platforms. TP compatible unit to handle screen graphics.
