Hacker News new | ask | show | jobs
by hamidp 6139 days ago
I remember fiddling around with PHPs recursion and having it get very bad very quickly.

Why use lambdas and recursion with PHP when there's tons of languages that do it better?

2 comments

Sometimes it is more practical to update a codebase than to rewrite it entirely in a different language.

From the comments here you would think it is bad that writing clean PHP is possible...

You could also generate PHP code from Scheme or Common Lisp. That way you can write in the language you like and update the codebase.
I would prefer if such approach was taken to ease a gradual reimplementation.

The risk of this just making the codebase even uglier is enormous.

I thought about that too. There are programs that can handle making PHP or C beautiful. GNU indent is one of them I think, and there's another one called TidyPHP? Something like that.

So you just generate and then run the code through that if you need it to be human readable. I assume most companies don't give a shit as long as it works ;)

I fear a Scheme to PHP code generator would turn out PHP code that's ugly beyond what any code beautifier could hope to fix. It's not make-up - it would be akin to major surgery.
I'm sure it would only require indent fixing if coded properly.
Lambdas and recursion are only a small part of the decision for a programming language. There are many, many deliberations in picking a language.

Availability on the target platform (cheap web hosters?), availability of libraries, familiarity with the language (of the entire team, both current and in the future), purpose (aiming to get to the market quickly, or trying to learn a new language?), compatibility or integration with an existing code base, et cetera.

All these deliberations taken together may lead to a decision to use PHP. If so, it is nice to have lambdas and recursion. "It's better in another language" is without meaning in that case, because the feature is so small compared to the other deliberations. It quickly turns into the better question: "is it good enough?"