Home » News » KavaScript: A Different Brew o ...

News by JavaScriptSearch


KavaScript: A Different Brew of JavaScript

 

JavaScriptSearch
Tuesday, June 27, 2006; 04:45 AM

Programmer Gary Gurevich has created a project that aims to bring the JavaScript programming language closer to the developers' expectations.  The KavaScript project extends JavaScript with syntax and features inspired by expressive, dynamic languages like Ruby and Perl.  Its creator describes as a "enhanced dialect of JavaScript designed to make your coding more productive, rewarding, and fun."


The project's website at www.kavascript.com offers examples, as well as links to downloads and documentation.  The documentation is benevolently described as being in "beta," but nonetheless contains useful articles and is being expanded.

KavaScript version 0.7 can be downloaded directly from the frontpage. A public subversion repository of the ongoing development snapshot is also available from http://svn.kavascript.com/trunk/.

KavaScript is free software, published under the MIT license.

Sample comparisons between JavaScript and KavaScript syntax:

KavaScript

`class Set (members) {
  var init = `{
    members = _;
    @length = members.length;
    @__expose(members, `w[indexOf map filter forEach sort]);
  };
  @.init(members || []);

  @get = `{ return members[_] }
  @list = `{ return members.map `{return _} }
  @clear = `{|| @.init([]) }
  @contains = `{ return members.indexOf(_) >= 0 }
  

 

JavaScript

function Set (members) {
  var init = function (_) {
    members = _;
    this.length = members.length;
    this.__expose(members, ['indexOf', 'map', 'filter', 'forEach', 'sort']);
  });
  init.call(this, members || []);

  this.get = function (_) {
    return members[_]
  }
  this.list = function () {
    return members.map(function (_) {return _ })
  }
  this.clear = function () {
    init.call(this, []);
  }
  this.contains = function (_) {
    return members.indexOf(_) >= 0 
  }


KavaScript Features

  • Variable and code interpolation within strings
  • List and array literals (like Perl's qw operator)
  • Terse block/closure syntax borrowed from Ruby
  • Usable and legible functional programming primitives
  • User-defined macros
  • A new class system and syntax which supports multiple inheritance
  • Ruby-style instance variables
  • File include and insert directives

 

Advertisement

Partners

Related Resources

Other Resources

arrow