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
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”,-hbecomes—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.
3
2
u/Sleepy_Tortoise Sep 23 '19
MS office programs replace your quotes with fancy quotes that look different at the beginning and end of the quote. This is not the same character as the quote that you type with your keyboard. It is also not the same quote character that is recognized as code
3
u/fushuan Sep 23 '19
Most pdf generators require you to write quotes in weird ways. Anyway, how the hell did you spend days with wrong code highlighting wordering why? Or even worse, do you code on notepad??
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
25
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
9
16
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.
Function is grammatically female so it'd be "die Funktion".
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
3
u/EternallyMiffed Sep 23 '19
Why is function gramatically female and not neuter?
5
u/VincentPepper Sep 24 '19
Gender for objects is essentially arbitrary in German.
To make it more fun it can also vary by region/country when it comes to everyday use.
→ More replies (1)2
4
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
3
2
u/Brawldud Sep 23 '19
// Solange mein Programm nicht kompiliert werden kann, gibt es nur ein Bug. Wenn es aber kompiliert werden könnte, würde es dann viele Bugs geben.
1
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.
1
u/Finianb1 Sep 24 '19
EBCDIC is awful. Why would anything still want to support it anymore? Like, cut your losses and stop inconveniencing the vast majority of programmers who couldn't give a damn whether their programs are compatible with obsolete IBM products.
3
u/Kered13 Sep 24 '19
You can say that, but I'm pretty sure there is still some poor sod out there who has to write software that runs on EBCDIC machines.
→ More replies (1)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.
1
u/lordheart Sep 24 '19
Yep, wierd. It was Java too. So the Java compiler on my computer apparently didn't care. But their system failed.
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.
2
u/ThePfaffanater Sep 23 '19
Fun fact, that same thing broke my robotics team's code once. Apparently "Röbor" is not appreciated by the java compiler...
3
0
0
Sep 23 '19
[deleted]
1
u/Finianb1 Sep 24 '19
Why were you writing Pascal compilers? That seems like a weird project.
0
Sep 24 '19
[deleted]
1
u/Finianb1 Sep 24 '19
Hmmm. I would think they'd want you to do something with your own language, to make it a little more personal. Also, it'd be less boring than grading 30 Pascal compilers.
2
49
u/Irravian Sep 23 '19
I worked somewhere with a very old codebase and large defect rate that more often than not led back to things like "when this code was written 9 years ago we didn't need to / didn't bother to check for null!". I tried adding a "No new warnings" requirement to our pr checklist to start softly heading off the problem but it was always overridden by the reviewer and I didn't have sufficient buy-in to really really force the devs to do it.
It took an actual crisis with complete client database loss and the involvement of our very angry company president to get the change done. New development was shut down for almost two months while we did a warning and hardening pass.
And the defect rate plummeted. We went from having months with triple-digit user reports to months with zero. It was an awesome "I told you so" moment. I was hailed as a visionary hero and everyone clapped I was let go because dev management felt I'd sold out the devs to upper management to kiss ass and that the new requirements slowed development time too much.
0
Sep 24 '19
[deleted]
6
u/Irravian Sep 24 '19
It was bizarre. I genuinely don't think they thought it would work. I have so many fun stories just from those few months. They found an entire feature that they'd written and forgotten about that was hidden because it was added to a menu-list that was no longer in-use. One of our screens went from a seconds-long load time to instant when they fixed an issue causing an exception in every single WinForms Paint() call. A custom control had a static array of brushes that was created for each instance, sometimes dozens of times on the same screen, and was completely unused and never freed. I don't remember exact numbers but the memory footprint of the whole app dropped dramatically by the end. All that from ignored warnings.
45
u/fat_charizard Sep 23 '19
For my CS classes all code had to be compiled with -Wall and -Werror
55
u/TopHatEdd Sep 23 '19
Good. That builds healthy coding habits.
6
u/while_e Sep 23 '19
Also great for learning. I cant count how many times I got warned, and learned something new because of it.
14
u/CarilPT Sep 23 '19
Until you get out in the real world and those habits are not used anymore...
5
u/Deathcofii Sep 24 '19
Is it a bad thing tho? I mean I feel REALLY satisfied when -Wall and -Werror don't spit out anything in my code.
1
u/CarilPT Sep 24 '19
Well... It's great when you do a small project. When you get your hands on a code base with 10/15 years and you see 3000 warnings and you need to fix x, y and z... Well it's not so easy to do sadly
30
186
Sep 23 '19
Warnings are, generally speaking, as important as errors. They are errors waiting to happen.
98
u/AudaciousSam Sep 23 '19
Not in Android Studio they aren't.
85
u/lacb1 Sep 23 '19
In Visual Studio sometimes the errors aren't even really errors, never mind the warnings.
34
23
Sep 23 '19
Sometimes I fix an error and it doesn't go away. Restart VS and voila! It's gone!
10
u/user_8804 Sep 23 '19
Eclipse on Linux is worse. Sometimes I have to save build compile reindex restart the program until it wakes the fuck up
→ More replies (13)6
u/airelfacil Sep 23 '19
Android Studio: Pssst! Just so you know, you're missing all of these translations and also you should probably use @string instead of hardcoded string, and just letting you know that one of your methods is never used, and also that if statement could be made much simpler and...
Me: I DON'T GIVE A SHIT I'M TRYING TO MAKE THIS BASIC GUI APP FUCKING WORK SUPPRESSWARNINGS DO YOUR JOB
1
0
Sep 23 '19
[deleted]
4
u/AudaciousSam Sep 23 '19
Right, those needs to be fixed. But there are also: Should be String errors that isn't strictly important, until you need to translate and such.
35
u/Yuzumi Sep 23 '19
Someone doesn't use Java :p
For that matter, the project I work on has over 4000 warnings and a good number of them we didn't cause but the software we build on top of did.
12
u/samspot Sep 23 '19
My experience with java warnings is very good, and you can suppress the unfixable ones. We thought there weren’t enough warnings so we added sonar on top!
10
u/Danelius90 Sep 23 '19
My view is that certain warnings, when suppressed are basically programmer assertions. For example the heap pollution for varargs warning. If you can 'prove' or assert you are handling the array carefully and not polluting the heap the suppression is you saying "yes we could pollute the heap, but we aren't".
It really gets me when devs suppress deprecation warnings though...
4
u/ParkerM Sep 23 '19
It really gets me when devs suppress deprecation warnings though...
Simple, just suppress deprecation warning suppressions.
7
u/fushuan Sep 23 '19
The project I was given once had 1000 warnings. Unsurprisingly most of them could be refactored or solving 1 solved 200 at once etc.
You are just lazy
1
u/Bainos Sep 23 '19
but the software we build on top of did
Doesn't apply to class projects... (Unless they also use Android libs.)
7
u/Intrepid00 Sep 23 '19
Just do what they did with wing Commander that would throw a warning on exit. Hex edit the warning to say instead thanks for playing.
12
u/smcarre Sep 23 '19
How is a class not being capitalized or an unused variable an "error waiting to happen"?
31
u/Salanmander Sep 23 '19
So, here's what it really boils down to.
A warning that you understand is fine.
A warning that you don't expect is often indicative of a logic error, rather than a syntax error.
If the unused variable is there because you're saying "I'm going to implement this check, but I want to test the other things first", fine. If it's there because you just forgot to implement the check, then it's a ticking time bomb.
→ More replies (4)4
u/chinpokomon Sep 23 '19
And use attributes and directives, depending on the language/compiler, to allow the warnings you know about and leave a comment. This way, when you get a warning you don't understand, it might point out a problem you don't realize.
1
1
3
u/Lothrazar Sep 23 '19
Not at all. 90% of the time its because of some third party dependency you are using, which means its not your code but its code you rely on. Literally unfixable
For example i have 50 warnings looking like this right now
"Overriding managed version 3.5.5 for liquibase-core"
Over and over and over again
1
3
u/MrPyber Sep 23 '19
"build targets java 1.7, host jdk is 1.8".
1
3
u/LeCrushinator Sep 23 '19 edited Sep 24 '19
And if you allow warnings to build up, then you're never going to notice when an important one shows up, you'll just be ignoring warnings because you've allowed them and now there are hundreds.
1
u/NPPraxis Sep 23 '19
It depends. I feel this way in XCode. I don’t feel this way in Android Studio.
1
0
Sep 23 '19
[deleted]
3
u/Finianb1 Sep 24 '19
To be fair, in any electronics programming you should be extremely mindful of errors and warnings since they could be a problem that leads to expensive hardware getting fried.
2
u/glorygeek Sep 24 '19
In the FPGA world you just keep cussing at Quartus and hope it eventually works.
0
0
Sep 23 '19
[deleted]
20
u/nelusbelus Sep 23 '19
It could be, it could be that you mistyped it and it used the member's variable instead
→ More replies (2)1
Sep 23 '19
heh I was gonna say. I guess you could comment out unused vars, but why? Especially if you're jsut going to implement them in the next few hours, it's nice to have the autocomplete there without having to fuck around with comments
9
124
u/ythl Sep 23 '19
I don't get it.
Your code should never have warnings, that's a sign you are doing something sketchy. At my company we enable all warnings as errors.
76
u/LPExpert Sep 23 '19
Then what do I do about Java warning of an import not being used but that's definitely being used
52
u/ythl Sep 23 '19
Open a bug report with your Java compiler
59
u/Mohammedbombseller Sep 23 '19
Java warnings are very minor compared to C warnings though. C warnings are bugs waiting to happen, java warnings are usually minor formatting differences that are pretty safe to ignore.
5
3
u/squishles Sep 23 '19
it's still your doing something messy in java usually.
my ignore line is intellj bitching about pep8, it's always something pep8 says no such fucking thing about. some knob over at intellj is just enforcing his favored code formatting style and parading it as being in the spec.
7
u/EishLekker Sep 23 '19
And while you wait for that bug to be fixed, and your project to be able to upgrade to that version, you do what exactly? Put the whole project on ice because it doesn't compile because all warnings are equal to errors?
→ More replies (7)1
u/TopHatEdd Sep 23 '19
Don't be a smartass. It's unbecoming. Just add a suppress for that warning.
1
u/EishLekker Sep 24 '19
Why do you call me a smart-ass? Surely the smart ass it's the one who claimed that no code should ever generate warnings. I just took his absurd statement and extrapolated it to its logical conclusion.
0
Sep 23 '19
[deleted]
14
u/ythl Sep 23 '19
Is it an actual javac warning? Or just an IDE linting warning? I treat compiler warnings seriously. IDEs, whatever
→ More replies (1)2
11
u/slepnir Sep 23 '19
https://www.baeldung.com/java-suppresswarnings
Just make sure you add a comment to explain why
60
11
u/Mr_Redstoner Sep 23 '19
And then there is GoogleWebToolkit just showing a random 'Copying 97 files with compilation errors' during my build and going on as if nothing was the matter... and so far I don't know if there actually is an error as everything seems to work & it was like that since I pulled the project...
3
u/Rizzan8 Sep 23 '19
Depends. Visual Studio WPF designer often can go ape-shit with errors and warnings in xaml code. Still compiles fine and works fine. This is widely known and goes on for a few years now. However, when reported to Microsoft, they are like "Minor annoyance, not worth spending precious resources to fix it, closing ticket. ¯_(ツ)_/¯ ".
The same thing with Cuda and VS. It goes mental when encounters
DoStuff<<< somethingA, somethingB >>> (something);→ More replies (1)2
u/randomkid1227 Sep 23 '19
In my company the build system warns about declaring the variables in a different order then initiating them, not necessarily meaningful (although can be). But any experienced developer delivered some quick and dirty work some time in his life so this is somewhat relateable
2
u/novinicus Sep 23 '19
I'm sure you know this, but in C++, you can specify the constructor's initializer list in any order, but the actual order of initialization is still in the order the variables are defined in the header. People prefer the no-reordering warning because it helps you reason about the constructor a little easier
2
Sep 23 '19
Depends on the language and the IDE.
If the language is incredibly strict, and the IDE is a good one, then yes, warnings will only show up when something sketchy is being done.
However, when the language is javascript, and the IDE is some open source thing with a garbage linter, you'll get tons of warnings about perfectly valid code, almost all of which you can safely ignore.
3
u/nicman24 Sep 23 '19
lol javascript linters make missing
;a warning32
u/Delioth Sep 23 '19
And auto formatters will add them for you so you don't get semicolon bugs. Shit like that is the whole purpose of linters - preemptively avoid common patterns which cause bugs.
→ More replies (4)48
u/RealBendie Sep 23 '19
Because missing semicolons can lead to unexpected behavior.
→ More replies (1)12
u/Logstone Sep 23 '19
Yes, use them! This isn't python!
4
u/Dornith Sep 23 '19
Even in python use them. And while you're at it, add some curly braces. And variable declarations. And code in a different language.
4
1
1
u/patrickfatrick Sep 24 '19
If you’re not autofixing this you’re not linting as well as you should be.
1
u/DarkyHelmety Sep 23 '19
Same where I work, no warnings are accepted. You can't even compile successfully. It does catch a lot of pointer issues though, appearing as incorrect casts of int to pointer.
1
u/crusty_cum-sock Sep 23 '19
I use .NET and StyleCop takes it to a whole new level. You could compile just fine with zero warnings, then run StyleCop on it and you'll see 12,398 warnings on a "Hello World" program. Of course StyleCop by default is strict af about literally everything, but it's a good tool for keeping all of your code very consistent.
1
1
5
u/fushuan Sep 23 '19
Not eliminating warnings is a rookie mistake that bootstraps you into un maintainable code.
1
8
4
4
u/Loading_M_ Sep 23 '19
See Rust. They have warnings for not following the naming convention. In Rust, if your professor doesn't want you to do it, the complier probably already calls it an exception.
10
3
u/CarilPT Sep 23 '19
And then you can start working on your first professional piece of software and you see thousands of warnings and realize nobody can gives a damn
3
3
Sep 23 '19
Yeah, I know that I assigned a double to float.
Yeah, I know that that function is not used.
Yeah, I know that you have a fancy new 'safe' function.
7
u/anonymous_yet_famous Sep 23 '19
I suspect that attitude is the reason I have encountered so many tutorials that do not work when I have literally _just_ installed the software the tutorial was written for and have made no configuration changes that could ruin things.
0
Sep 23 '19
[deleted]
3
u/bitofabyte Sep 23 '19
The issue is that there's really two fields being taught in undergrad computer science, actual computer science and software engineering. Some professors know the math/theory really well, but aren't familiar with the industry.
0
Sep 23 '19
[deleted]
1
u/I_DIG_ASTOLFO Sep 24 '19
Alternative rule: Professors live in an academic bubble and do not have to deliver software.
Do EE or SE proffessors not work in the field / not come directly from the field usually?
7
2
u/chris_saddler Sep 23 '19
Liferay apps don't even work properly if they don't error a lot in the logs
1
u/LolliDepp Sep 23 '19
I just finished reviewing the pr “Warnings are now errors” 10 minutes ago at work
0
1
u/espriminati Sep 23 '19
by the way The private field "variable" is not defined, and will always have it's default value null.
1
u/Deboniako Sep 23 '19
I was a grown adult and already entered in the work world before I saw my first program without warnings
1
1
1
1
u/0xygen_15 Sep 23 '19
You guys are doing all -Wall and shit while my college recommended us to write code in turbo c. Fucking #include<iostream(.H?) >
1
1
1
Sep 23 '19
Warnings: Hey, you should probably do something about that, no pressure, though!
Errors: Do something about that.
1
1
u/infinitude Sep 23 '19
I also truly despise the kids who waste class time having to show how much they know, even though all they're doing is going beyond the scope of the class for no reason.
1
u/junkmeister9 Sep 23 '19
warning: no newline at end of file
2
u/amdc Sep 24 '19
All half-decent code editors can be configured to automatically put a newline at the end of file so you never really have this warning
1
1
u/Reala27 Sep 24 '19
gcc -Wall -Wextra -Werror -ansi -pedantic may as well have been engraved on the walls of my C class.
1
Sep 24 '19
I am doing my first CS programming class knowing how to program so I can relate to this on a deep level.
1
1
1
Sep 23 '19 edited Sep 23 '19
"Warning: There is nothing wrong with this code, but I'm going to say there might be, just to annoy you."
0
134
u/gumol Sep 23 '19
-Wall or die