How do PHP people handle templating simply? Edit: Perhaps I worded my question wrong. How do PHP programmers try and keep to DRY (ala layouts and view templates)?
PHP Addiction
71–80 of 320 posts
Re: PHP Addiction
#72Earlier quoted context omitted.
Do you want to provide an application that anyone can run and easily deploy on their own server with as little configuration as possible? Oh. I hate PHP as much as anyone (of course), but that's what it does.
So Java then?
It's a similar problem as Ruby and Python, believe it or not.
Re: PHP Addiction
#73Here is another point that highlights the problem: If I want to write a hello world application in PHP, it's neither as long as nor as short as Rather it's simply: hello world. Just type in those 11 characters in a text file and save it as hello.php. Now load it on your browser [or run it from command line] and it will print hello world. I don't think it can get any more simpler than that in other languages. PHP was…
What people continue to fail to explain is why PHP needs to be replaced. Why not improve it? After the millions of man hours that have gone into the plethora of open source PHP based frameworks and tools (aka, what powers the internet) - wouldn't we as a community want to improve the foundations rather then scrap them entirely? You know, like what happened with Javascript...
PHP has a lot of them. And they interact badly.
Re: PHP Addiction
#74The only thing actually wrong with PHP, is that it's popular but not cool. And that's a terrible place to sit for any product. It runs half the Internet quite well, but if you went by the posting on HN, you'd think it was Windows Vista. I've probably read every article critical of PHP that has hit the front page of HN in the last few years, and the one thing they all have in common is the vague refrain that PHP is a…
It isn't as much broken, as it is just a bit annoying. Just a bit. Not enough to make it really bad, but enough to irritate you.
Re: PHP Addiction
#75How do PHP people handle templating simply? Edit: Perhaps I worded my question wrong. How do PHP programmers try and keep to DRY (ala layouts and view templates)?
Since PHP is a template language at heart, they go ahead and use PHP. For PHP folk, I guess the question is: how do people handle templating simply in other languages, since they can't use the host language itself for that? EDIT: Disclaimer: I'm a PHP guy trying to make a break for it, and the question was both rethorical and tongue-in-cheek.
Re: PHP Addiction
#76Earlier quoted context omitted.
As easy as PHP in what sense? That Python is basically part of all OS' now or as easy as putting in in a .php file and uploading it to your server? I severely doubt it's as easy as the latter. I'd like to see an article that explains in less than 140 chars how to deploy a simple app as Hello World to the web in Python without the use of a framework like Django or Flask. Edit: In the amount of chars Twitter accepts, h…
echo "hello world" > index.html && python -m SimpleHTTPServer :)
Re: PHP Addiction
#77Here is another point that highlights the problem: If I want to write a hello world application in PHP, it's neither as long as nor as short as Rather it's simply: hello world. Just type in those 11 characters in a text file and save it as hello.php. Now load it on your browser [or run it from command line] and it will print hello world. I don't think it can get any more simpler than that in other languages. PHP was…
$ echo 'hello world' | erb
hello world
$ echo 'hello world' | php
hello world
If a new user could throw index.erb up on a server and have it execute in a Ruby context, would we be any further to supporting better development practices? Will the user take that experience and move into a framework like Rails later? If yes, what has stopped them from using the similar PHP frameworks that will already take them away from the comfort of the single page template?If you truly only need a single page template without any further abstraction, then why not use PHP? It seems all of the complaints about PHP stem from using it in big projects. It is hard to argue that it does a single page template very well for when that is all you need. Right tool for the job and all that.
Re: PHP Addiction
#78Why do I need to switch?
You've already gone through the pain of learning how to work around all of its warts, and you will lose a ton of productivity immediately after switching to a new language. This may seem trivial if you are just programming as a hobby (and fun, even, to learn something new) but if you are a professional programmer, the productivity loss can be a problem. If you are a freelancer billing at a good rate, can you charge the same thing to your new client knowing things will take you twice as long and be less optimal, with bugs happening in new surprising places?
Taking on a new language needs to happen for a better reason than "the language I'm an expert in is kind of ugly." Are there libraries that are only available in the new language? Is there a different server architecture that lets you write applications with several times the performance in certain important use cases? These are valid reasons. "Too many functions in the global namespace" is not, especially if you already have them all memorized.
Re: PHP Addiction
#79"...next language choice was clear: Python, which seems to fit my style better than Ruby" Just out of curiosity, why would someone believe this? The syntax of python and ruby are nearly identical, but ruby has more tools and support for web-based projects. For someone looking to develop for the web, ruby is pretty clearly a better choice. And this is not knocking python at all, I really enjoy them both and there are…
Just off the top of my head:
- Ruby was always designed as an OO language, whereas Python OO was bolted on later. Ruby's object system is almost a straight transplant from Smalltalk and is very powerful.
- Python lambdas can only be one liners. Ruby lambdas can be arbitrarily long. Guido doesn't really like FP - there's no tail recursion, either.
- Ruby's metaprogramming capabilities are a bit more powerful (haven't really looked at Python in this regard, so don't quote me).
- In fact, there are some pretty big syntax differences. Python requires brackets even for the print statement now, whereas Ruby lets you miss them out if it's unambiguous. Ruby has blocks. Python doesn't have "end\n end" sprinkled everywhere.
The main philosophical differences are that Ruby is more powerful and implicit, wheras Python is stricter and explicit. When I say "powerful", by the way, I don't necessarily mean "good", just that it exposes more functionality to the user. Although I like Ruby a lot, I accept that on large projects Ruby's power (like that of Lisp or C) can be dangerous. Python has a lot going for it.
You're right, they're still very similar in many ways. Maybe they're like Democrats or Republicans; up close, they're screamingly different, but from a distance they're almost alike.
Re: PHP Addiction
#80The only thing actually wrong with PHP, is that it's popular but not cool. And that's a terrible place to sit for any product. It runs half the Internet quite well, but if you went by the posting on HN, you'd think it was Windows Vista. I've probably read every article critical of PHP that has hit the front page of HN in the last few years, and the one thing they all have in common is the vague refrain that PHP is a…