5 ms·
>This irks me too. It's been a while but I believe the workaround is just to define your own (checked) FunctionE, SupplierE, ConsumerE functional interfaces. Bu
by tpxl 6y ago
>This irks me too. It's been a while but I believe the workaround is just to define your own (checked) FunctionE, SupplierE, ConsumerE functional interfaces. But maybe that causes other problems I've forgotten.
You can do that, but you need to do it for every exception type ): I'd love it if Java had templated exceptions.
>> the stupid distinction between primitive types and Objects
One of the slowest things I found out about C# was floats being objects and `a < b` (or something similar) being a stack about 7 levels deep.
- gordaco 6y agoThat's right, I would run into even bigger performance issues if I used Integer/Long/Double/etc everywhere instead of the primitive types. The problem is not that primitive types are not object, but rather, that generic code will only accept objects and not primitive types.
- srtjstjsj 6y agoSo don't use generic code in critical inner loops.
- ossopite 6y ago> You can do that, but you need to do it for every exception type ): I'd love it if Java had templated exceptions. It does have them. You can write an interface with a type parameter `<E extends Throwable>` and declare functions inside it with `throws E`
- culturedsystems 6y agoYou can do this, but it's not ideal. A function can list multiple exceptions in its throws clause, which share no common type except Throwable, but this combination of exception types can't be represented by a single type parameter (except for the common base type). So in a lot of cases, you lose information about the specific exceptions your function can throw, which limits the value of using checked exceptions.
- toolslive 6y agoThe other alternative is to use the error monad in combination with railroad style programming. Of course you also want infix operators like (>>), (>>?) aso.
- jasonboyd 6y ago> One of the slowest things I found out about C# was floats being objects Floats are value types not objects: https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/builtin-types/floating-point-numeric-types https://docs.microsoft.com/en-us/dotnet/csharp/language-refe... Maybe you we're dealing with floats that had been boxed?
- tpxl 6y agoThey were probably boxed yeah, we were dealing with unity physics stuff and that's what the benchmarks showed.