4 ms·
> its type system has historically been an afterthought This is a rather outdated view. PHPs type system isn't the most expressive thing out there, but it's ve
by deergomoo 2y ago
> its type system has historically been an afterthought
This is a rather outdated view. PHPs type system isn't the most expressive thing out there, but it's very achievable to have end-to-end type safety these days. For a start it's possible to delineate between nullable and non-nullable types, something many more "serious" languages don't support.
It has the weakness that, not being compiled, you need an additional static analysis tool to catch these things before runtime. But at least it has the good graces to crash if you tell it you're expecting a Foo and you try to pass a Bar, unlike e.g. Python.
Modern PHP is a completely different thing to the 5.x days. Yeah you still have the inconsistent stdlib, but everything has a few warts after 30 years.
- pmarreck 2y agoGood point on the type thing. Not so much on the "everything has a few warts after 30 years". Many of the warts were baked-in at the start or in the very early days (like in many other languages), which is why language design is so important. I'm not a Lisp fan, but it doesn't seem very warty; and while I'm not a C# fan either, its stdlib, last I used it, was EXTREMELY well-designed/organized. I WAS a Ruby fan, but after working in million-line codebases with hit, its warts finally showed up. I have yet to find any true warts in Elixir; the only one I can think of is how to indicate in a match that a given variable should be matched against instead of reassigned, that's done with the ` character, which threw me off at first. A simple and accessible example of something Elixir does superior to PHP (and many other languages) is make the first argument to every function the "main thing being worked on", which then enables the pipeline operator to actually be useful. So, every String function expects the string being worked on to be its first argument, enabling chained transformations, which ends up being really nice for readability/maintainability/conciseness.