you mean the tabs? It's great, it allows me to systematically identify and exterminate any heretic use of spaces for indentation. It's not an option i activate with all languages but for example with python i literally can't program without it
If you're using arrows that look like that you're either using a retarded IDE that wants to look pretty by stylizing -> or you're using a shitty language.
To be fair, that -> stylization does look quite pretty. The only issue is opportunities for confusion, which shouldn’t happen unless somebody else uses the same computer.
The problem is that it calls itself recursively when there's an exception reading a keystroke. Given any I/O error that's not user-caused you're guaranteed to overflow the call stack when it tries to read, fails, tries to read again, fails, etc. all the while adding calls to the call stack until you run out.
That's why I suggested changing the caught exception to something more specific. One that only gets throws when there was input, but it wasn't a number. But yeah, there are definitely cleaner solutions I agree.
Of course, if the exception is that it's not a number, then one could also cause a call stack overflow and crash the process by typing a lot of non-numeric nonsense...
What would the harm be if a user space program gets crashed by unmanageable user input?
I mean, it means your application is broken, first of all.
If it's a shared system, it's a denial of service issue.
A call stack overflow is an immediate panic, you know. You don't get a lot of opportunity to save user work or clean up connections.
In general, as an engineer, you should always avoid escalating a simple input error to an application panic, especially for a reason as silly as "I can't think of a better way to toss out invalid input right now".
You may think there are systems where you don't have to defend against hostile input, but you're the one making that assumption. You have to consider that the consequences could be catastrophic if you're wrong. The easiest way to avoid catastrophe is to just have good engineering practices whether or not you "expect" hostile input.
The worst bugs I see in software on a literal daily basis are bugs where an engineer assumed the input was trusted or that no user would ever do XYZ (or if they did do XYZ they were just stupid and deserved it). A user comes along with a perfectly legitimate reason to do XYZ and everything catches fire, and the engineer is the one holding the gas can.
The problem is that it calls itself recursively when there's an exception reading a keystroke.
Which isn't a problem since it will wait for the next keystroke, which may or may not fail. It's not getting stuck in a loop on the same keystroke... it's going to wait for the next one. If it fails, it will wait for the next one, if it doesn't it will do what it needs to do...
52
u/Maoschanz Oct 01 '19
(it compiles so it's CorrectCode™)
141
u/[deleted] Oct 01 '19
In fairness I once wrote code that caught stackoverflow exceptions and spawned a new thread and then continued executing in the new thread.
27
u/[deleted] Oct 01 '19
Ugh that white space rendering is hideous. Especially with ligatures that match those that have functional use in a lot of languages.
11
u/[deleted] Oct 02 '19
This would fail due to a stack overflow eventually- Java (as far as I know) doesn't optimize tail calls. You need to use a loop.
33
u/GogglesPisano Oct 01 '19
7
u/Vatril Oct 01 '19
I mean if you maybe change that exception to a more specific one and also print out some user feedback it's not that bad I think
2
u/NightStormYT Oct 01 '19
I didn’t like java class in hs:(
2
u/sheeve_boi Oct 02 '19
"java creator creates the first ever method of making an event listener work"
1
u/sim642 Oct 02 '19
You're not supposed to create multiple Scanners onto one input stream.
1
u/[deleted] Oct 08 '19
Solved with recursion