5 ms·
Ah, well this is where we differ, I'd say PHP is easy, not simple, and that Python is simple not easy. My reason for feeling that way hinges upon Python having
by anc2020 18y ago
Ah, well this is where we differ, I'd say PHP is easy, not simple, and that Python is simple not easy.
My reason for feeling that way hinges upon Python having more available abstractions.
Scheme is an exagerated example of this. Continuations are a very simple idea, you can describe call/cc to someone without much hassle. But the implications of call/cc can be very difficult to grasp.
The closure is a lesser example of a simple, pure abstraction which allows complex code through this devious form of simplicity.
So that is (pretty much) why it is very easy to reach expert level in PHP but very very hard in Scheme.
At the end of the day, what's easier to learn:
closures, or
the fact that a callback (in PHP) is supplied by giving its name as a string?
Its easier to not learn something than it is to learn it :)
- wvenable 18y agoI think I can explain the problem. I taught PHP for a semester at the college level to Web designers. I had 3 months (1 class a week) to get them from no programming experience at all to having a small web application (a contact list). Mostly they all managed to accomplish the task but obviously there's only time to cover the minimum functionality necessary. In that sense, PHP is easy. Now, here's the problem, absolutely nothing they learned is useful for building a reasonable-sized long-lasting web application. They didn't use any classes. They didn't use a template engine. They didn't use a database abstraction. They learned PHP but they didn't learn to use PHP to build real applications. So all that easiness of PHP is all wrong. If you want to do it right, it's not easy.
- randallsquared 18y ago"So all that easiness of PHP is all wrong. If you want to do it right, it's not easy." However, much of the time getting people to do it at all is harder than getting them to do it right after they're doing something. PHP makes it easy to start doing something and see results, and that immediate reward prompts those who wouldn't otherwise get that far. A coupla weeks ago, tptacek made this point, and I think it applies here: http://news.ycombinator.com/item?id=418157 http://news.ycombinator.com/item?id=418157 [Edit: to be clear, tptacek may not have specifically been talking about PHP, but about the fact that writing lots of code is an indicator of total usefulness even if the code is currently bad or inappropriate.]
- habibur 18y ago> They didn't use a template engine. PHP is a templating engine. Writing a templating language for PHP, like Smarty, is like writing a second templating language running on the first templating language.
- wvenable 18y agoPHP is a crappy template engine. Inlining code into an HTML document requires a lot of discipline, a lot of code to write, and is error prone. Why not let software handle that task for you? You want to create more work for yourself?
- habibur 18y agoDon't want to inline code? Well don't inline code. No second templating engine can reduce complexting any more than using PHP directly as a templating language. PHP was built as a templating engine from day 1. There is a reason why php scripts start with <? --- ?>
- wvenable 18y ago"No second templating engine can reduce complexting" Oh yeah, compare: <?php echo htmlentities($firstName, ENT_COMPAT, "UTF-8"); ?> with: {$firstName} Isn't that reduced complexity? And that's not even getting into other constructs. In my template language (based on smarty), a single {loop} tag expands to 10 lines of PHP code. Would you also claim that no programming language can ever reduce complexity over assembly language? Probably not. This is just the same thing. Compiling a higher level language into a lower level language.
- habibur 18y agoWell, here is what I would write: Smarty: {$firstName} vs PHP: <?=h($firstName)?> And, loops? Your: {loop} vs PHP's loop: <?while(loop()){?> Of course you have to define function h() and loop() somewhere. Just don't do it in your template file and you are fine. Hardly saving you even one line of code. We are down to counting how many charecters each need. Would you also claim that no programming language can ever reduce complexity over assembly language? Probably not. This is just the same thing. Compiling a higher level language into a lower level language. I woun't.