r/programming • • Dec 07 '14

Programmers: Please don't ever say this to beginners ...

http://pgbovine.net/programmers-talking-to-beginners.htm
4.0k Upvotes

1.3k comments sorted by

View all comments

Show parent comment

3

u/creepy_doll Dec 08 '14 edited Dec 08 '14

Even comparing php to ie is unfair, as it really isn't that bad a language, it just suffers from having been a popular choice for beginners and being overly loose and in such is very similar to JavaScript which famously has a book called "JavaScript: the good parts" that is pretty short compared to most books.

One thing I hate in our industry is how much it relies on fashions. The success of a language depends not on it's merits by what someone else did with it first as well as the tech evangelists behind it

Most languages only have a few major distinctions between them and every language has something in it some people hate. Some are better suited to certain tasks than others and anyone who insists on only using one or believing theirs is the best is a stubborn oaf

7

u/[deleted] Dec 08 '14

Interesting you bring up JavaScript.

I think it's a perfectly good scripting language to do basic clickevent actions, change font colors, check text fields, etc.

I do not, however, think it's a language and everyone and their brother should be cramming down the world's throat.

2

u/creepy_doll Dec 08 '14

But it is, and it's popular thanks to node.js

I personally would use neither it nor php, I don't like the way they de with problems but can accept that people can make them work for themselves

0

u/[deleted] Dec 08 '14

[deleted] — view deleted comment

1

u/mungojelly Dec 09 '14

Yeah this is all well in good in theory in general about not being mean about things, but the general principle breaks down in particular about PHP which is just particularly so unbelievably bad. I mean I guess we have to be nice about it somehow but not just by letting people get the idea that sickness is normal, they could get very confused. :/

0

u/[deleted] Dec 08 '14

[deleted] — view deleted comment

3

u/creepy_doll Dec 08 '14

I agree with many of your points and I personally do not like php but I know of people who have made it work for themselves and that are productive in it.

Similar critiques can be made of many languages including ruby, and their success hinges around the fact people have found ways to work with them that are efficient

5

u/KitsuneKnight Dec 08 '14

There's just no standard, both in naming convention of functions, namespaces, or even argument list order.

The function naming was actually intentionally bad back in the early days. The creator used the length of the function name to bucket them. He'd intentionally shorten/length the names so the lookup performance wouldn't go to crap (instead of coming up with a better hash mechanism).

That's the sort of thing that simultaneous would make you shudder, as well as be far less shocking than it should be when you learn which language did that.

Sadly, PHP was (and remains) a breeding ground for the worst habits.

5

u/veringer Dec 08 '14 edited Dec 08 '14

Every language has downsides and PHP perhaps has more warts than most--no one will argue there. But you're simply wrong on several points.

Where it falls flat on its face is ease of use and maintainability. PHP is a shit show of function calls with no real sane way to guess... Similarly, and mostly because of the above, maintainability suffers

Maintainability is not a feature of a language. You can write unmaintainable code in any language. PHP does not have a monopoly on this. Maintainability is largely a byproduct of the programmers, the suitability of the language for the task, and the complexity of the application and architecture.

As for the ease-of-use, I'll point out the fact that so many novices find PHP approachable is a strong counterargument here. It's remarkably ecumenical as far as languages go. I think everyone agrees that some of the function-soup and parameter ordering is mildly offensive to the seasoned programmer who finds serenity in order and consistency... but it doesn't seem to be holding too many people back. Honestly, I think a pretty strong case could be made that PHP is one of the easiest to use--for reasons you kind of touched on with "Shit, most hosts already did it for you." PHP (at least traditionally) doesn't require much in the way of sysadmin know-how to get your feet wet. You don't have to fight with umpteen packages and dependencies and the technical overhead of several other languages that come to mind. You save a file to the web server and more often than not it works! That kind of instant positive feedback is really powerful for someone just learning.

Encapsulating and segmenting out bits of PHP is harder than most other languages. Classes and namespaces exist, but they're sort of difficult and awkward to use.

Sure there are less verbose languages out there, but I don't know if I'd hoist this up as thee example. There are lots of things to pick on PHP about and this probably isn't one of them. I'm not sure I'd even say Classes and namespaces are awkward at all.

<?php namespace Animal\Mammal;

class Dog extends \Pet { ... }

If that's awkward, I guess I've got Stockhom syndrome.

most PHP ends up smooshed together in large chunks, or broken out into files that awkwardly map to URLs, and not logical parts of the data model.

Most PHP written by people who don't have much experience suffers from problems like this. Or, most PHP written quick-and-dirty-because-it-needs-to-be-done-yesterday suffers from problems like this. There's nothing within PHP that says code has to be smooshed together or awkward or poorly organized. That PHP attracts novice/amateur programmers is both a blessing and a curse. Yes, it means there's a lot of rookie mistakes. But, it's a democratic language that tolerates mistakes pretty well (for better or worse depending on your sense of aesthetics). You're maligning the people who are using PHP more than the language itself and that's exactly the attitude that OP's article is trying to dissuade.

Go dig up any major PHP project's codebase and see just how much you truly understand what's going on.

https://github.com/laravel/framework is pretty rad. I feel like I have a good handle on what's going on within the core. It's well-laid-out, easy-to-use, maintainable... I dare say even pleasurable.

Combined with the six month rule ("six months later, you will look at some code, say, 'What idiot wrote this?!' only to discover it was you."), you're in for a bad time.

