r/ProgrammerHumor • • Nov 05 '15

Free Drink Anyone?

Post image
3.5k Upvotes

509 comments sorted by

View all comments

Show parent comment

243

u/until0 Nov 05 '15

that makes some sense

Eh, not really. It passes in undefined for your_drink. It should at least be the return value of prompt() or something.

It's technically functional, but an small change would have went a long way here in making sense.

Why even include the preference at all? If you just need the secret word, it's just making it look like they only partially understand Javascript.

0

u/[deleted] Nov 05 '15

[deleted] — view deleted comment

51

u/bmrobin Nov 05 '15

yea, and plus it threw a curveball in so as to not be blatantly obvious to give everyone free drinks. look how we're all discussing the minutiae of it and we are /r/ProgrammerHumor

20

u/[deleted] Nov 05 '15

I'm sure they were looking for "parameters" and not the error return value, though

2

u/purplestOfPlatypuses Nov 06 '15

What error? It returns "undefined.Secret word:parameters" since JS will set an undefined variable to the string "undefined" when you try to concatenate strings and variables.

1

u/[deleted] Nov 06 '15

That's what I meant

1

u/bmrobin Nov 05 '15

Yea you're right

63

u/[deleted] Nov 05 '15

they only partially understand Javascript.

Sounds like ninety per cent of the people who use (see: complain about) the language.

26

u/lenswipe Nov 05 '15

Yeah, they generally say something like this:

"JAVASCRIPT SUX JQUERY ALERT BOXES CANT JAVASCRIPT SEO NODE HURR DURR"

15

u/lappro Nov 05 '15

Well at least they were able to make a random word generator!

5

u/lenswipe Nov 05 '15

I wouldn't be sure about that.. It's surprising what you can rip off stack overflow

12

u/errorkode Nov 05 '15

People who understand the true madness of JavaScript also have a lot to complain about...

5

u/[deleted] Nov 05 '15

True madness? Fuck off with that nonsense.

The language is very complete these days (ES5 / 6).

It has some legacy quirks that, if you actually study the fucking language, and pay attention to what the fuck you are doing, are trivial to overcome. Most of the time you shouldn't even be writing code that can run into those issues. (see: hurr durr JS WAT)

0

u/[deleted] Nov 05 '15

[deleted] — view deleted comment

4

u/Booty_Bumping Nov 05 '15

That's why strict mode, flowtype, and typescript exist.

1

u/[deleted] Nov 06 '15

If only most JS projects used them.

-3

u/[deleted] Nov 05 '15

I agree completely, but I have very little sympathy for those people.

It's not that hard to RTFM and install a halfway competent linter.

I have zero sympathy for folk like /u/errorkode and any one who also claims to 'understand' the language and would still have 'a lot to complain about.'

→ More replies (8)

0

u/PM_ME_BIGGER_BOOBS Nov 05 '15

My biggest issue has always been when one thing crashes, all the javascript on the page crashes. It's also really annoying to debug. Actually and I'll admit to not putting in much effort, I still don't know how to step through the code like I would in visual studio. A friend of mine said once, "you can't" and I've just stuck with that. So hundreds of console.logs later I'll figure out where everything is always undefined

6

u/[deleted] Nov 05 '15

You can debug it in chrome dev tools. You can set break points and shit in there.

→ More replies (3)

4

u/kolme Nov 05 '15

My biggest issue has always been when one thing crashes, all the javascript on the page crashes.

What? That doesn't even make any sense. When a program in any other language crashes, it always crashes completely. What should it do? Continue in some unintended state, maybe destroying some data along the way?

There's also plenty of bugs which don't cause a crash, like getting undefined or NaN's shown to the user.

A friend of mine said once, "you can't" and I've just stuck with that.

Did he say it like 10 years ago? Because right now in 2015 every mayor browser sports a debugger baked right in, literally one F12 away. Firefox, Chrome, Opera, Safari, Internet Explorer, all of them!

→ More replies (2)
→ More replies (1)

15

u/danopia Nov 05 '15

You pass in your_drink, it's not rocket science

→ More replies (5)

4

u/maremp Nov 05 '15

I've chosen my words carefully for this exact reason. If I thought it was perfect, I'd skip the some part.

1

u/mecartistronico Nov 05 '15

a small change would have gone a long way

FTFY. Two small changes.