Hello all! I’m announcing a new macro-based null-safety library called ScalaNullSafe!
The macro allows for null-safe navigation, while adding almost no performance overhead!
I also have created a new programming blog, where, in the first article, I discus the theory behind why null pointers are such a problem in most programming languages.
Please give me any feedback you might have
null as the same type or subtype of other types in the type system is the problem
The problem with
null is its existence.
Even the creator of
null admitted that. I really do not understand why people insists in saying the opposite.
null was created to model a very real effect in the real world.
The absence of a value, or a computation that may or may not produce a value in the end.
Option is a very simple and intuitive way to model that same effect but in a type-safe way.
I won’t discuss “Readable & Writable” because that is mostly subjective.
But, I would just say that if you find it hard to read
opt.map(f) then you probably also find it hard to read
list.map(f); and if you prefer to manipulate collections using plain loops and mutability, then I wonder how much do you win using Scala.
Finally, about performance. Before benchmarking and identified bottlenecks, performance optimizations are meaningless.
And for most traditional Scala applications I really doubt the bottleneck would be the wrapping and boxing of value on
Options, but rather network latency or database queries.
Now, if you are doing some scientific computations in scala and you need to squeeze your CPU then yeah, you probably need plain Arrays, loops, and
nulls. Not sure how helpful or not this plugin may be in those situations.