3 ms·
> There is no need to compile anything. But I really like compilers, they catch a whole class of bugs, before I run things.
by latchkey 4y ago
> There is no need to compile anything.
But I really like compilers, they catch a whole class of bugs, before I run things.
- oaiey 4y agoAnd static typing, and linting, and code analysis, and security checks, and .. these pipelines are long nowadays Oh and the garantiert that no one can modify it post the compile step.
- binhamstrr 4y agoWhile you don't have a proper compilation step, you can run some very good static analysis on PHP. I can't imagine not having Psalm or PHPStan in our build pipelines.
- hakube 4y agoUnit testing
- Gigachad 4y agoUnit testing is a poor mans compiler. Our medium size rails app has 40,000 unit tests and constantly we have issues where an updated library changed the name or parameters of a method without warning causing breakages.
- jjice 4y agoYikes. Is there a static analysis tool for Ruby (along the lines of MyPy or PHP Stan) that could have caught this? Also, out of curiosity, are all of those tests hand written, or is there some generation in there?
- Gigachad 4y agoAll hand written over 10 years. They catch a lot of stuff, but stuff still slips through. Generally the area of the breakage even has tests over it but didn’t manage to catch the particular issue or they had mocked out parts which ended up being the issue. I can’t see how static analysts could solve it really.
- latchkey 4y agoimho, this is a huge reason why ruby fell off the popularity charts over time. i predicted this pretty early on and got a lot of flack from the ruby community as a result. nobody wanted to write tests to ensure that something would compile... let alone tell you what 'type' an object was. i can't tell you how many hours i wasted watching my pair trying to figure out what 'type' an object was, by using `print`. luckily i was working as a very expensive consultant. of course these things could be bolted onto ruby, but it never felt natural. running 40k tests to see if something compiles is absurd, takes forever and results in super brittle tests that have to be reworked when code changes. often people would use meta programming in the tests, which only made figuring out the errors even harder since the line numbers would be all wonky in traces. sorry you're saddled with that legacy of well intention and poor execution.
- stackedinserter 4y agoNot enough.
- mozey 4y agoThe compilation step, and the resulting binary, is also very useful if you need to distribute your software. As opposed to creating a ZIP file. There are tools for creating stand-alone executables from PHP source code, but they're not as nice to use, compared to languages that were designed for this. By distributing software I also mean making your latest code live in prod. I suppose the benefit of using PHP (or other interpreted languages) is that it's easier to create "plugins", just copy the new source files to the server.
- latchkey 4y agoCorrect. I had a use case where I needed to run an app on 30,000+ servers and the app would be updated regularly with new features. I wasn't going to use PHP for that because it would involve not only copying the PHP binary around (and maintaining that version), but also my own app code. golang ended up being a perfect solution because I could cut the binary down to about 3-4 megs with compression and build flags. More importantly, it was just one thing to install and maintain.
- apocalyptic0n3 4y agoPHP has a way to compile entire applications into single files, for what it's worth. You can compile it all in your CI/CD and then push the PHAR file to all the servers (instead of the thousands of regular files). I don't know if it accomplishes everything you're after, but it's been a PHP feature for over a decade. https://www.php.net/manual/en/intro.phar.php https://www.php.net/manual/en/intro.phar.php
- latchkey 4y agoAs the op said: "There are tools for creating stand-alone executables from PHP source code, but they're not as nice to use, compared to languages that were designed for this."