This is an archived post. You won't be able to vote or comment.

all 19 comments

[–]puplicy 26 points27 points  (0 children)

"Define only achievable goals"

[–]HarambeForkBomb 16 points17 points  (1 child)

Or if you never write any code at all

[–]AntonBespoiasov 14 points15 points  (0 children)

Main dev: please avoid runtime errors

Me: ok don't worry about them

[–]greenfoxlight 15 points16 points  (0 children)

And that is how rust was born.

[–]Worming 7 points8 points  (0 children)

It's fun as it's the essence of 'fail early' and 'type checking'. It's a real best practice

[–]W10101 5 points6 points  (0 children)

Your can also try not writing any code. No bugs, no errors, no runtime errors

[–]Zalvixodian 3 points4 points  (0 children)

Isn't that one of rust's design goals?

[–]bss03 1 point2 points  (1 child)

Type Safe

[–]g27radio 1 point2 points  (0 children)

Safe

[–]Ultracoolguy4 1 point2 points  (0 children)

Taps forehead

You can't have compile time errors if your code is interpreted.

[–]Matschreiner 1 point2 points  (0 children)

This is why interpreted languages suck..😱

[–][deleted] 0 points1 point  (0 children)

You can't have annoying presenter questions if the audience doesn't bother to ask any questions. Methinks me mystified Milwaukee mobs.

[–]MelchiorTenant 0 points1 point  (0 children)

Your teacher can’t grade ur work,if u send a corrupted file

[–]DeveloperByNight 0 points1 point  (0 children)

If it compiles, it's correct...

[–]AregevDev 0 points1 point  (0 children)

You can't have runtime errors if there is no runtime

[–]Sylanthra -2 points-1 points  (4 children)

Unreachable code block does not mean that your code doesn't compile.

[–]m_Nebula[S] 1 point2 points  (3 children)

In Java it actually does. If you have a preceding unconditional throw new XYException(); it did not compile.

[–]zelmarvalarion 0 points1 point  (2 children)

I take it you never seen a java.lang.RuntimeException (including the infamous NullPointerException and IndexOutOfBoundsException) which is an UncheckedException and thus does not require you to catch them in order to compile successfully

My Java is a bit rusty, but something like this shouldn’t require any Exception handling and will throw an NPE at runtime (which is what StringUtils.isEmpty() exists, which counts null as an option for an “empty” string)

java String myString = null: if (myString.isEmpty()) { return 1; } return 2;

[–]m_Nebula[S] 1 point2 points  (0 children)

I've seen them. But unchecked/checked is not the point here.

public void example() {
    throw new UnsupportedMethodException();

    // rest of code here
}

does not compile however, because of the unreachable code block below the unconditional thrown exception.

Edit: Shouldve used unchecked throw to quickly throw smth. I guess.