News for hackers. Stuff that matters.
Re:I still love PHP and JavaScript by forgotmypw17 on Tuesday August 02, 2022 @09:01PM (#32326410)
Many comments about static typing in here. I agree that it is a great and helpful feature, and it's also not the only feature.

For many other reasons, my languages of choice are mostly PHP, Perl, and JavaScript. And I have experienced the types of bugs that static typing (and also immutability) can help with.

What I have found extremely helpful is to write as if variables are immutable, not allowing myself to change them. And to do sanity checks in the beginning of every function which expects a certain type of value.

Perl's taint and strict are of great help, but I haven't thought of an easy way to port them to JS and PHP. So whenever I can, I do the heavy lifting in Perl, and then use PHP and JS as glue.

The main reasons I have chosen these three languages is their ubiquity and their committment to backwards compatibility. With all three, I can carefully write something reasonable 20 years ago and have it still run today. Sadly, I recently came across a GNU/Linux distribution without Perl, but it is rare. PHP is widely available anywhere with a web server, Perl is ubiquitous in modern (post-2000) *nix, and JavaScript can still be written in ways which work in Netscape 3.x and up.

I think if you want to write software which continues working without too much fuss, it's helpful to exploit the Lindy Effect to your advantage.

Re:I still love PHP and JavaScript by peaky_blinder on Wednesday August 10, 2022 @09:03AM (#32411210)
You can configure TypeScript to give you the output for older versions of ECMAScript. No need to limit yourself and you get many benefits (not just strict typing but also some constructs like interfaces and enums to easily scale your codebase).