r/programming • • Jan 31 '09

What if you can see how wrong that code is?

http://www.greatfunnypictures.com/pictures/2609_2768.jpg
0 Upvotes

133 comments sorted by

113

u/Null_State Jan 31 '09 edited Jan 31 '09

Stop upvoting this corporate marketing bullshit.

6

u/jones77 Jan 31 '09

Drink Coca-Cola.

17

u/averyv Jan 31 '09

best comment. would upmod again.

3

u/Joeboy Jan 31 '09 edited Jan 31 '09

Sentiment is sound, spelling's a bit off though.

Edit: sentiment and spelling now fine.

2

u/Null_State Jan 31 '09

Damn you spellchecker!

-1

u/G-Brain Jan 31 '09 edited Jan 31 '09

Wait, they did it wrong on purpose only to reach the front page of proggit? This was their plan all along! OH GOD WHAT HAVE I DONE‽

-2

u/dicey Jan 31 '09

Incorrect usage of Cuil interrobang.

0

u/[deleted] Jan 31 '09

[deleted]

1

u/[deleted] Jan 31 '09

Why do I always get smacked down when I say it?!

Shush, no complaining.

15

u/smika Jan 31 '09 edited Jan 31 '09

There's absolutely nothing wrong with this code in javascript, at least if you assume understanding it is empty and you understand nothing.

Cut and paste the following into an HTML document, and I'll show you what I mean.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
	"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>

	<title>Live</title>
	<script type="text/javascript">			
	function read_code() {
		var get = {
			a: {
				girlfriend: alert("You probably already have a girlfriend.")
			}
		}
		var understand = {};
		var you = understand.nothing;

		if (you == understand.this) {
			get.a.girlfriend;
		}
		return false;
	}
	</script>

</head>

<body>
	<pre>
		function read_code() {
			var get = {
				a: {
					girlfriend: alert("You probably already have a girlfriend.")
				}
			}
			var understand = {};
			var you = understand.nothing;

			if (you == understand.this) {
				get.a.girlfriend;
			}
			return false;
		}
	</pre>
	<form onsubmit="read_code()">
		<input type="submit" value="Read code" />
	</form>
</body>
</html>

10

u/G-Brain Jan 31 '09 edited Jan 31 '09

It might be valid Javascript, but my point is that a person being equal to the understanding of something doesn't make any sense, among other things.

17

u/smika Jan 31 '09

I need to work on my code humor, apparently.

1

u/ThePoopsmith Jan 31 '09

I appreciated it. You put the little snippet in the image into context. :D

5

u/pyry Jan 31 '09 edited Jan 31 '09

Maybe it should be something more like, you.understand(this) which returns true or false, then you.get(girlfriend), which submits an HTTP POST to popular dating websites' account creation forms. If you don't get a girlfriend, then it submits an HTTP POST to manhunt.com.

6

u/apollotiger Jan 31 '09

They’re not equal to the understanding of this -- they’re equal to the this of understanding.

3

u/[deleted] Jan 31 '09

Firefox runs it, Opera and IE7 don't.

3

u/[deleted] Jan 31 '09

but this alert gets called immediately, so even if you remove the “get.a.girlfriend;” part, you'll still get a message.

1

u/maxd Jan 31 '09

Nice work! And yes, thank you, I do.

0

u/[deleted] Jan 31 '09 edited Jan 31 '09

you should change it to something like this (but only FF will be able to run it then):

var get = { a: {} };
get.a.__defineGetter__('girlfriend', function() { alert("You probably already have a girlfriend."); });

1

u/smika Jan 31 '09 edited Jan 31 '09

