r/ProgrammerHumor • • Sep 23 '19

Knowing how to code beforehand

Post image
7.6k Upvotes

264 comments sorted by

View all comments

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

u/LeCrushinator Sep 23 '19

Then there needs to be a distinction between a warning and a suggestion.

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.

0

u/[deleted] 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

2

u/t3hmau5 Sep 23 '19

Jetbrain's 500 warnings, none of consequence.

→ More replies (1)

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 (9)

11

u/slepnir Sep 23 '19

https://www.baeldung.com/java-suppresswarnings

Just make sure you add a comment to explain why

60

u/gumol Sep 23 '19

At my company

this is a sub for 1st year college students, shush

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

u/[deleted] 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 warning

32

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

u/Logstone Sep 23 '19

And if you really need to run it as python, don't.

→ More replies (3)
→ More replies (4)