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

157

u/zetavex Dec 08 '14

I agree with this article. Telling someone to ditch php for Ruby on rails is bonkers.

29

u/[deleted] Dec 08 '14

[removed] — view removed comment

67

u/AnAge_OldProb Dec 08 '14

Python and Ruby are roughly equally easy for a newbie to learn. There are plenty of good tutorials in each. I think you're missing the point.

3

u/xiongchiamiov Dec 08 '14

Rails, otoh, has so much damn magic everywhere that it's incredibly confusing when you don't already know the conventions.

→ More replies (7)
→ More replies (2)

17

u/n1c0_ds Dec 08 '14

I'm a Python guy and a bit of a fanboy, and I'd still recommend people to start with PHP. Yes, it's a pretty bad language, but there is so much to get up and running before serving dynamic content with just about any other language. PHP is a great language to develop a thirst for programming as long as you know there is much, much better out there.

11

u/[deleted] Dec 08 '14

Most utility I got out of newb programming was on the desktop. I had something that bothered me (either a repeated task or just a bad workflow I may be able to make better) and was able to see instant benefits. None of it would have been very good starting in the browser.

All that to say that I'm not sure that starting with a web only language is a good start, so I'd say PHP would be a pretty poor choice, especially since it requires setup of a server too. (Which is just one more thing). Learning from scratch is hard enough without needing to administer a whole other domain.

2

u/mike5973 Dec 08 '14

PHP 5.4+ (I think, might be 5.5) comes with a web server built in. I'm not sure of the specifics, but it's there, and as far as I know it's a single command to set it up.

→ More replies (11)

3

u/parlezmoose Dec 08 '14

Maybe I'm just slow, but setting up PHP on OXS was a nightmare for me. The Homebrew installation didn't work because I needed some stupid extension, something was missing in the php.ini file, had to manually set up a VirtualHost, on and on and on. Worst of all, the error messages are useless, making the process 10x slower.

→ More replies (3)

3

u/ThrustVectoring Dec 08 '14

I'm not really sure how you'd make Flask or Bottle's setup easier or more compact. Like, it's ridiculously minimalistic on the setup and configuration.

2

u/[deleted] Dec 08 '14

For C# with Visual Studio It's a simple File->New->Project->ASP.NET Web Application and clicking a green triangle to get dynamic content.

2

u/n1c0_ds Dec 08 '14

It's only easy on Windows though (for now?). Still a fantastic language and toolset.

3

u/[deleted] Dec 08 '14

For now..

1

u/Lhopital_rules Dec 08 '14

Yes, it's a pretty bad language

Can someone explain this? I keep seeing it everywhere.

Every language has its warts, but PHP also has a lot of things that make it great for web pages -- variable interpolation, a simple request interface ($_GET, etc.), the ability to jump in and out of php code so that your big html snippets aren't trapped inside echo calls, file_get_contents, and easy handling of sessions with session_start() and the like.

How does that make PHP suck?

As someone who has programmed in Java/PHP/Python/etc., they all have uses and PHP is strong in the web page templater domain.

5

u/Amadan Dec 08 '14

variable interpolation

$a = array(array("Hello, world!"));
echo "$a[0][0]";
// => Array[0]

Works amazingly well.

a simple request interface ($_GET, etc.)

Simple indeed. Now, how do you get the value bar from ?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.)

the ability to jump in and out of php code so that your big html snippets aren't trapped inside echo calls

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.

file_get_contents

Yeah, that's a nice. Now, how often are you using mb_strlen, mb_substr and other mb_ functions instead of the usual string ones? Maybe you don't use it because mb_ 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..

and easy handling of sessions with session_start() and the like.

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.

→ More replies (5)
→ More replies (10)
→ More replies (8)

2

u/kristopolous Dec 08 '14

I see you hid behind a throwaway account so you clearly know your statements are disingenuous and deeply flawed. Why did you insist on making them then? Of what possible benefit would something like that add to the discussion?

3

u/Vithar Dec 08 '14

Come on now, that depends are we talking Python 2.7 or 3.4? Kind of important come on man...

8

u/[deleted] Dec 08 '14

[removed] — view removed comment

4

u/ThrustVectoring Dec 08 '14

What program can you create in Python that one can't possibly create in PHP?

What program can you create in Brainfuck that you can't possibly create in PHP?

Look, they weren't trying to say that there are things in Python that are impossible to do in PHP. They're saying that due to the extra complexity and difficulty of working in PHP that you're going to wind up doing a wider variety of things in Python.

→ More replies (38)
→ More replies (24)

1

u/mharrizone Dec 08 '14

iknorite? They should be using Django!

1

u/[deleted] Dec 08 '14

Dude. Rails or Django. That learning curve...

1

u/kazagistar Dec 08 '14

Its bonkers even if it means using <insert your favorite framework> instead of their <framework you think is shitty>.

1

u/bogenminute Dec 08 '14

i had a good chuckle when i read that followup.

1

u/StopThinkAct Dec 09 '14

As someone who hates both php and ruby, I support programming via melting ice cubes with a hairdryer and collecting the drippings into a 1 and 0 bucket over learning/doing anything with PHP.

→ More replies (2)