r/ProgrammerHumor • • Sep 23 '19

Knowing how to code beforehand

Post image
7.6k Upvotes

264 comments sorted by

View all comments

322

u/lordheart Sep 23 '19 edited Sep 24 '19

Had a professor give us code to complete that didn't compile when uploaded to the auto checker but did on my computer.

Why? Umlauts. The prof wrote comments in german. My computer compiler didn't care.

Their online checker spit out vague mysterious errors. Because comments...

Edit: OMG typo made it so hard to understand. thanks bobcob, what would I do without you.

115

u/[deleted] Sep 23 '19

Ah, the fun of unicode support.

27

u/Clydseph_III Sep 23 '19

I had an error for days because we were supposed to copy down a couple lines from the spec pdf, which had different quote marks for begin and end quote rather than the basic straight up ones.

21

u/SubliminalBits Sep 23 '19

Another fun time you'll run into this is when you copy code out of an email in Outlook.

4

u/TracesOfGuitar Sep 23 '19

Care to explain?

14

u/ParkerM Sep 23 '19

The MS Office suite is notorious for sneakily converting ASCII characters into their more readable/pretty Unicode versions.

e.g. "foo" becomes “foo”, -h becomes —h (hyphen gets converted to emdash), etc.
The hyphen one is especially fun because it's damn near indistinguishable depending on the font.

5

u/SubliminalBits Sep 24 '19

They'll keep looking pretty in all your unicode compatible editors too. One time I was so frustrated I looked at the raw string as hex, at which point everything seemed so obvious.

→ More replies (1)
→ More replies (1)
→ More replies (1)
→ More replies (3)

31

u/Lidex3 Sep 23 '19

I used to work for a professor as tutor and correct some assignments of first year students. The Plattform where the students should upload their code didn't support Unicode. So every time I downloaded the files and tried to run them they won't compile. Reason for that is that even tho we told the stundens over and over again to not use ä ö ü or any other special characters most of them just named alle their functions with special characters inside.

They even did that after I removed points from a perfectly fine assignment with the only mistake being a special character.

20

u/scotchirish Sep 23 '19

Man, after the first time my instructors would have given a 0 since it couldn't compile.

15

u/[deleted] Sep 23 '19

As they should, since the students aren't following basic directions.

25

u/[deleted] Sep 23 '19

Just turn in your computer for the assignment 🤷‍♂️ That’s what we do in production whenever a feature “works on my machine “

46

u/Cheet4h Sep 23 '19

The origin of Docker.

9

u/napstablooki Sep 23 '19

The real life hacks are always in the comments.

0

u/[deleted] Sep 23 '19

[deleted]

→ More replies (4)

16

u/[deleted] Sep 23 '19

Oof

22

u/notfromchicagoornyc Sep 23 '19

//ja das ist nicht gut. Ich müsste hier besser Code schreiben. //ZUTUN: macht das Funktion schneller

Duolingo German is not helping much :(

20

u/regendo Sep 23 '19

It's pretty good actually, you just got two small errors in the last sentence.

  1. Function is grammatically female so it'd be "die Funktion".

  2. Your sentence translates to "makes the function faster". It implies that the code you're commenting on is making the function run faster, when you probably meant "[to] make the function faster" ~ "die Funktion schneller machen".

I really hope nobody would actually write a // ZUTUN: comment instead of // TODO: but honestly I wouldn't be surprised.

10

u/z500 Sep 23 '19

I really hope nobody would actually write a // ZUTUN: comment instead of // TODO: but honestly I wouldn't be surprised.

Sounds like something r/de would do

→ More replies (4)

4

u/[deleted] Sep 23 '19

if it makes you feel any better my highschool spanish is probably worse. Yo toco el guitarro con mi pene gordo

6

u/ponodude Sep 23 '19

That takes true skill

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

6

u/Kered13 Sep 23 '19

I believe C/C++ compilers are only required by the standard to support ASCII characters. Any other character set support is at their discretion.

8

u/Calkhas Sep 23 '19

I believe C/C++ compilers are only required by the standard to support ASCII characters.

This is kind of true but actually slightly too strong.

C does not require an implementation to support ASCII (because of EBDIC). C has wording like "the representation of each member of the source and execution basic character sets shall fit in a byte." (5.2.1/3), and it specifies ninety-six characters that the implementation must have in its character set, but neatly elides saying how those characters should be represented. C defines both a "basic character set" and allows optional "extended character sets".

Since C11, we also have "an implementation may allow multibyte characters that are not part of the basic source character set to appear in identifiers; which characters and their correspondence to universal character names is implementation-defined." (6.4.2.1/3).

C++ handles this a bit differently. Since C++11 we are required to allow some "universal-character-names" (e.g., \u89ab) in identifiers. These map directly to the unicode standard. During preprocessing, each non-basic source character is expanded to a \uXXXX code point, but it is up to the implementation whether or not it accepts it.

4

u/Kered13 Sep 23 '19

Ah, that damned EBCDIC strikes again! Every time you assume that the basic ASCII characters are universal, EBCDIC is hiding just around the corner ready to prove you wrong.

→ More replies (3)
→ More replies (1)

5

u/ponodude Sep 23 '19

How does that work? Did the checker not recognize that it was a comment? Why did it not just skip over the comments?

Edit: Ooooohhhh Unicode. Still, what the fuck. That's dumb.

→ More replies (1)

3

u/Dagreiyo Sep 23 '19

Reminds me of a test I wrote. Everything worked on my machine, so I turned it in early. Got an F because the program didn't work on my prof's Mac Book. I complained and got a B. Still think it shouldve been an A.

→ More replies (3)