(Mar 26, 2015 05:14 PM)Crypto™ Wrote: As an ex-PHP user, I wish I had never learned it, not because it was bad per sé, but because I learned practices that most developers would probably laugh at me for. I throw this article around a lot, but PHP: A Fractal of Bad Design is well worth a read regardless of your stance on PHP. Same with PHP Sadnesss. Sure, it might be a language you like personally, but it's syntactically, it's terrible. Laravel is one of the few things that makes it bearable for me.
Sigh. I've read these resources - and others - that complain about PHP's imperfections. It's not exactly something new or surprising - every language has many ( many) flaws.
Would you care to share some of the practices you learned in PHP that would make other developers laugh at you? And perhaps give some examples of its terrible syntax? It's just to satisfy my curiosity more than anything else really.
PHP internals developer
Mar 28, 2015 01:21 AM
(This post was last modified: Mar 28, 2015 01:29 AM by Crypto™.)
(Mar 27, 2015 04:31 PM)Haxalot Wrote: Sigh. I've read these resources - and others - that complain about PHP's imperfections. It's not exactly something new or surprising - every language has many (many) flaws.
Would you care to share some of the practices you learned in PHP that would make other developers laugh at you? And perhaps give some examples of its terrible syntax? It's just to satisfy my curiosity more than anything else really.
1) Mixing business and display logic without templating. (PHP actually encourages this behaviour by default.)
2) Suppressing errors by silencing them, rather than fixing them (even though some stupid shit causes errors/warnings)
3) No concurrency, because no support for it. (This is both a bad practice, and a language flaw. Concurrency results in much faster code, since you can carry on in a separate thread while particularly weighty code executes. I wrote a script that had to parse a large amount of web pages. Without concurrency, it took almost two hours to go through 1000 entries. With concurrency, it took approximately fifteen minutes.)
PHP is particularly destructive to beginners in my opinion, since an experienced developer knows how to avoid these pitfalls, but novice developers are coaxed into a very linear approach, which, unless you learn about modularizing code, properly handling errors, sanitizing user input, and a laundry list of other tasks that simply aren't as prevalent in other languages. I'm not saying that PHP's the only offender, but in my experience, it's significantly more susceptible to these pitfalls.
I have a weird thing with Cron Jobs as well for executing PHP tasks. I feel like it's super hacky, and not a good way to deal with background work.
Get a signed message before dealing: Keybase
Still here sometimes.
(Mar 28, 2015 01:21 AM)Crypto™ Wrote: 1) Mixing business and display logic without templating. (PHP actually encourages this behaviour by default.)
I realise PHP makes this easy to do by enabling you to inline it within other code, effectively also making it a native templating language. But to say that it encourages this behaviour isn't exactly true - and it certainly far from promotes it either.
(Mar 28, 2015 01:21 AM)Crypto™ Wrote: 2) Suppressing errors by silencing them, rather than fixing them (even though some stupid shit causes errors/warnings)
PHP's different error level handling is really one of its strengths. It does not force a developer to run strict, standards compliant code. It simply lets the developer choose what error reporting level they wish to run, and instead recommends the code base run cleanly in the highest error reporting level possible (E_ALL). This is a strength because it acts as a guide to writing cleaner, future-proof code rather than acting as an enforcement (which isn't as programmer-friendly).
(Mar 28, 2015 01:21 AM)Crypto™ Wrote: 3) No concurrency, because no support for it. (This is both a bad practice, and a language flaw. Concurrency results in much faster code, since you can carry on in a separate thread while particularly weighty code executes. I wrote a script that had to parse a large amount of web pages. Without concurrency, it took almost two hours to go through 1000 entries. With concurrency, it took approximately fifteen minutes.)
It's not baked into the core, but don't dismiss the pthreads extension.
Personally, I feel the predominance of crappy tutorials out there for PHP is more of the problem than the language itself - but maybe I'm just biased :)
PHP internals developer
(Mar 28, 2015 06:39 AM)Haxalot Wrote: I realise PHP makes this easy to do by enabling you to inline it within other code, effectively also making it a native templating language. But to say that it encourages this behaviour isn't exactly true - and it certainly far from promotes it either.
PHP's different error level handling is really one of its strengths. It does not force a developer to run strict, standards compliant code. It simply lets the developer choose what error reporting level they wish to run, and instead recommends the code base run cleanly in the highest error reporting level possible (E_ALL). This is a strength because it acts as a guide to writing cleaner, future-proof code rather than acting as an enforcement (which isn't as programmer-friendly).
It's not baked into the core, but don't dismiss the pthreads extension.
Personally, I feel the predominance of crappy tutorials out there for PHP is more of the problem than the language itself - but maybe I'm just biased :)
That's definitely possible. I know my knowledge of it was just glommed together from a bunch of mediocre tutorials, so it's entirely possible. I'm always going to prefer Node.js to PHP though :P
Get a signed message before dealing: Keybase
Still here sometimes.
I would highly recommend you check out www.avuna.org
It's java, but faster and less resource intensive than PHP & RoR put together doubled.
(Mar 28, 2015 07:12 PM)JavaProphet Wrote: I would highly recommend you check out www.avuna.org
It's java, but faster and less resource intensive than PHP & RoR put together doubled.
That's quite a statement - you wouldn't happen to have any figures on performance comparisons between the three with real world apps?
PHP internals developer
I got curious today about the number of available jobs for PHP vs Ruby on Rails, so I did some research:
Indeed.com
Query: title:PHP - 205 Results
Query: title:Ruby on Rails - 276 Results
Query: title:Rails - 299 Results
Careers.StackOverflow.com
Query: PHP & type: Permanent - 368 Results
Query: Ruby on Rails & type: Permanent - 407 Results
Query: Rails & type: Permanent - 237 Results
TheMuse.com
Query: PHP - 123 Results
Query: Ruby on Rails - 2022 Results
Query: Rails - 53 Results
Lever.co
I used Google to quickly check their listings:
Query: "PHP" site:*.lever.co - 488 Results
Query: "Ruby on Rails" site:*.lever.co - 123 Results
Query: "Rails" site:*.lever.co - 220 Results
Greenhouse.io
Once again, Google:
Query: "PHP" site:boards.greenhouse.io - 542 Results
Query: "Ruby on Rails" site:boards.greenhouse.io - 192 Results
Query: "Rails" site:boards.greenhouse.io - 277 Results
Angel.co
Query: Job Type: Full-time & Role: Backend Developer & PHP - 223 Companies
Query: Job Type: Full-time & Role: Backend Developer & Ruby on Rails - 204 Companies
Query: Job Type: Full-time & Role: Backend Developer & Rails - 205 Companies
Query: Job Type: Full-time & PHP - 842 Companies
Query: Job Type: Full-time & Ruby on Rails - 977 Companies
Query: Job Type: Full-time & Rails - 1001 Companies
This is in no way comprehensive, but should provide some interesting stats.
Get a signed message before dealing: Keybase
Still here sometimes.
Ruby is for stupid gay hipsters that sit in Starbucks on the MacBooks while they work on their shitty startup with an .io domain of a word that normally ends in er and they take out the e
PHP is for manly men.
(Mar 29, 2015 10:07 AM)mallard Wrote: Ruby is for stupid gay hipsters that sit in Starbucks on the MacBooks while they work on their shitty startup with an .io domain of a word that normally ends in er and they take out the e
PHP is for manly men.
Github
Groupon
Heroku
Hulu
Twitter
CodePen
Stripe
37Signals
Basecamp
HipChat
CampFire
YellowPages
All these companies were started by the "Hipsters" you speak of.
(Mar 29, 2015 10:49 AM)~Dec Wrote: Github
Groupon
Heroku
Hulu
Twitter
CodePen
Stripe
37Signals
Basecamp
HipChat
CampFire
YellowPages
All these companies were started by the "Hipsters" you speak of.
damn hipsters
i was a hipster before it was cool
Mar 29, 2015 01:23 PM
(This post was last modified: Mar 29, 2015 01:25 PM by Strider64.)
I'm a dinosaur when it comes to programming, although I really haven't become serious about programming since the last few years. I started out with COBOL that had to deal with punch cards, if anyone knows about punch cards you know the anguish. 🤐
Anyway PHP -vs- Ruby on Rails is kind of silly, any programming language can be poorly coded. Though I do agree being a PHP developer that PHP lends itself to a lot of bad code floating around the net. An to throw in the mix there is a lot of obsolete code that uses mysql that for some strange reason beginners seem to be drawn to. A lot of them will change over to mysqli or PDO once they are notified they are using obsolete code, but you always have the few knuckleheads "I'll change over once I learn PHP"! Why learn something that is going to be obsolete? I never understand this way of thinking. Anyways this is not to bash PHP or Ruby, but just to give my opinion that both are just a tool in a developers toolbox. ✌
|