Gosu (programming language)

From Wikipedia, the free encyclopedia
Jump to: navigation, search
Gosu
Paradigm(s) object-oriented
Designed by Guidewire Software
Developer Guidewire Software
Stable release 0.10.3 / January 17, 2014; 7 months ago (2014-01-17)
Influenced by Java, Ruby, Python, Erlang, Haskell, C#
Implementation language Java, Gosu
Platform Java virtual machine
OS any JVM supported
License Apache License
Filename extension(s) .gsp .gs .gst .gsx
Website gosu-lang.org

Gosu is a general-purpose Java virtual machine-based programming language released under the Apache License 2.0.[1] This general-purpose programming language is used in some open-source software projects, including the web application framework Ronin and the build-tool Vark, as well as in Guidewire Software commercial products for the insurance industry.[1][2] The language is rooted in concepts from Java, C#, and ECMAScript, but borrows some constructs from Ruby 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[edit]

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 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. The latest version is 0.10.3, released on January 2014.

Examples[edit]

Fibonacci sequence:

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

Blocks (closures or lambda functions):

var list = {1, 2, 3}
var result = list.where(\ elem -> elem >= 2)
print(result)

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()

Notes[edit]

References[edit]

External links[edit]