Neko (programming language)
| File:NekoLogo.png | |
| Paradigm | object-oriented, structured, classless, scripting |
|---|---|
| Appeared in | 2005 |
| Developer | Nicolas Cannasse |
| Stable release | 1.8.0 (October 10, 2008) |
| Typing discipline | dynamic |
| Major implementations | Neko, haXe |
| OS | Cross platform |
| Website | nekovm.org |
Neko is a high-level dynamically typed programming language developed by Nicolas Cannasse as part of R&D efforts at Motion-Twin.
Concept
Neko has a compiler and a virtual machine with garbage collection. The compiler converts a source .neko file into a bytecode .n file that can be executed with the virtual machine. Since Neko is dynamically typed with no fixed classes, a developer only has to find the proper runtime mapping (as opposed 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 compilation before execution, like other scripting languages such as Groovy. Since Neko doesn't need to be interpreted at runtime, it executes faster.
Examples
Hello World
<source lang="javascript"> $print("Hello World!"); </source>
Type Conversions
<source lang="javascript"> $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]" </source>
Objects
<source lang="javascript"> o = $new(null); // new empty object o2 = $new(o); // makes a copy of o o2 = $new(33); // if parameter is not an object, throw an exception o.field = value; //sets field to value o.field; // returns "field" value of object o </source>
Methods
<source lang="javascript"> foo = function() { $print(this.x); } o = $new(null); o.x = 3; o.bar = function() { foo(); }; o.bar(); // prints 3 </source>
Function Scope
<source lang="javascript"> var x = 3; f = function() { $print(x); } x = 4; f(); // print 3 </source>
Prototypes
<source lang="javascript"> var proto = $new(null); proto.foo = function() { $print(this.msg) }
var o = $new(null); o.msg = "hello"; $objsetproto(o,proto); o.foo(); // print "hello"
$objsetproto(o,null); // remove proto o.foo(); // exception </source>
Web Functionality
Neko includes a mod_neko module for the Apache server. As such, it can process user input using GET and POST requests: <source lang="javascript"> get_params = $loader.loadprim("mod_neko@get_params",0); $print("PARAMS = "+get_params()); </source>
External links
- Neko home page
- Neko mailing list archives
- haXe, a high-level language that can compile to the Neko VM
| Stub icon | This computer programming-related article is a stub. You can help Wikipedia by expanding it. |
If you like SEOmastering Site, you can support it by - BTC: bc1qppjcl3c2cyjazy6lepmrv3fh6ke9mxs7zpfky0 , TRC20 and more...