I am searching for a language/library (preferably JVM-based) that handles numeric values (integer and floating point numbers) in both convenient and efficient manner.
Is there a language that handles primitives with the same convenience but efficiently (compared to that language general performance)?
C# fits the criteria, depending on what you mean by the efficiency requirement. It doesn't run on the JVM, of course.
Unlike Java, which implements generics with type erasure, C# implements generics via reification like C++ does. That means that when you make a List<int>
, the underlying array will be an array of int
, not an array of objects. Also the code that implements all the List
methods will be compiled specifically for List<int>
, and can take advantage of int-specific optimizations.
For this reason, data processing with primitive types is generally faster in C# than it is in Java when you're using all the convenient language features. It can still be far from what you can get with C++, however, because the runtime checks that prevent buffer overrun, etc., are not free.