Gosu (programming language)
Encyclopedia
Gosu is a general-purpose Java Virtual Machine
Java Virtual Machine
A Java virtual machine is a virtual machine capable of executing Java bytecode. It is the code execution component of the Java software platform. Sun Microsystems stated that there are over 4.5 billion JVM-enabled devices.-Overview:...

-based programming language
Programming language
A programming language is an artificial language designed to communicate instructions to a machine, particularly a computer. Programming languages can be used to create programs that control the behavior of a machine and/or to express algorithms precisely....

 released under the Apache License
Apache License
The Apache License is a copyfree free software license authored by the Apache Software Foundation . The Apache License requires preservation of the copyright notice and disclaimer....

 2.0. This general-purpose programming language is used in some open-source software
Open-source software
Open-source software is computer software that is available in source code form: the source code and certain other rights normally reserved for copyright holders are provided under a software license that permits users to study, change, improve and at times also to distribute the software.Open...

 projects, including the web application framework
Web application framework
A web application framework is a software framework that is designed to support the development of dynamic websites, web applications and web services. The framework aims to alleviate the overhead associated with common activities performed in Web development...

 Ronin and the build-tool Vark, as well as in Guidewire Software
Guidewire Software
Guidewire Software Inc., commonly just Guidewire, is a privately-held American corporation based in San Mateo, California. It offers core backend systems for property and casualty insurance carriers in the U.S...

 commercial products for the insurance industry. The language is rooted in concepts from Java
Java (programming language)
Java is a programming language originally developed by James Gosling at Sun Microsystems and released in 1995 as a core component of Sun Microsystems' Java platform. The language derives much of its syntax from C and C++ but has a simpler object model and fewer low-level facilities...

, C#, and ECMAScript
ECMAScript
ECMAScript is the scripting language standardized by Ecma International in the ECMA-262 specification and ISO/IEC 16262. The language is widely used for client-side scripting on the web, in the form of several well-known dialects such as JavaScript, JScript, and ActionScript.- History :JavaScript...

, but borrows some constructs from Ruby
Ruby (programming language)
Ruby is a dynamic, reflective, general-purpose object-oriented programming language that combines syntax inspired by Perl with Smalltalk-like features. Ruby originated in Japan during the mid-1990s and was first developed and designed by Yukihiro "Matz" Matsumoto...

 and dynamic languages. Its most notable feature is its Open Type System API, which allows the language to be easily extended to provide compile-time checking for things that would typically be dynamically checked at runtime in many other languages.

History

Gosu began in 2002 as a scripting language called GScript at Guidewire Software. It was used to configure business logic in Guidewire's applications and was more of a simple rule definition language. In its original incarnation it followed ECMAScript
ECMAScript
ECMAScript is the scripting language standardized by Ecma International in the ECMA-262 specification and ISO/IEC 16262. The language is widely used for client-side scripting on the web, in the form of several well-known dialects such as JavaScript, JScript, and ActionScript.- History :JavaScript...

guidelines. Guidewire enhanced the scripting language over the next 8 years, and released Gosu 0.7 beta to the community in November 2010. The 0.8 beta was released in December 2010, and 0.8.6 beta was released in mid 2011 with additional typeloaders, making Gosu capable of loading XML schema definition files (xsd's) and XML documents as native Gosu types.

Examples

Fibonacci


function fib(n : int) : int {
if (n < 2) return n
return fib(n-1) + fib(n-2)
}

print(fib(20))


XML


/*
Any XSD can be placed into a Gosu source directory, and types will automatically appear in the system that
can be used to manipulate instance documents that conform to that schema. This example shows
manipulation of a schema using the schema schema that ships with Gosu in the gw.xsd.w3c.xmlschema package.
var schema = new gw.xsd.w3c.xmlschema.Schema
schema.TargetNamespace = new java.net.URI( "urn:example.com" )
schema.Element[0].Name = "root"
schema.Element[0].ComplexType.Sequence.Element[0].Name = "child"
schema.Element[0].ComplexType.Sequence.Element[0].Type = schema.$Namespace.qualify( "string" )
schema.print

External links

The source of this article is wikipedia, the free encyclopedia.  The text of this article is licensed under the GFDL.
 
x
OK