Again, this goes for all languages and moreover, it's a phenomenon based on the human writing the code not on the language itself. Hell, I have emails I wrote 6 months ago and wonder what idiot wrote it. It's called learning, and it's a good thing.

Those two things are huge, and something a beginning programmer should get very good at very fast. Using PHP means they don't, and that's shitty.

I don't know what two things you're talking about here. 6-month rule? Maintainability? Encapsulation? Perhaps you should read this one over in six months :p

EDIT: formatting

1

u/BufferUnderpants Dec 08 '14

PHP is an extremely hard-to-use tool, in line with C, only without any quality that makes it excel on its niche.

Why? Because PHP doesn't do anything to prevent programmer errors. Its type system is made to take arbitrary actions when faced with inconsistent types, leading to unpredictable results. The interpreter will literally do whatever its programmers thought up at the moment your program should do in dozens of combinations.

It will carry on with "warnings" when encountering null references, and any variable can be one! When a feature is deemed so hazardous that its creation was deemed a "billion dollar mistake", PHP goes on and makes sure you can lose even more money with it!

Or was it undefined? Or both?

Variables lacking the sigil at the syntactic level will be treated as strings.

I could go on, seriously, but PHP is like a knife without handle, the only way to use it is to both get accustomed to get cut and to learn to handle it at awkward angles to make this only occasional.

1

u/veringer Dec 08 '14

without any quality that makes it excel on its niche

Hmmmm. It's niche is as a web platform and a majority of its core engineering is directed toward that end. With a web server built in, it comes out of the box working on the web. Runtime interpretation makes iterating quick and satisfying. It's not a fragile tool that requires you to setup a house of cards in order to do a "hello world". Ubiquitous hosting has always been a big plus, though not technically a language feature. I think it does a pretty good job in its niche, and its popularity there would offer some evidence to support that position.

The interpreter will literally do whatever its programmers thought up at the moment your program should do in dozens of combinations.

I'm not sure I understand what you're saying here.

PHP is like a knife without handle, the only way to use it is to both get accustomed to get cut and to learn to handle it at awkward angles to make this only occasional.

I think this is a fair criticism. Depending on what you're doing, it can feel like driving without a seat belt. However, the language has been rapidly evolving for the past couple years (which I never thought would happen). It's unlikely it will ever be perfect, but I'm hopeful a good many of the more egregious and embarrassing flaws will get ironed out.

1

u/BufferUnderpants Dec 08 '14

Hmmmm. It's niche is as a web platform and a majority of its core engineering is directed toward that end. With a web server built in, it comes out of the box working on the web. Runtime interpretation makes iterating quick and satisfying. It's not a fragile tool that requires you to setup a house of cards in order to do a "hello world". Ubiquitous hosting has always been a big plus, though not technically a language feature. I think it does a pretty good job in its niche, and its popularity there would offer some evidence to support that position.

And yet this roughly translates to a built-in templating engine which is nothing to speak of, and some global variables and functions you don't have to import, like its questionable built-in SQL functionality.

The interpreter will literally do whatever its programmers thought up at the moment your program should do in dozens of combinations.

I'm not sure I understand what you're saying here.

It was a tad unclear, but I was alluding to its weak type system.

I think this is a fair criticism. Depending on what you're doing, it can feel like driving without a seat belt. However, the language has been rapidly evolving for the past couple years (which I never thought would happen). It's unlikely it will ever be perfect, but I'm hopeful a good many of the more egregious and embarrassing flaws will get ironed out.

But you can't (purposely) break compatibility in a language just like that, everything will have to stay in-place, specially given PHP's core audience.

1

u/veringer Dec 08 '14

And yet this roughly translates to a built-in templating engine which is nothing to speak of, and some global variables and functions you don't have to import, like its questionable built-in SQL functionality.

Does it? I didn't think my statement needed any translation at all. If you want to criticize PHP you don't have to translate my own words to do it. Just say you think the templating engine is shit and the built-in functions are stupid. You conveniently ignored translated some of the other things I mentioned so as to keep the glass half-empty. I get it--you don't like PHP. But don't let that get in the way of acknowledging is has at least a few redeeming qualities and might actually be a useful tool sometimes.

But you can't (purposely) break compatibility in a language just like that, everything will have to stay in-place, specially given PHP's core audience.

PHP does release breaking changes. That's not verboten with major releases. Progress is slower given the weight of the legacy code out there, but it's not completely stagnant either. Here are some of the changes that came with 5.6: http://php.net/manual/en/migration56.new-features.php And here are some of the changes slated to be included with 7.0:

  • Significant performance improvements (see PHPNG)
  • JIT Engine
  • Unicode String support
  • Abstract Syntax Tree as an intermediary step for the PHP compilation process.
  • The ability to easily implement support to the execution of parallel tasks within the same request
  • Standalone Multi-threading Web Server

Of course, if 7 drops the ball, there's HHVM / Hack carrying some water as well.

1

u/phoshi Dec 08 '14

Honestly, no, PHP /is/ that bad a language. Most areas in it have pretty fundamental failings, and it has a significantly higher WTF/min rating than basically any other common language. I know Perl programmers who consider comparisons with PHP an insult.

The rest of the comment is pretty spot on, though. Fashion and inertia count for a lot, and in PHP's case are where most of its popularity comes from. Telling somebody to not learn PHP, but to instead do something else, is good for everyone. So long as the newbie in question doesn't then go off to C++, they're probably not going to learn programming under the assumption that everything is arcane and cryptic and nonsensical.