Cross compilation: Difference between revisions

Added Wren blurb.
m (→‎{{header|Phix}}: sp, more)
(Added Wren blurb.)
Line 28:
''[https://www.rosettacode.org/mw/index.php?title=Special%3ASearch&search=phixonline here]'' and
''[https://www.rosettacode.org/mw/index.php?title=Special%3ASearch&search=notonline here]'' respectively.
 
=={{header|Wren}}==
Wren is basically a scripting language which lives inside a host application in the form of a virtual machine (VM). The host application communicates with the VM via the embedding API which (like the VM itself) is written in C99.
 
Host applications don't have to be written in C99 itself and bindings exist for several other languages including C++, Rust and Go. If a language exposes a C FFI, one can probably write a binding for it.
 
The VM is very small compared to, say, those of the Java or .NET family languages. Although it is typically built as a shared or static library which the host can link to, its small size means that it's a practical proposition to incorporate its source code directly in a host application written in C/C++ which can then be built directly by including the wren.h/wren.hpp header file.
The VM compiles the Wren source code into a intermediate bytecode which it then interprets at runtime. The compilation process is just 'single pass' which imposes some limitations on the Wren language but is so fast that the compile and runtime stages are virtually indistinguishable to the user.
 
Wren has a small standard library whose only dependency is the C99 standard library.
 
Athough it is possible to run Wren applications from the command line using [https://github.com/wren-lang/wren-cli '''Wren-cli'''] (the main focus for RC tasks), technically the latter is just a host application for the Wren VM which uses the cross-platform C library, [https://github.com/libuv/libuv ''libuv''], to implement IO functionality and supplements the Wren standard library accordingly.
 
Pre-built Wren-cli executables exist and are [https://github.com/wren-lang/wren-cli/releases/tag/0.4.0 freely available] for 64-bit Linux, MacOS and Windows. However, as libuv runs on many more platforms than these and virtually all platforms have a C99 (or C++98) compiler available, it should be technically possible to build a version of Wren-cli for any such platform.
 
To build a Wren-cli executable which runs on a different platform from the development platform then one needs, of course, to use a C99 compatible cross-compiler such as the ubiquitous GCC which can be set up to do this provided ''binutils'' is available for the target platform. For some platforms (such as embedded systems) it may be necessary to use the ''newlib'' subset of the standard C library.
 
Finally, it is worth mentioning that a [https://github.com/ppvk/wrenjs Wren to Javascript transpiler (via emscripten)] exists which enables Wren applications to be run in a browser though this does have a dependency on ''node.js'' and various other stuff.
9,476

edits