>Kotlin’s design principle of making important ...
# language-proposals
r
Kotlin’s design principle of making important things explicit
than please make that all function have throws in function declaration like in Java
1
b
Oh gosh yes please
p
Oh god no. This is Kotlin's best feature. You are bad and you should feel bad.
2
b
I hate it when things throw without me knowing. It seems like an oversight that I have to deal with `null`s like crazy presumably to avoid
NullPointerException
, but all other exceptions and errors are completely ignored by the compiler.
k
the java developers themselves agree that checked exceptions do more bad than good. yes, they can prevent bugs, but at the cost of waaaay to much clutter
1
e
not mention they make extending APIs very complicated
b
Yes, Java has a terrible way of handling exceptions at compile-time. That doesn't mean its way is the only way. I personally love Swift's way of just saying whether a function
throws
or
rethrows
, and when you call it you mark the line it's called on with
try
(like
var x = try danger()
). The best part is that if you use
try?
(like
var x = try? danger()
), you get an Optional that's
null
if it threw. Of course, Swift lets you use `try!`if you really don't care and are OK with it crashing there. Much less syntax, even more powerful. That's the point of these modern languages. Kotlin's current kludge of using an annotation is ugly and relies on stdlib. That's just... It hurts every time I do it.
👍 1
e
yeah. i'm not thrilled about the annotation. but that's mostly ok because I just don't use it either. 😄
b
I loathe exceptions. I want to know about all of the ones others throw, and never throw any myself. I'd rather my app run with bugs than crash.
👍 1
c
@benleggiero you are saying you like the swift approach, which plugs the hole you loathe, but then reasserting your loathing? you might need exception therapy..
b
I'm saying I like that Swift always lets me know about exceptions and lets me deal with them like they're not even there. I like that Swift won't allow an exception to crash your app unless you explicitly request it.
c
I know what you are saying, oh and I agree with you. I am saying you are in essence saying ‘there is a solution to my loathing, but I still loath them.’ Or are you saying you don’t loathe S exceptions, and you would use them there, but not in K or J?
b
I'm saying I loathe crashes. If a language allows crashes without letting me know at compile time, I'm a very angry coder
c
Amen, dude.. as I said of course I agree with that.
👍 1
r
@kirillrakhman are exceptions important thing? if so, than make them explicit, it's your quote
Kotlin’s design principle of making important things explicit
1