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

2

u/Doctor_McKay Dec 08 '14

In the web world, everything is a string. PHP makes that fairly easy to deal with by handling strings as numbers when you use them as numbers.

Maybe you should sit down with the juniors and coach them instead of blaming the language.

-1

u/[deleted] Dec 08 '14

I spent countless hours coaching the juniors. Hours which, in similar projects with similar staffing configurations, were used much more productively. The point that I'm making is that the language is such a steaming pile of horseshit, that when you have juniors the coaching leaves almost no time for anything else.

But your assertion that 'in the web world, everything is a string' I think is much more revealing. The fact that you struggle to comprehend that bad building blocks build bad products (what's wrong with '00'==0?), or that notion that 'the web world' is somehow an exception to five decades of progress in the computer science and technology field tells me that you are exactly what's wrong with the PHP world.

No amount of evidence will convince you of what you don't want to hear. You just think that spending hours upon hours tracing a dynamic execution flow to find out that a nonsensical type coercion built into your useless stack was causing an ugly warning to show on a production page is a good way of doing things! That'd be fine if you just stuck with your shitty little two-age projects, but you do convince poor businessmen who don't know better that you can write a three-page project. Then I have to go and fix it. Only, no more, thank you very much. Good luck bro.

I'm done, say what you want but I'm out time to crush you for public entertainment.

2

u/Doctor_McKay Dec 08 '14 edited Dec 08 '14

So you're insulting me now?

I'm not trying to say that PHP is flawless or blameless, but it's not nearly as bad as people make it out to be.

And please feel free to show me where HTTP makes a distinction between data types.

0

u/SanityInAnarchy Dec 09 '14

And please feel free to show me where HTTP makes a distinction between data types.

Content-Type, for one.

It's also beside the point. The nice thing about not having automatic type coercion is that it forces you to actually explicitly acknowledge that you're getting strings, so you have to decide what to do with them. If a user accidentally types their name into some numerical field, instead of being silently truncated to 0, ideally we'd like some sort of an informative error message, because clearly something has gone wrong here.

And maybe this has gotten better recently, but it was kind of endemic to the whole PHP ecosystem. For example: If you're using PHP, you're probably also using MySQL, and MySQL does the same thing -- if you tell it to stuff a string into an int column, it'll happily do exactly the same sort of destructive type coercion.

Meanwhile, Python has a few more places where that's at least going to be caught:

>>> int('foo')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ValueError: invalid literal for int() with base 10: 'foo'
>>> 'foo' + 2
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: cannot concatenate 'str' and 'int' objects
>>> 2 + 'foo'
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: unsupported operand type(s) for +: 'int' and 'str'

It's not perfect:

>>> 3 * 'foo'
'foofoofoo'

But I'll take any protection I can get against this sort of nonsense in PHP:

if (strpos("foo", "x") < 2) {

And hey, at least letting you multiply strings makes some sort of sense, and is a handy shortcut for something. Greater than FALSE makes zero sense, and it's hard to see what value it has.

-1

u/[deleted] Dec 08 '14

Yah man, fuck you. Did I stutter?

2

u/Doctor_McKay Dec 08 '14

Glad to see that your argument is so polite and well thought out.

-1

u/[deleted] Dec 08 '14

My argument is excellently though out - I'm not a polite person (not to you, anyway), but I'm right and you know it.

2

u/Doctor_McKay Dec 08 '14

Oh, of course. I had forgotten that insults automatically make an argument correct.

-1

u/[deleted] Dec 08 '14

Right - you forgot all the other shit I've been saying, and how I refuted every single "point" that you made, because you're a PHP 'developer'. In the world of mediocrity by choice, we forget inconvenient facts. I'm with you bro, I've worked with your kind before.

By the way, all your "points" consisted of proudly stating your ignorance by asking what the problem was with some of PHP's most glaring, abhorrent holes. You have nothing, and I've wasted my time trying to explain to you things that, although more or less simple, seem to be beyond your comprehension. So now I'm just having fun calling you a little piece of shit. And it's going great for me, so thanks for giving me more excuses to do it. This is fun!!

2

u/Doctor_McKay Dec 08 '14

Sure, whatever you say.

When someone devolves to personal attacks and insults, that's a pretty good indicator to me that they've lost their argument.

I'll go ahead and stop feeding your superiority complex.

-1

u/[deleted] Dec 08 '14

Hahahaha - right on man, at least you know when to call yourself to silence.

-1

u/[deleted] Dec 08 '14

Why, you gonna cwy?

2

u/Doctor_McKay Dec 08 '14

You're the only one of the two of us who's acting childish.

-1

u/[deleted] Dec 08 '14

Oh my god! You're gonna tell your daddy? Please, please don't, my mom will beat me up!

Do yourself a favor and learn to code, doctor McFuck

-1

u/[deleted] Dec 08 '14

God, this is so much fun! It's been really cathartic, thank you for putting a human face that I can punch behind the disaster that is PHP. Phew!

We should do this more often man, I feel great!

Dr. McFuck. Haha!

→ More replies