The tougher part of the challenge for me was to try to see if there was any way that this could refer to something that could plausibly be an attribute of an understand object. (Assuming you play by the rules and aren't just setting your own this.)

I wasn't able to do it, so the only lame trick I could come up with was comparing two undefined values.

66

u/apollotiger Jan 31 '09

Obviously, it’s instructing those of the readers who can’t actually understand it to get a girlfriend because they’ve got no hope of a career in computer science.

Whereas the hackers will say “Am I equal to the this of understand? Nope! Guess I don’t have to read the girlfriend of a of get!”

63

u/markedtrees Jan 31 '09

I'd love to use their language.

hello.world;
get.names.from.the.server;
forget.to.hire.a.high.schooler.to.check.your.ad.copy;

10

u/Lizard Jan 31 '09

I bet a could use it to write a GUI for tracking IPs in no time at all!

5

u/joncash Jan 31 '09

In VB no less.

4

u/Snoron Jan 31 '09

I use VB GUIs for pretty much everything I do.

2

u/hiffy Jan 31 '09

Okay, we need to retire that meme stat or we're in danger of becoming slashdot, guys, and before we know it this is all filled with simpsons quotes, ??? profit steps and in Soviet Russia lamefests.

12

u/Snoron Jan 31 '09
  1. In soviet Russia, meme retires you.

  2. ???

  3. D'oh!

24

u/Dijkstracula Jan 31 '09

Nice try, Axe, but I thunk you'll find that Redditers only buy shitty deodorant whose ad campaigns insult us in incorrect Haskell.

4

u/nbloomf Jan 31 '09

Given the context, I'll go ahead and assume "thunk" was intentional. :)

1

u/Entropy Jan 31 '09

I hadn't thought about that until you mentioned it.

47

u/STOpandthink Jan 31 '09

get.a.girlfriend does nothing!!!

32

u/njharman Jan 31 '09

returns void;

8

u/[deleted] Jan 31 '09

Or worse, returns self

0

u/[deleted] Jan 31 '09

[deleted]

41

u/[deleted] Jan 31 '09 edited Jan 31 '09
if (you.understand(this)) {
   you.get(girlfriend);
}

Although this implies that understanding it will automatically get you a girlfriend, which I think was not the intended message :]

13

u/osiris99 Jan 31 '09 edited Jan 31 '09

Well I doubt girlfriend is defined.

#include <girlfriend>

if (you.understand(this)) {

you.get(new girlfriend);

}

17

u/teaguesterling Jan 31 '09

That's not enterprise enough. You need to use the GirlfriendFactory pattern.

11

u/redalastor Jan 31 '09

Just be careful to check that the instance you are getting is an object of the class Woman, you might be surprised at what can implement the Girlfriend interface.

2

u/[deleted] Jan 31 '09

Creating your own girlfriend? IKEA model?

2

u/[deleted] Jan 31 '09

Weird Science!

1

u/ModernRonin Jan 31 '09

Why do you assume it's C++? I mean, maybe we need to:

import "girlfriend.*";

