I haven't tried C# unsafe, but it definitely looks better than JNI. In
fact, Oracle has openly admitted that JNI was intentionally designed
to be hard to use in order to push people to write pure Java.

JNI isn't only hard to use, it can be pretty slow as well. The
function calls themselves aren't that bad, but stick to primitive
parameters/return values and direct ByteBuffers for any data the needs
to be passed between native and Java. Setting a field in a java object
from native costs (on my machine) something like 50ns, which on its
own isn't much, but still about 100x more than doing it in pure Java.
So don't do that on a critical path!

At JavaOne 2011 Oracle casually mentioned that they hope to improve
native handling in Java 9. I hope they do, and wouldn't be surprised
if it looked a lot like "unsafe".

Regards,
Erik Språng


On Jan 17, 8:00 pm, Josh Berry <[email protected]> wrote:
> On Tue, Jan 17, 2012 at 1:36 PM, clay <[email protected]> wrote:
> > I read the JGit email: he's right. unsigned types are definitely a
> > plus and a JVM deficiency but it's usually not a huge performance deal
> > by itself in the context of a full application. You have a good point
> > about "unsafe" in C#, but you can also use JNI to integrate Java with
> > high performance optimized C. But bottom line, performance is
> > typically never a deciding factor between JVM and CLI/Mono.
>
> I could be wrong, but JNI doesn't really act as a good "unsafe"
> replacement.   I tried searching quickly, but couldn't find any good
> links.  Essentially, I'm lead to believe that JNI calls can actually
> be rather expensive.  And, especially with some of the insane tricks
> I've seen to quickly take a byte of data from a network packet and
> turn it into a struct (yeah yeah, I know this is old hat for c
> coding...), I think these add up heavily in common code for game
> development.
>
> > playing and game development brands like Xbox/XNA/XBLA/DirectX/C# are
> > very popular. Anything related to Java is not. And most people view
> > terms like "Scala" or "Haskell" as just foreign jibberish. With this
> > type of crowd, most people have zero or very limited development
> > experience, and it's more perception and brand preference than deep
> > technical issues.
>
> > But even for the Microsoft fans: the Sony PlayStation Suite doesn't
> > give them the full XNA and XBLA tool chain. Microsoft's Xbox and
> > Sony's PlayStation platforms are similar but intensely competitive
> > rivals, and the fans are strongly divided as well. Much of the
> > Microsoft fanbase will choose to develop for Xbox Live and/or Windows
> > Mobile rather than a PlayStation/Android SDK. If there's anywhere for
> > a viable tool chain alternative to MIcrosoft, this is it.
>
> I think you are dismissing the amount of example code out there in C#
> for doing game development.
>
> So, lets turn this around.  Why would you have picked a different
> platform?  Why do you feel that the stuff Microsoft has created is a
> bad choice?

-- 
You received this message because you are subscribed to the Google Groups "The 
Java Posse" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/javaposse?hl=en.

Reply via email to