NekoVM

Last updated
NekoVM
Original author(s) Nicolas Cannasse
Developer(s)
Initial release2005;17 years ago (2005)
Stable release
2.3.0 / October 24, 2019;3 years ago (2019-10-24)
Repository
Written in C
Operating system Windows, macOS, Linux
Platform IA-32, x86-64
License MIT
Website nekovm.org/doc/vm/

NekoVM is a virtual machine developed by Nicolas Cannasse as part of research and development (R&D) efforts at two independent video game developers in Bordeaux, France: first at Motion Twin and then at Shiro Games. NekoVM's native language is the bytecode for a high-level dynamically typed programming language called Neko. This pairing allows Neko to be used directly as an embedded scripting language or to target NekoVM by compiling some other language (such as Haxe) to NekoVM bytecode.

Contents

Concept

Neko has a compiler and a virtual machine (VM) with garbage collection. The compiler converts a source .neko file into a bytecode .n file that can be executed with the VM. Since Neko is dynamically typed with no fixed classes, a developer only needs to find the proper runtime mapping (in contrast to type mapping) so that code executes correctly. As the Neko FAQ puts it: "...it is easier to write a new or existing language on the NekoVM than it is for the CLR / JVM, since you don’t have to deal with a highlevel type system. Also, this means that languages can interoperate more easily since they only need to share the same data structures and not always the same types." [1]

Neko requires compiling before executing, like other scripting languages such as Apache Groovy. Since Neko need not be interpreted at runtime, it executes faster. The Haxe programming language can compile to Neko code, among other targets.

Virtual machine

The Neko virtual machine is used to execute a Neko bytecode file, the VM also has the option to convert a bytecode file into an executable file (output changes depending on the target operating system).

Language

Neko
NekoVM logo.svg
Paradigm Object-oriented, structured, prototype-based, scripting
Designed by Nicolas Cannasse
Developer
First appeared2005;17 years ago (2005)
Stable release
2.3.0 / October 24, 2019;3 years ago (2019-10-24)
Typing discipline Dynamic
Implementation language OCaml
Platform NekoVM
OS Windows, macOS, Linux
License MIT
Filename extensions .neko .n
Website nekovm.org/specs/syntax/

Hello World

$print("Hello World!");

Type conversions

$int("67.87");// Converts string "67.87" to integer 67$float(12345);// Converts integer 12345 to float 12345.0000$string($array(1,2,3));// Converts array [1,2,3] to string "[1,2,3]"

Objects

o=$new(null);// new empty objecto2=$new(o);// makes a copy of oo2=$new(33);// if parameter is not an object, throw an exceptiono.field=value;//sets field to valueo.field;// returns "field" value of object o

Methods

foo=function(){$print(this.x);}o=$new(null);o.x=3;o.bar=function(){foo();};o.bar();// prints 3

Function scope

varx=3;f=function(){$print(x);}x=4;f();// print 3

Prototypes

varproto=$new(null);proto.foo=function(){$print(this.msg)}varo=$new(null);o.msg="hello";$objsetproto(o,proto);o.foo();// print "hello"$objsetproto(o,null);// remove protoo.foo();// exception

Web functionality

Neko includes Apache server modules mod_neko for Neko language and mod_tora for hosting the NekoVM application server tora. As such, it can process user input using GET and POST requests:

get_params=$loader.loadprim("mod_neko@get_params",0);$print("PARAMS = "+get_params());

See also

Related Research Articles

<span class="mw-page-title-main">Java virtual machine</span> Java Virtual machine

A Java virtual machine (JVM) is a virtual machine that enables a computer to run Java programs as well as programs written in other languages that are also compiled to Java bytecode. The JVM is detailed by a specification that formally describes what is required in a JVM implementation. Having a specification ensures interoperability of Java programs across different implementations so that program authors using the Java Development Kit (JDK) need not worry about idiosyncrasies of the underlying hardware platform.

OCaml is a general-purpose, multi-paradigm programming language which extends the Caml dialect of ML with object-oriented features. OCaml was created in 1996 by Xavier Leroy, Jérôme Vouillon, Damien Doligez, Didier Rémy, Ascánder Suárez, and others.

Common Intermediate Language (CIL), formerly called Microsoft Intermediate Language (MSIL) or Intermediate Language (IL), is the intermediate language binary instruction set defined within the Common Language Infrastructure (CLI) specification. CIL instructions are executed by a CLI-compatible runtime environment such as the Common Language Runtime. Languages which target the CLI compile to CIL. CIL is object-oriented, stack-based bytecode. Runtimes typically just-in-time compile CIL instructions into native code.

