I would like to develop (or find, if one is already in development) a framework with support for accelerated graphics and sound built on a system flexible enough to compile to the following:
native ppc/x86/x86_64/arm binaries or a language which compiles to them
javascript
actionscript bytecode or a language which compiles to it (actionscript 3, haxe)
optionally java
I imagine, for example, creating an API where I can open windows and make OpenGL-like calls and the framework maps this in a relatively efficient manner to either WebGL with a canvas object, 3d graphics in Flash, OpenGL ES 2 with EGL, or desktop OpenGL in an X11, Windows, or Cocoa window.
I have so far looked into these avenues:
Building the game library in haXe
Pros:
Targets exist for php, javascript, actionscript bytecode, c++
High level, object oriented language
Cons:
No support for finally{} blocks or destructors, making resource cleanup difficult
C++ target does not allow room for producing highly optimized libraries -- the foreign function interface requires all primitive types be boxed in a wrapper object, as if writing bindings for a scripting language; these feel unideal for real-time graphics and audio, especially exporting low-level functions.
Doesn't seem quite yet mature
Using the C preprocessor to create a translator, writing programs entirely with macros
Pros:
CPP is widespread and simple to use
Cons:
This is an arduous task and probably the wrong tool for the job
CPP implementations differ widely in support for features (e.g. xcode cpp has no variadic macros despite claiming C99 compliance)
There is little-to-no room for optimization in this route
Using llvm's support for multiple backends to target c/c++ to web languages
Pros:
Can code in c/c++
LLVM is a very mature highly optimizing compiler performing e.g. global inlining
Targets exist for actionscript (alchemy) and javascript (emscripten)
Cons:
Actionscript target is closed source, unmaintained, and buggy.
Javascript targets do not use features of HTML5 for appropriate optimization (e.g. linear memory with typed arrays) and are immature
An LLVM target must convert from low-level bytecode, so high-level constructs are lost and bloated unreadable code is created from translating individual instructions, which may be more difficult for an unprepared JIT to optimize. "jump" instructions cause problems for languages with no "goto" statements.
Using libclang to write a translator from C/C++ to web languages
Pros:
A beautiful parsing library providing easy access to the code structure
Can code in C/C++
Has sponsored developer effort from Apple
Cons:
Incomplete; current feature set targets IDEs. Basic operators are unexposed and must be manually parsed from the returned AST element to be identified.
Translating code prior to compilation may forgo optimizations assumed in c/c++ such as inlining.
Creating new code generators for clang to translate into web languages
Pros:
Can code in C/C++ as libclang
Cons:
There is no API; code structure is unstable
A much larger job than using libclang; the innards of clang are complex
Building the game library in Common Lisp
Pros:
Flexible, ancient, well-developed language
Extensive introspection should ease writing translators
Translators exist for at least javascript
Cons:
Unfamiliar language
No standardized library functions, widely varying implementations
Which of these avenues should I pursue? Do you know of any others, or any systems that might be useful?
Does a general project like this exist somewhere already?
Thank you for any input.