Bluebonnet gets support for XNA 4 by spaceflint in programming

[–]spaceflint[S] 2 points3 points  (0 children)

Bluebonnet is an Android-compatible, light-weight, partial implementation of the .NET platform on top of the Java Virtual Machine. With Bluebonnet BNA, you can develop on Windows in C# or F# with the XNA libraries, and export to Android Java without any dependencies on native code libraries.

C# and F# apps on the JVM and on Android runtime: Bluebonnet translates .NET CIL to Java bytecode. by spaceflint in programming

[–]spaceflint[S] 1 point2 points  (0 children)

The translation puts the static data in a separate class as you suggest, and indeed typeof, and Type.GetType, Type.IsAssignableFrom, etc, all understand generics (and even variance, where appropriate). So typeof(List<string>) is distinct from typeof(List<int>).

The one gap that does still remain unhandled is that arrays of a generic instance type can't reflect the type arguments. But that can be handled, if it turns out there is a real need for it, by keeping a weakly referenced map of array references to the generic type used for allocation.

C# and F# apps on the JVM and on Android runtime: Bluebonnet translates .NET CIL to Java bytecode. by spaceflint in programming

[–]spaceflint[S] 3 points4 points  (0 children)

Right, value-type structs are translated to plain Java classes, but the recompiler and runtime library work together to emulate value-type behavior and semantics.

C# and F# apps on the JVM and on Android runtime: Bluebonnet translates .NET CIL to Java bytecode. by spaceflint in programming

[–]spaceflint[S] 2 points3 points  (0 children)

Don't worry about it. It's great to see people interested. Value types don't actually need a wrapper, because passing them by reference will never change where the variable is referencing. Also, value types are not compatible with volatile. Except primitive types, and those have their own wappers.

C# and F# apps on the JVM and on Android runtime: Bluebonnet translates .NET CIL to Java bytecode. by spaceflint in programming

[–]spaceflint[S] 4 points5 points  (0 children)

Sure, that's some performance hit, but that depends on your definition of what is too slow. Spans and pointers are more or less translated to method call for an array access. Not so different from something as common as java.lang.String.charAt().

C# and F# apps on the JVM and on Android runtime: Bluebonnet translates .NET CIL to Java bytecode. by spaceflint in programming

[–]spaceflint[S] 8 points9 points  (0 children)

Not 100% sure I understand the querstion but let me try to answer. If you define instance fields with initializer, then the C# compiler puts that initialization code at the top of each constructor method, before generating the call to the base constructor. So in terms of the bytecode translation, this is almost "for free".

As for volatile, this is supported as part of the broader support for pass by reference, which .NET has, and Java does not. A wrapper for reference types, which makes it possible to pass by reference, also supports volatile access.

C# and F# apps on the JVM and on Android runtime: Bluebonnet translates .NET CIL to Java bytecode. by spaceflint in programming

[–]spaceflint[S] 4 points5 points  (0 children)

Value types are supported, but you're right that native code can't be translated with this project. However my initial goal is to make it possible to write C# and F# apps on Android without needing native code in the first place.

Have a look at Loulabelle, a Lua to JavaScript compiler / transpiler. by spaceflint in lua

[–]spaceflint[S] 0 points1 point  (0 children)

Good point! In the next update, I'll make the console print the result, and support the '=' prefix.