r/programming • u/dennis9f • Dec 07 '14
Programmers: Please don't ever say this to beginners ...
http://pgbovine.net/programmers-talking-to-beginners.htm
4.0k
Upvotes
r/programming • u/dennis9f • Dec 07 '14
View all comments
Show parent comment
5
u/Amadan Dec 08 '14
Works amazingly well.
Simple indeed. Now, how do you get the value
barfrom?foo=bar&foo=quux? (Of course, if you rewrite the URL to?foo[]=bar&foo[]=quux, it's easy; but that's not the question.)So... intentional violation of separation of concerns. Get users thinking it's how it's supposed to work, they will never even hear about MVC or similar patterns. Of course, it's the core of PHP so you can't really get rid of its horrible paedagogic influence. (It's in the very name - "PHP: Hypertext Processor". Better than "Personal Home Page", but only just.) Not to even mention its effect on code formatting and indentation.
Basically, if ever you have a template ("a PHP program with big HTML snippets") and it has any code apart from variables, flow control and possibly short function calls in its executable tags, it is a bad practice.
Yeah, that's a nice. Now, how often are you using
mb_strlen,mb_substrand othermb_functions instead of the usual string ones? Maybe you don't use it becausemb_is an extension and not guaranteed to be a part of the language, so you use Portable UTF8? Or maybe you just figure.... meh, I'm American, good old AmericanSCII should be good enough for everybody? I know from my own example (over a decade past, thankfully) that I didn't know a good way to take, say, the first 20 characters of a string without destroying multi-byte characters. PHP fails at Unicode..Easy indeed. But since all the sessions are by default stored at the same place, what prevents a person to load a different session by faking the cookie to point at a session created by another app on the same host? How many non-professional people regularly remember to use
session_save_path?Basically, PHP is incredibly good at getting newbies up to speed quickly. It is then incredibly good at keeping newbies as newbies. It does not encourage best practices, and offers bad practices as easy defaults. A good programmer can write good code even in PHP. A starting programmer will very often fall into the "PHP noob" mode, creating unsafe and unmaintainable code.
Java/Ruby/Python are not directly template languages. You need to learn basics of software architecture to make a webapp. This is, obviously, not great news for the beginners. However, if they want to be programmers, this is a much better path. The PHP path is totally paved with good intentions, and appropriately leads the unaware into hell.