Quote:
Originally Posted by BestXXXPorn
(Post 17825384)
qft
Also, @brandonstills
Don't be knocking PHP up in here... I guarantee I can write an app that will out perform any other language when run in the correct, optimized environment for virtually any task. (Notice I said virtually any task :))
First off, if you think any scripting language these days is a blocking factor to code running fast and/or efficiently... you're going to lose a LOT of credibility in my eyes.
If anything, code wise, it's some of these frameworks that show poor performance. Even Rails... I love RoR syntactically but it is a slow ass bitch when compared to other frameworks/languages! It is, IMO, the most elegant syntax on the planet and I love Ruby for it's pure OO driven syntax however... it's slooooow. RoR heads will argue that caching allows RoR apps to stay on par... sure but that doesn't leave any room to catch up with other languages when they use caching as well!
Right now the largest limiting factor is storage, specifically, relational storage. That's why NoSQL is so hot right now... When you start to take into account large scalability + social features (which require much more responsive times and larger data sets) it's no wonder everything is moving towards NoSQL!
PHP is a fantastic language and anyone that says otherwise is just ridding the elitist short bus. I am proficient in a LOT of different languages yet still prefer to write _most_ web apps in PHP for a variety of different reasons. Not the least of which is speed...
I will say though that your posts about the best developers being able to cherry pick the best and most profitable opportunities are absolutely correct! You definitely have a firm grasp on where most of the top developers sit as well as a variety of other topics, I just had a bone to pick with the whole ripping on PHP thing :)
|
You just said the Ruby syntax is better than PHP but it is slow. But then you say speed doesn't make a difference. I agree with you on both counts and that is what I am saying too.
My main gripe with PHP is not its execution speed. That doesn't really matter much as far as practicality is concerned. It is developer productivity. PHP feels like I'm programming in assembly language compared to other languages. It's so tedious that it takes away from the actual task at hand.
As an aside, here's a benchmark of various programming languages. Notice that PHP is at the bottom. Even more feature rich languages run faster. Notice that Ruby 1.9 is faster than PHP.
RoR has a lot of overhead but the latest version of Ruby is actually faster than PHP language to language. Check the queries RoR generates, it sometimes isn't the most efficient and you have to manually override its defaults.
But you are right, the language speed doesn't matter much, the database is typically the bottleneck. And caching makes page render times pretty much pointless.
Some of my gripes about PHP are the following:
1) Limit scope control
You can't have nested lexical scopes, it doesn't support any type of coroutines or continuations. It doesn't support dynamic scope either. If you want to automate certain things you can't put them in functions because that function can't operate in the scope that it is was executed in. So you end up having to pass variables in and out which just adds a bunch of overhead that makes it not worth even bothering. You also can't bind scope directly either.
2) No support for macros or extending the syntax of the language
3) Poor support for functional programming
arr [ sq ] map
or
arr.map &:sq
is much easier and more readable than
$new_arr = array(); foreach ($arr as $x) $new_arr[] = sq($x);
or
$new_arr = array_map(function($x) { return sq($x); }, $arr);
Ewww.
4) Poor support for meta programming
You can't write code that writes code. At least not unless you want to write a parser and compiler in PHP that uses another custom DSL. Granted there is create_function() but that is not really meta programming. That is passive code generation.
Read
http://letoverlambda.com/ and
http://pragprog.com/titles/ppmetr/metaprogramming-ruby to get a better idea about meta programming. The Factor programming language is probably the best at meta programming but it isn't really a mainstream language.
5) Extremely limited object model when compared to Smalltalk, Ruby, CLOS, or even Javascript. Plus the syntax sucks.
6) Inconsistent API function naming, is it $needle, $haystack or $haystack, $needle?
Is it module_fooBar, foobar, FooBar, module_foo_bar, ModuleFooBar, etc?
7) Limited architecture
Each page load starts executing a completely new environment. There is no server or application context. You can't start up the server and run a bunch of initialization code and THEN handle connections. Each connection starts fresh and you has to run the entire code again for each page load.
8) Limited syntax
Why can't I do funcThatReturnsArray()[5]? Instead I have to do:
$stupid_temp = funcThatReturnsArray()
$stupid_temp[5]
same goes for funcThatReturnsClass()->theFunc()
9) No ||= operator
Instead I have to do $foo = isset($foo) ? $foo : 5; instead of foo ||= 5
Here's a funny story that has been around for a while that hits home for me.
Quote:
As I was walking down the street the other day, I noticed a man working on his house. He seemed to be having a lot of trouble. As I came closer, I saw that he was trying to pound a nail into a board by a window --- with his FOREHEAD! He seemed to be in a great deal of pain. This made me feel very bad, watching him suffer so much just to fix his window pane. I thought, "Here is an opportunity to make someone very happy simply by showing him a better way to do things." Seeing him happy would make me happy too. So I said, "Excuse me sir, there is a better way to do that."
He stopped pounding his head on the nail and with blood streaming down his face said, "What?" I said, "There is a better way to pound that nail. You can use a hammer."
He said, "What?"
I said "A hammer. It's a heavy piece of metal on a stick. You can use it to pound the nail. It's faster and it doesn't hurt when you use it."
"A hammer, huh?"
"That's right. If you get one I can show you how to use it and you'll be amazed how much easier it will make your job."
Somewhat bewildered he said, "I think I have seen hammers, but I thought they were just toys for kids."
"Well, I suppose kids could play with hammers, but I think what you saw were brightly colored plastic hammers. They look a bit like real hammers, but they are much cheaper and don't really do anything," I explained.
"Oh," he said. Then went on, "But hammers are more expensive than using my forehead. I don't want to spend the money for a hammer."
Now somewhat frustrated I said, "But in the long run the hammer would pay for itself because you would spend more time pounding nails and less time treating head wounds."
"Oh," he said. "But I can't do as much with a hammer as I can with my forehead," he said with conviction.
Exasperated, I went on. "Well, I'm not quite sure what else you've been using your forehead for, but hammers are marvelously useful tools. You can pound nails, pull nails, pry apart boards. In fact every day people like you seem to be finding new ways to use hammers. And I'm sure a hammer would do all these things much better than your forehead."
"But why should I start using a hammer? All my friends pound nails with their foreheads too. If there were a better way to do it I'm sure one of them would have told me," he countered.
Now he had caught me off guard. "Perhaps they are all thinking the same thing," I suggested. "You could be the first one to discover this new way to do things," I said with enthusiasm.
With a skeptical look in his bloodstained eye he said,"Look, some of my friends are professional carpenters. You can't tell me they don't know the best way to pound nails."
"Well, even professionals become set in their ways and resist change." Then in a frustrated yell I continued, "I mean, come on! You can't just sit there and try to convince me that using your forehead to pound nails is better than using a hammer!"
Now quite angry he yelled back, "Hey listen buddy, I've been pounding nails with my forehead for many years now. Sure, it was painful at first but now it's second nature to me. Besides, all my friends do it this way and the only people I've ever seen using hammers were little kids. So take your stupid little children's toys and get the hell off my property!"
Stunned, I started to step back. I nearly tripped over a large box of head bandages. I noticed a very expensive price tag on the box and a blue company logo on the price tag. I had seen all I needed to see. This man had somehow been brainwashed, probably by the expensive bandage company, and was beyond help. Hell, let him bleed, I thought. People like that deserve to bleed to death. I walked along, happy that I owned not one but three hammers at home. I used them every day at school and I use them now every day at work and I love them. A sharp pain hit my stomach as I recalled the days before I used hammers, but I reconciled myself with the thought that tonight at the hammer users club meeting I could talk to all my friends about their hammers. We will make jokes about all the idiots we know that don't have hammers and discuss whether we should spend all of our money buying the fancy new hammers that just came out. Then when I get home, like every night, I will sit up and use one of my hammers until very late when I finally fall asleep. In the morning I will wake up ready to go out into the world proclaiming to all non-hammer users how they too could become an expert hammer user like me.
|