Parrot was a register-based process virtual machine designed to run dynamic languages efficiently. It is possible to compile Parrot assembly language and Parrot intermediate representation to Parrot bytecode and execute it. Parrot is free and open source software.

Bytecode is a form of instruction set designed for efficient execution by a software interpreter. Unlike human-readable source code, bytecodes are compact numeric codes, constants, and references that encode the result of compiler parsing and performing semantic analysis of things like type, scope, and nesting depths of program objects.

In computer programming, lazy initialization is the tactic of delaying the creation of an object, the calculation of a value, or some other expensive process until the first time it is needed. It is a kind of lazy evaluation that refers specifically to the instantiation of objects or other resources.

In computer science, reflective programming or reflection is the ability of a process to examine, introspect, and modify its own structure and behavior.

<span class="mw-page-title-main">ActionScript</span> Object-oriented programming language created for the Flash multimedia platform

ActionScript is an object-oriented programming language originally developed by Macromedia Inc.. It is influenced by HyperTalk, the scripting language for HyperCard. It is now an implementation of ECMAScript, though it originally arose as a sibling, both being influenced by HyperTalk. ActionScript code is usually converted to byte-code format by the compiler.

In some programming languages, eval, short for the English evaluate, is a function which evaluates a string as though it were an expression in the language, and returns a result; in others, it executes multiple lines of code as though they had been included instead of the line including the eval. The input to eval is not necessarily a string; it may be structured representation of code, such as an abstract syntax tree, or of special type such as code. The analog for a statement is exec, which executes a string as if it were a statement; in some languages, such as Python, both are present, while in other languages only one of either eval or exec is.

In computer programming, an entry point is the place in a program where the execution of a program begins, and where the program has access to command line arguments.

<span class="mw-page-title-main">Scala (programming language)</span> General-purpose programming language

Scala is a strong statically typed general-purpose programming language that supports both object-oriented programming and functional programming. Designed to be concise, many of Scala's design decisions are aimed to address criticisms of Java.

Exception handling syntax is the set of keywords and/or structures provided by a computer programming language to allow exception handling, which separates the handling of errors that arise during a program's operation from its ordinary processes. Syntax for exception handling varies between programming languages, partly to cover semantic differences but largely to fit into each language's overall syntactic structure. Some languages do not call the relevant concept "exception handling"; others may not have direct facilities for it, but can still provide means to implement it.

The Parrot intermediate representation (PIR), previously called Intermediate code (IMC), is one of the two assembly languages for the Parrot virtual machine. The other is Parrot assembly language or PASM. Compared to PASM, PIR exists at a slightly higher abstraction layer, and provides temporary registers and named registers, simplifying code generation.

Haxe is an open source high-level cross-platform programming language and compiler that can produce applications and source code, for many different computing platforms from one code-base. It is free and open-source software, released under the MIT License. The compiler, written in OCaml, is released under the GNU General Public License (GPL) version 2.

<span class="mw-page-title-main">Vala (programming language)</span> Programming language

Vala is an object-oriented programming language with a self-hosting compiler that generates C code and uses the GObject system.

This article describes the syntax of the C# programming language. The features described are compatible with .NET Framework and Mono.

<span class="mw-page-title-main">Clojure</span> Dialect of the Lisp programming language on the Java platform

Clojure is a dynamic and functional dialect of the Lisp programming language on the Java platform. Like other Lisp dialects, Clojure treats code as data and has a Lisp macro system. The current development process is community-driven, overseen by Rich Hickey as its benevolent dictator for life (BDFL).

In computing, Java bytecode is the bytecode-structured instruction set of the Java virtual machine (JVM), a virtual machine that enables a computer to run programs written in the Java programming language and several other programming languages, see List of JVM languages.

Kotlin is a cross-platform, statically typed, general-purpose programming language with type inference. Kotlin is designed to interoperate fully with Java, and the JVM version of Kotlin's standard library depends on the Java Class Library, but type inference allows its syntax to be more concise. Kotlin mainly targets the JVM, but also compiles to JavaScript or native code via LLVM. Language development costs are borne by JetBrains, while the Kotlin Foundation protects the Kotlin trademark.

References

  1. "How is Neko different from .Net's CLR or the Java's JVM ?". FAQ. NekoVM. Retrieved 2021-03-28.