![]() |
PHP compared to other languages...
I love coding in PHP, but, I read a lot of articles that deplore PHP for a variety of reasons. I am sick and tired of hearing that my favorite language for web programming sucks! Here are a few articles that I would like some of the advanced users here at TalkPHP to comment upon:
???? blog Ruby vs PHP performance PythonVsPhp - PythonInfo Wiki I have heard a lot of good things about Python (namspaces,OO, et al). As I am still young is it worthwhile to get acquainted with say, Python? Another question, what is this obsession with OOP? People talk a lot about inheritance and namespaces being primary reason to use OOP, but, most of the classes that I had come across (at say phpclasses.org) could be implemented with just plain functions. Is there a price in performance that one has to pay if one chose to use a class instead of a function? Can someone point me to an example where using a class is better than using a function. Some smart Programmers like Paul Graham say they never had use for OOP (he along with a few others built Viaweb, a shopping portal, which I think later got converted into Yahoo Stores, so it was definitely a big project that he had coded for) |
Why did you make a poll? This is talkphp.com, does it surprise you that everybody will vote for PHP? *!*
Quote:
That said, Python *is* a good language. The language fundamentals are much more solid than PHP's. PHP is more or less hacked together. Quote:
Quote:
OOP is important because it increases code maintainability. Writing hundreds of functions is cute, and it works, but when you look at your code again after a year, you might ask yourself what function is supposed to do what, and how everything is supposed to fit together in the big picture. What if you need to extend your application beyond its original intended purpose? If it consists of a bunch of loose functions, you'll be in maintenance hell. OOP allows you to model real-world entities in terms of classes. This allows your code to reflect the real world instead of exposing implementation details all over the place. It allows you to split your code into multiple smaller, simple subsystems, rather than lumping everything together in a big spaghetti boil. As someone who has programmed for almost 10 years, I'd have to say OOP is an invaluable tool for any serious developer. |
Just ignore them. Believe me, if you don't stick around and support "your language" even when it's decried, you won't be considered worth helping out. PHP is just fine and dandy, and PHP6 is going to make it much better. At a certain point, when the market requires a change of you, comply---otherwise, commit and stick to your guns.
And I have to say I highly agree with FooBarWidget: branch out and learn other languages. But don't abandon the ones you say are your favorites. Python is very unfriendly to any version changes, between major versions painfully so. (Big discussion of this at RGRD.) PHP6 will have full support for namespaces, and by proxy modules. The core is rather compact as it is though most don't distinguish between core functions and add-on extensions that ship with PHP. The naming of all these functions is very disparate though, so the comment on that is quite true. PHP5 is a part of the transition of PHP from a procedural, object orientation hackneyed, language to something with more true object orientation. Multiple inheritance, though powerful, can decrease orthogonality and obfuscate the object's reusability. As to OO file handling ... whee, I wrote my own classes for this in fifteen minutes. Worse, the whole document is a paragon of arrogance. Comments like this disqualify 98% of their view in my opinion: Quote:
|
You can embed Python Code in PHP. That is all.
|
Quote:
- I have no experience with PHP introspection so I won't comment on that. - Lambda function: create_function() *is* a joke. It is essentially a code evaluator. PHP cannot check the syntax during parse time - it performs checking only when the function is created. Furthermore, it makes it hard to bind local variables to the function. In contrast, lambda functions in Python are almost-first-class citizens (I say 'almost' because the Python syntax does not allow one to define multi-line lambda-expressions, but that can be worked around with anonymous function objects instead). Perl has true support for lambda functions (anonymous subroutines). Ruby has it as well (Proc objects). Heck, even C# has it (anonymous delegates aka closures). PHP's seems to be hacked together. - Maturity/stability/compatibility: They are right. PHP 4 and 5 changed some pretty large things compared to previous versions, and many apps required porting. So far I've seen less Python programs that break between Python releases than PHP programs that break between PHP releases. Quote:
|
I'm not saying those parts aren't hacked together, they most certainly are! Despite being hacked together, they still retain some usefulness and purpose though. But it's use isn't primarily a lambda anyway, just a callback generated anonymously.
They are right, and they are wrong. I should say the arrogance costs them any respect I had for their view. PHP 4 and 5 changed a good bit, sure. But in the end they were doing us a favor, if only our web hosts would implement the new versions more quickly. I can't claim to have used Python, because I don't use it. But I've seen a good many people complain of its major version breakages, and even minor version breakages. By and large, I don't hear this with PHP nearly so often. |
Speaking from a general point of view, everything in life has its problems because everybody, or supposedly everybody, is different. The best path you can take is to choose yourself a language - in this case you've chosen PHP, and stick with it. Granted it has its problems, I vehemently dislike the
create_function function. I think it's truly appalling. I much prefer Javascript's implementation of it - and as Ruby is more like Javascript in its syntactical implementation, I do like Ruby, but I wouldn't take it up as my primary language for the very reason that I could be learning new programming languages constantly in my life - making me a Jack of all languages, master of none.With that said, PHP 5.3 and PHP 6 really will bring a lot more to the table. However, although they're implementing namespaces amongst other exciting features, they're not fixing their inconsistencies in the function naming. I personally feel PHP should place all the global functions into namespaces, such as String and Math. Can I see that happening? Honestly? No, I can't.However, I know I will be sticking with PHP, but I won't be sticking with PHP because of any blinkered ignorance, but rather because, although it has flaws and downsides, as other languages inevitably do because of my original point, with well thought out organisation via implementing various design patterns, with a flexible and logical hierarchical directory structure, it really does shine - as does every other language, and thus the conclusion we can reach from this is that it's really down to personal preference. The lesson to be learnt? Take others opinions on-board, but don't let them hijack and divert you from your own path their discouragement. After all, we all have the ability to make up our own minds and act on those accordingly. |
Quote:
Quote:
Quote:
Quote:
What do you guys think of the second article: ???? blog Ruby vs PHP performance With processor speeds getting better, would you prefer one language over the other (I am referring to interpreted languages), just because it is quicker in processing data? |
My sincere opinion is that there is no perfect programming language, and most of all, there's not only one single language that "would hold the future". PHP will have a long life from now on in web development, I believe, for the simple fact that it's made for this purpose. Of course, there is also C#, Java and others, but they are not made for "web use only", their creators had other things in mind, too, when creating them (like desktop applications and such). Ruby code looks like junk to me, personally, and their web server (webricks or such) acts like crap when dealing with alot of traffic, from what I've heard. Java is another language that will live many many years from now on, and so is C/C++ (although my preference is Java over C++). So, I'll go for PHP and Java. Oh, and also the markup languages (like HTML, XML) and SQL (ppl will always need databases and internet websites).
|
i hated ruby when i first tried it, and i still do loathe it, dont ask y i just hate it.
|
Coming from a compiled code background, I've always known that PHP has a certain level of inefficiency. In this case it certainly appears that Ruby is the faster, doesn't it? But hey, maybe it's just that spot.
PHP is way more prevalent, and cheap, than RoR so I don't think we're threatened all that much. YET. |
Hi cosmok,
I've just joined this site, it looks like it's pretty lively so thought I'd roll with you lot :) I've been using php since version 3, I think, like yourself, it's a lot of fun, heck' I even use it for a living nowadays. FooBarWidget kind of said the important stuff but I thought I could expand a little on a couple more points. Php can be cool and easy to get into, but also difficult at times as there isn't any real standard in the core, more explicitly, function names such as those with underscore separation, and other's without. There's also a big difference between 4 and 5 if you're an oop programmer, php6 is going further away from 4 as well (and that's the version a LOT of web hosts use on their shared servers), so if you're currently using 4, you're gonna have to do a lot of catching up if you ever want to get into a more recent version of php. Oop is great, my impression is that oop can be overkill for small sites, but for big sites with/without multiple coders, it's such a useful way of working. Once you've coded your gazillionth site, it gets a bit less fun recoding a page to output news, etc. Code reusability is a core part of the oop mindset. Of course, you make a great point, you could have a script full of your most used functions, but that doesn't scale well. Over time, you'll have functions to do everything, and loading in that whale of a script is going to nail your loading times of a page. An example of a good use of oop is a database util class. In the first example, you could just have your functions class that connects and queries a mysql db. Great. Now, if you want to connect to a Sqlite / postgre / oracle db, what do you do? With oop, you could have a factory script, a sort of shell, that can extend one other script of your choosing. You know that you just need to call open_db() (or of that ilk), and whichever type of data storage you have, you'll be getting the same result. Without oop, you'll be writing functions like open_db_mysql(), open_db_postgre(), open_db_sqlite(), and so forth, then if you moved datasource at any time, you'll be recoding all calls throughout the site to the new function. "Portability" is the take-home message ;) I think from a new person's perspective, oop can seem too overkill because that person looks at framework's such as zend, pear, etc. Those guys pack everything and the kitchen sink into their packages, so from an outsiders perspective who just needs an email validation function (e.g.), oop seems like this unwieldy beast. As for other languages, I've never come across a problem that I couldn't solve with php, apart from recently! Ever done a file upload with a progress bar in pure php? You can't, it doesn't have the stuff out of the box to do it. You can extend the core with additional dll's/so's, or talk to an outside script such as perl/python using ajax, but out of the box, php can be limiting. That said, with the right extensions, php can solve anything :) |
Quote:
Quote:
|
Quote:
|
Cosmok, take a look at TlcAndres' database stuff that he's posted; it's the same principle. ;-)
|
Quote:
|
Quote:
|
As RobertK said, my DB class script is an example of OOP, I'd recommend looking at the first version since it's easier to read. the second version (last post) is slightly more complicated an abstracted.
|
Quote:
|
Quote:
|
| All times are GMT. The time now is 10:17 PM. |
Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0