Value types for Java

Ben Hutchison benh at ibsglobalweb.com
Wed Apr 30 21:07:29 PDT 2008


I have just discovered John Rose's "Tuples in the VM" proposal. I have 
wanted value types in Java for a long time, so this is of interest to 
me. I am involved in two fields of software development, each with 
differing motivations for value types.

I develop financial software that involves lots of BigDecimal 
calculations, which has led me to envy the 8-byte decimal struct 
available in .NET, which behaves like a primitive type but has precision 
like the more cumbersome BigDecimal.

Im also involved in game development, an area where Java "market share" 
is largely confined to the low-performance end of the industry - J2ME 
and browser-based platforms. Most high-performance games are written in 
C++, but managed C# has an ever growing share. However, I think the JVM 
can be an excellent technology for game development, if it can provide 
two things: an upper-bound on GC pause times, and value types.

At present, I think value types are a key reason why game developers 
using a "managed" platform prefer .NET over Java. For example, 3D 
graphics processes massive arrays of Triangle structs, and allocating 
them onto a heap accessed via indirection seems sufficiently wasteful 
and cache-unfriendly that no competent game studio would consider it.

To be useful in game dev, a value type mechanism would need to allow 
some control over the placement of fields in memory, since Triangle 
arrays and similar data would be passed to native code in the 3D 
accelerator driver. Similar memory-layout requirements would likely 
arise were JVM value-types used for other forms of low-level systems 
programming, such as networking. .NET's value types do a pretty good job 
of catering to these needs, so that seems like a good example to learn 
from.

Specifying memory layout isn't traditionally very Java-ish, but given 
the atypical, low-level scenarios that value types address, would it be 
a mistake to add value types but leave issues of field layout up to the 
JVM implementor?

Sincerely
Ben

-- 

	

*Ben Hutchison
Developer
* Level 2 476 St Kilda Road Melbourne VIC 3004
T 613 8807 5252 | F 613 8807 5203 | M 0423 879 354 | 
www.ibsglobalweb.com <http://www.ibsglobalweb.com/>

This e-mail (and any attachments to this e-mail) is for the exclusive 
use of the person, firm or corporation to which it is addressed and may 
contain information that by law is privileged, confidential or protected 
by copyright. If you are not the intended recipient or the person 
responsible for delivering this e-mail to the intended recipient, you 
are notified that any use, disclosure, distribution, printing or copying 
of this e-mail transmission is prohibited by law and that the contents 
must be kept strictly confidential. If you have received this e-mail in 
error, kindly notify us immediately on + 613 8807 0168 or respond to the 
sender by return e-mail. The original transmission of this e-mail must 
be destroyed.

Internet Business Systems Australia Pty Ltd accepts no responsibility 
for any viruses this e-mail may contain. This notice should not be removed.





More information about the mlvm-dev mailing list