3 ms·
I've had to go through a bunch of "cowboy" Perl scripts at work. Some are a ridiculous 2-3000 lines doing things a decently written Python script could do in a
by jqm 12y ago
I've had to go through a bunch of "cowboy" Perl scripts at work. Some are a ridiculous 2-3000 lines doing things a decently written Python script could do in a 100 lines or less. (I don't fault the language for this... it's the way they were written). Many of them have bugs that have existed for years. Nobody wants to (or practically can) go through and fix the bugs... even the authors. They are full of cleverness, regular expressions, don't make efficient use of functions etc. So, in my limited experience, when Perl is bad, it is really really bad. And that is a very strong negative in a language. I've finally got permission for flat out re-writes in Python and the old timers have been fairly sullen about the short amount of time the re-writes thus far have taken, and how small the code is. Again.. I don't blame Perl for all this. But it's readability sure doesn't help these kind of situations.
- allendoerfer 12y agoI hate this "I do not fault the language for this". It is the argument always brought up with PHP as well. You can write ugly code with Python, but the Python language and community clearly renounces itself from that and is all about readable code. Every feature addition or remove is done with consideration of code readability and creating one best practice to perform a task correctly. JavaScript "maintainers" try their best to build a solid language on top of an ugly hack. The community tries every day to avoid its own language with another precompiler. Java is all about defining solid interfaces, which creates new problems, but at least they try. On the other side, Perl people were historically often proud of their crazy hacks. PHP does not remove dangerous or objectively ugly language features. It could avoid SQL injections in new versions all together but instead is focused more on adoption and backwards compatibility. The language is partly responsible for the type of code that is written in it.
- nemo 12y ago"PHP does not remove dangerous or objectively ugly language features." I hate to defend PHP, but they have removed some dangerous features. Over the years there have been a lot of dangerous hacks that were deprecated and eventually killed. register_globals was deliberately disabled, breaking a lot of old PHP. Magic quotes got removed (though PHP's morass of variable escaping is still a tar pit). PHP 6 (or maybe 7 depending on the number they decide to go with) will kill mysql in favor of mysqli which will help enforce the use of placeholders/prepared statements (you can still screw it up, but you have to work harder). They could do better, but they have been improving in removing dangerously broken features, and have broken back-compatibility over and over to do so. I actually hate PHP, but when I've had to use it, PHP 5.5/5.6 isn't nearly as dangerous/broken as PHP used to be (though it's still horrible).
- allendoerfer 12y agoThey have had PDO since nearly ten years now and are just now thinking about removing the worst of the other two worse DB APIs they put in the standard library. Instead of deprecating they were busy copying every language construct they could find. Even if you want to stay backwards compatible, what is so hard about deprecating it and moving the dangerous feature out of the standard library into a module after 2 years? I give them, that they are slowly changing now (probably because they can not come up with further constructs), but for a while they still deserve the rants.
- nemo 12y agoIf you said "PHP isn't aggressive enough in removing dangerous or objectively ugly language features" I'd be with you 100%. I was just pointing out that they do sometimes pull some, though I'd agree they could do better. I don't use PHP unless its a requirement and have declined nice paying job offers because PHP was involved (a 5.5/Laravel port from legacy code) so I no longer stay on top of things (don't really do Perl either anymore), but I was under the impression that they were killing a lot of deprecated legacy cruft in PHP 6/7.
- eCa 12y ago...Or a hundred lines of decent Perl or Ruby. Any language can be written badly.
- jqm 12y agoOh, I agree 100%. Python is referenced because I personally knew I could do much more compact re-writes in it. Also, I'm not sure, but I believe, had the original hacks not been done in Perl, the authors (and others after them) would have had much less trouble untangling the mess and they wouldn't have had 10 year old bugs no one could fix.