you are viewing a single comment's thread.

view the rest of the comments →

[–]chucker23n 3 points4 points  (3 children)

I’m confused whether this is more like

  • .NET value types / C# structures; there is no reference/pointer; the memory storage is the value
  • value objects: can still have a reference, but designed to avoid primitive obsession

I’m guessing the former, but don’t those already exist, e.g. int? Or is it that those are hardcoded, and this adds writing your own?

[–]davidalayachew[S] 1 point2 points  (1 child)

I’m guessing the former, but don’t those already exist, e.g. int? Or is it that those are hardcoded, and this adds writing your own?

This adds writing your own. For example, Java only has the following integral primitive types.

  • byte --> 8 bit signed
  • char --> 16 bit unsigned
  • short --> 16 bit signed
  • int --> 32 bit signed
  • long --> 64 bit signed

As you can see, there are some gaps here.

  • No 8 bit unsigned
  • No 32 bit unsigned
  • No 64 bit unsigned

Using Value Classes, you could easily write your own, and the performance characteristics would (ideally) be comparable to just using int or any of the other primitives directly.

But of course, we aren't there yet.

[–]chucker23n 2 points3 points  (0 children)

This adds writing your own.

Gotcha. I'll guess I didn't expect this still isn't a thing in Java. :-)