(I'd like to "import all girlfriend", hur-hur...)

0

u/[deleted] Jan 31 '09

[deleted]

3

u/Lerc Jan 31 '09

in an imperfect world the parameters are:

size, intelligence, kinkiness.

perhaps?

4

u/[deleted] Jan 31 '09

Screw that man... Girlfriend *girlfriends = new Girlfriend[GF_MAX];

0

u/[deleted] Feb 01 '09

So when you stick your dick in her she overflows back to GF_MIN? No thanks!

1

u/[deleted] Feb 01 '09

No dude, an array of the maximum possible number of girlfriends.

1

u/[deleted] Feb 01 '09

Whoops.

1

u/neoice Feb 01 '09

haha, thats clever.

1

u/australasia Jan 31 '09

Parameters should be strings or upper-case constants.

2

u/Tordek Jan 31 '09

What's awesome is that in that "more correct" syntax, you can almost read it straight through.

2

u/harmonik Jan 31 '09 edited Jan 31 '09

But wtf is you? and the concept of this really doesn't make sense in that aspect! ughhhhhhhh.

You you = new You(self);  
if(you.Understand(this))  
{  
you.Necessities.Add(new Girlfriend());  
}  

6

u/pathogenix Jan 31 '09 edited Jan 31 '09

For heavens sake, people - the sense of the code is

if(you.understand(this))
{
  Assert.That(you.Girlfriend == null);
}

or possibly

if(you.Understand(this))
{
  you = new Man(new AxeDeodorant(), new Girlfriend());
}

I would counter that

if(you.Understand(that) && Axe.Customers.Contains(you))
{
  Assert.That(you.Age < 15);
  Assert.That(you.getType() == typeof(ScriptKiddy));
}

1

u/nousplacidus Jan 31 '09

this is the correct implementation.

1

u/[deleted] Jan 31 '09 edited Jan 31 '09

I really like your way, but you can also write their text with the correct connotation in legal code.

  • if (you.understand(this)) {

  • get.a.girlfriend; }

  • You could also use commas or something like that. Sorry for the formatting, I don't know how it works on reddit.

1

u/[deleted] Jan 31 '09 edited Jan 31 '09

although it is a tad better, you could improve a bit:

if (you.understand(this))

{

try

{

you.set(girlfriend);

}

catch (...)

{

you.fapfapfap(); /* no arguments */

}

}

EDIT: need to improve my markdown skills...

1

u/frogking Feb 01 '09
 if (!you.understand(this)) {
    you.get(girlfriend);
 }

this version follows the intended message..

1

u/NovaX81 Dec 26 '09

Would probably set a flag for next time the CRON job was checking who needed a girlfriend.

if(you.understand(this))
    you.setFlag(REQUIRE_GIRLFRIEND);

1

u/krizo Jan 31 '09

this is a pointer. So, it's more like

if(you == this->understand)

...

15

u/Entropy Jan 31 '09 edited Jan 31 '09

This ad isn't targeting programmers at all. It's written in pseudo-pseudocode that non-programmers would understand. They'll think to themselves "LOL nerds" and go buy more Axe. The advertiser even utilized the clickable link mouseover iconography to flip the slower or less computer-literate viewers into the correct context.

3

u/[deleted] Jan 31 '09

On closer inspect, I've determined that you are 100% correct.

11

u/[deleted] Jan 31 '09

I'm trying to imagine how someone would not be able to understand that. It was almost harder to understand as a programmer because of its nonsensical structure.

Also, why is their a pointing hand cursor under it?

3

u/IOIOOIIOIO Jan 31 '09

Also, why is their a pointing hand cursor under it?

Some people might look at that gibberish and not even make the connection to computers without the hint.

33

u/[deleted] Jan 31 '09 edited Sep 14 '24

bake piquant wine ask market modern encourage sharp marble brave

This post was mass deleted and anonymized with Redact

60

u/anachronic Jan 31 '09

Yep... their target market seems to be quasi-homosexual 13 year old boys.

5

u/[deleted] Jan 31 '09

quasi?

2

u/hiffy Jan 31 '09

Yes, I'm sure the gay boys are the ones who would find being chased by hordes of girls appealing.

1

u/[deleted] Jan 31 '09

And we've found ourselves an Axe user.

19

u/G_Morgan Jan 31 '09

I'm offended by how the code clearly does not convey the intended message of its writer.

If you are going to troll you should at least troll in an accurate manner.

1

u/[deleted] Jan 31 '09

Take the Onion's dolphin-cum-opposable-thumbs.

5

u/antiproton Jan 31 '09

You're offended?

How come stereotypes are funny until you're the object of the stereotype?

11

u/jahbeblessed Jan 31 '09

I think he's offended because the advertising practically advises him to cheat on his wife.

4

u/[deleted] Jan 31 '09

I don't see where he said he finds stereotypes funny.

4

u/anonjose Jan 31 '09 edited Jan 31 '09

You must have your comments set to invisible, if you had them on you'd have seen this:

Is this for real?

I'm actually pretty offended if it is (you can never tell these days).

I've been programming for almost 15 years and I am happily married... not getting a girlfriend any time soon.

...maybe I'm not their target demographic.

// Is it me, or are stereotypes fekkin awesome?

4

u/Enoxice Jan 31 '09 edited Jan 31 '09

It's like that Verizon commercial with the Italian family. You know, the one where the guy says, "He's not really my uncle, but he doesn't owe me money so he's a keeper." People were offended by that! Verizon had to cut out the "...but he doesn't owe me money..." because Italians complained.

People need to grow the fuck up and learn that a joke is a joke is a joke is a joke.

edit: Disclaimer: Half of my extended family is Italian. None of them were offended, as far as I know.

1

u/jumpy_monkey Jan 31 '09 edited Jan 31 '09

I've always thought Axe's target demographic is greasy men who didn't take showers and are trying to cover their stench with cheap cologne.

1

u/phughes Jan 31 '09 edited Jan 31 '09

I've thought it was pathetic (and not too bright) guys who don't understand that an aerosol body spray designed to smell good to them is somehow going to attract a woman.

13

u/[deleted] Jan 31 '09

get.a.girlfriend means nothing, and you == understand.this means MAYBE that you yourself are an understand object. This ad is written so that smug fuckers can read what looks like real code and laugh at nerds. You could be a first grader and figure out what the message is.

5

u/bludmuny Jan 31 '09

it keeps returning null

5

u/ThePoopsmith Jan 31 '09 edited Jan 31 '09

ad.designers.each do |designer|

designer.salary(:annual) -= 10000

end

print "Your boss is a geek: watch who you mess with."

11

u/G_Morgan Jan 31 '09 edited Jan 31 '09

So if I'm equal to understanding I need to retrieve the girlfriend member of the a member of variable get and do nothing with it?

I assume the writer meant something like

if(you.understand(this) {
    you.acquireGirlfriend(population);
}

22

u/swieton Jan 31 '09

You're missing a closing paren.

6

u/Philluminati Jan 31 '09 edited Jan 31 '09

or should they say:

DeodorantFactory ourDeodorant = new DeodorantFactory();

[...]

you.aquireGirlfriend(ourDeodorant.purchase(1))

and just give us the command to buy their product.

2

u/Entropy Jan 31 '09 edited Jan 31 '09

I still take issue with "this" as it is the object that the code is being evaluated in. Do I understand the side of the bus? Yes! What they're really trying to determine is whether the you can eval the code without throwing an exception.

if(you.eval(__FILE__) {
  you.acquireGirlfriend(population);
}

At that point, though, things get recursive so...

1

u/pathogenix Jan 31 '09

Not necessarily, in JS "this" refers to the current scope chain, not necessarily the object that contains the current method. It's quite easy to have "this" point to a completely different object - especially in bloody JQuery - and this has been the cause of some of my most colourful expletives in the office to date.

You can even set your own scope context with myFunction.call(newThisObject, params); to really confuse your UI team and remind them why they should have learned a proper language.

2

u/[deleted] Jan 31 '09

you.acquireGirlfriend(population)

Is it just me, or is "acquireGirlfriend()" a rather ominous name for a method? There's something about the word "acquire"...

2

u/tesseracter Jan 31 '09

target acquired. proceed with "operation rufies".

1

u/TearsOfRage Jan 31 '09

People do speak of being in a target-rich environment" when surrounded by people of their preferred sex.

4

u/[deleted] Jan 31 '09

Are they trying to tell me I'm a lesbian?

3

u/bigmell Jan 31 '09 edited Jan 31 '09

And that for some reason you would use a cheap adolescent male deodorant instead of something with class?

4

u/mercurytransit Jan 31 '09

It's classic nerdophobia. The ignorant always seek to mock people that are more clever than them in order to feel better about themselves.

7

u/xachro Jan 31 '09

I would have read the code. But I refuse to read anything without documentation. What does it do?

7

u/whozurdaddy Jan 31 '09

void main(void) { int girlfriend; int money;

girlfriend = 0;
money = 100;

while (money > 0)
{
   girlfriend += money;
   money--;
}

}

1

u/Norseman2 Oct 27 '09

This will take $100 from you and give your girlfriend $5,050.

2

u/jasonbrennan Jan 31 '09

I think everyone here is missing the point...

2

u/sebnukem Jan 31 '09

I don't get it. I'll ask my GF to explain it to me.

2

u/krum Jan 31 '09

Yea I don't think that would make my wife too happy.

2

u/gregK Jan 31 '09

Regardless of the syntax errors, I resent that ad for promoting the idea that it's not OK to go into CS. I mean, I don't care cause any shortage of developers is a good thing for me. But that can't be good for the economy in the long run.

Anyways what is AXE promoting? That it's not ok to be smart? You'd think advertisers would be aware that the bush era is over.

2

u/tjogin Jan 31 '09 edited Jan 31 '09

I hate it when pseudo code doesn't make any kind of sense (which is always). When the fuck would the object "you" be equal to the method "this" on the "understand" object?

1

u/bigmell Jan 31 '09

I need a girlfriend?!? OMG I am insulted! And the code is wrong anyway IDIOTS! /sarcasm

1

u/[deleted] Jan 31 '09

What? This isn't in Lisp? You can totally get a girlfriend unless you grok this (or use grok for that matter):

(defun lame-ad (you)
  "Provides life advice"
  (if (understand-statement-p you)
      (format t "~a: seriously, get a ~a-friend"
              (get-name you)
              (if (gay-p you)
                  (get-gender you)
        	      (get-opposite-gender you)))
      (format t "You're all set.")))

2

u/stepcut251 Jan 31 '09

but javascript is lisp -- with funny syntax:

http://bc.tech.coop/blog/030920.html

1

u/aaallleeexxx Jan 31 '09 edited Jan 31 '09

I don't know why you people are bitching, the code is obviously in R.

1

u/GuybrushThreepwood Jan 31 '09

What if you have to ask your girlfriend why it's wrong?

:(

1

u/[deleted] Jan 31 '09

Service Unavailable.

1

u/[deleted] Jan 31 '09

It is clear why this ad guy never made it into CS.

1

u/[deleted] Jan 31 '09 edited Jan 31 '09

The add is not funny, but seeing computer nerds getting angry because of the syntax is hilarious.

1

u/SuperKing Jan 31 '09

Needs comments.

-1

u/cray Jan 31 '09

well, it's crappy code.

if(you.can see = how wrong this code is) { you.need = girlfriend; }

6

u/[deleted] Jan 31 '09

if(you.can see = how wrong this code is) { you.need = girlfriend; }

Congratulations, that was even worse. I didn't even think it was possible.

-1

u/mahlzeit Jan 31 '09
If You = Understand.Me Then
    Get.A.Girlfriend
End If

-1

u/[deleted] Jan 31 '09

the code looks legit, except for the fact that the syntax highlighting indicates that the "this" in "understand.this" is the reserved word this, which can't be used in that way(I think).

-1

u/[deleted] Jan 31 '09

bool needGirlFriend = (you == this.understand) ? true : false;

1

u/[deleted] Jan 31 '09

I hate it when I see this, almost as much as:

if (whatever) return true; else return false;

Wth?!

1

u/[deleted] Jan 31 '09

Ya, I don't like them much either. nobody posted an inline 'if' yet, so I felt I had to.

Even worse is when there is more logic around the :

-5

u/theanti9 Jan 31 '09

should be this.understand. and girlfriend.get()....lol

1

u/[deleted] Jan 31 '09

That could potentially do something, but please don't write code like that - it would be really annoying to work with.

-2

u/averyv Jan 31 '09 edited Jan 31 '09

girlfriend.get() makes zero sense. the girlfriend object isn't getting anything, unless girlfriend.get(a_boyfriend) where a_boyfriend == you.

if i were writing it (and let it be known that i am a rubyist), it would come out like this:

if(you.understand(this)){
  you.need { |to|
    to.get(a_girlfriend)
  }
}

where the need method stores the block passed, yielding the person instance referenced by 'you' into the block.

girlfriend is a set of attributes one might desire in a girlfriend and the 'get' method on you searches for an instance of a person (or an object if the girlfriend structure somehow defines that it is looking for a person) that satisfies as many of those as possible.

1

u/Nexum Jan 31 '09 edited Jan 31 '09

if ([you understands:self) { // self rather than this in Obj-C

[you setNeedsGirlfriend:YES];

}

-5

u/theanti9 Jan 31 '09

should be this.understand. and girlfriend.get()....lol

-1

u/[deleted] Jan 31 '09

Then you can forget about the girlfriend

0

u/[deleted] Jan 31 '09

[deleted]

5

u/Shade00a00 Feb 01 '09

You keep throwing that exception. I do not think it raises what you think it raises.

2

u/fibbery Jan 31 '09

MateWeight.Chunky

:(

4

u/ThePoopsmith Jan 31 '09

Yeah, she'd be skinny, young and hot if he wrote it in ruby.

1

u/[deleted] Jan 31 '09 edited Jan 31 '09

[removed] — view removed comment

3

u/[deleted] Jan 31 '09

Yeah. It's sort of like that spray you use to keep animals from pissing on stuff. But for ladies.

3

u/IOIOOIIOIO Jan 31 '09

What if you want the ladies to pee on you, though?

1

u/[deleted] Jan 31 '09 edited Jan 31 '09

Then you should not wear Axe. Instead, wear a shirt which says "Ladies, listen up. If you want to pee here... well, that can be arranged.", with an arrow pointing at your preferred body part for being peed on.

1

u/IOIOOIIOIO Jan 31 '09

Just have it put on a hat.

1

u/[deleted] Jan 31 '09

In that case, you don't need nearly so much verbage. Just have a hat shaped like a toilet (it is a novelty hat) which says "Ladies only, please."

Er, you might also want to put a "No pooping." on there for good measure.

1

u/IOIOOIIOIO Jan 31 '09

Who do you think I am? Mayo Callahan?