Gosu (programming language): Difference between revisions

Content deleted Content added
m General fixes via AutoWikiBrowser
 
(117 intermediate revisions by 70 users not shown)
Line 1:
{{Short description|Programming language}}
{{Multiple issues|
{{Cleanup bare URLs|date=September 2022}}
{{More citations needed|date=February 2015}}
}}
{{Infobox programming language
| name = Gosu
| logo = =
| caption = =
| file ext = .gspgs, .gsgsp, .gst, .gsx
| paradigm = =
| released = <!-- {{11 Nov|2010}} -->
| developer = Guidewire and open source contributors
| designer = Guidewire Software
| latest release version = {{wikidata|property|reference|edit|P348}}
| developer = Guidewire Software
| latest release versiondate = 0.8.6-C{{Start date and age|{{wikidata|qualifier|P348|P577}}|df=no}}
| latest releasepreview dateversion =
| latest preview date = <!-- {{start date and age|YYYY|MM|DD}} -->
| typing = [[Type system#Static type-checking|static]]
| latest preview version =
| implementations =
| latest preview date = <!-- {{start date and age|YYYY|MM|DD}} -->
| dialects =
| typing =
| influenced by = [[Java (programming language)|Java]], [[C Sharp (programming language)|C#]]
| implementations =
| influenced = [[Kotlin (programming language)|Kotlin]]
| dialects =
| platform = Execute on the [[Java Virtual Machine]], statically and dynamically compiles to [[Java bytecode|bytecode]]
| influenced by = [[Java (programming language)|Java]], [[Ruby (programming language)|Ruby]], [[Python (programming language)|Python]], [[Erlang (programming language)|Erlang]], [[Haskell (programming language)|Haskell]], [[C Sharp (programming language)|C#]]
| operating system = any supporting JVM
| influenced = Ronin, Vark
| license = [[Apache License 2.0]]
| programming language = Java, Gosu
| website = {{URL|https://gosu-lang.github.io/}}
| platform = [[Java Virtual Machine]]
| wikibooks =
| operating system = any JVM supported
| license = [[Apache License]]
| website = http://gosu-lang.org/
| wikibooks =
}}
 
{{Portal|Free software}}
'''Gosu''' is a [[Type system#Static type-checking|statically typed]] [[general-purpose programming language]] that runs on the [[Java Virtual Machine]]. Its influences include [[Java (programming language)|Java]], [[C Sharp (programming language)|C#]], and [[ECMAScript]]. Development of Gosu began in 2002 internally for [[Guidewire Software]], and the language saw its first community release in 2010 under the [[Apache license|Apache 2]] license.<ref name=slashdot>{{cite web|url=http://slashdot.org/story/10/11/09/0510258/Gosu-Programming-Language-Released-To-Public|title=Gosu Programming Language Released To Public|date=2010-11-09|publisher=[[Slashdot]]}}</ref>
'''Gosu''' is a general-purpose [[Java Virtual Machine]]-based [[programming language]]. It is licensed as [[open source software]] under the [[Apache License]] 2.0.<ref name=slashdot>{{Cite web|url=http://slashdot.org/story/10/11/09/0510258/Gosu-Programming-Language-Released-To-Public|title=Gosu Programming Language Released To Public|date=2010-11-09|publisher=[[Slashdot]]}}</ref> This general-purpose programming language is used in some [[open-source software]] projects, including the [[web application framework]] [http://ronin-web.org/ Ronin] and the build-tool [http://vark.github.com/ Vark], as well as in [[Guidewire Software]] commercial products for the insurance industry.<ref name=slashdot/><ref>{{Cite news|url=http://www.pcpro.co.uk/news/362638/gosu-brings-fresh-language-skills-to-java-virtual-platform|title=Gosu brings fresh language skills to Java Virtual Platform|publisher=[[PC Pro]]|date=2010-11-09}}</ref>. 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.
 
Gosu can serve as a scripting language, having free-form Program types (.gsp files) for scripting as well as statically verified Template files (.gst files). Gosu can optionally execute these and all other types directly from source without precompilation, which also distinguishes it from other static languages.
 
==History==
Gosu began in 2002 as a scripting language called '''GScript''' at Guidewire Software.<ref>http://www.guidewire.com {{Bare URL inline|date=August 2025}}</ref><ref>https://gosu-lang.github.io/ {{Bare URL inline|date=August 2025}}</ref> It was later renamed to '''Gosu''' by the lead developer Scott McKinney in order for the language to not be confused as a [[Google]] technology.<ref>https://groups.google.com/g/gosu-lang/c/KFvnB5dxw1A/m/qUBhSBerm3oJ {{Bare URL inline|date=August 2025}}</ref> It has been described as a [[Java (programming language)|Java]] variant that attempts to make useful improvements while retaining the fundamental utility and compatibility with Java. 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 of 2010. The 0.8 beta was released in December of 2010, and the 0.98.6 beta will bewas released shortly in early mid-2011 with additional typeloaders, making Gosu capable of loading [[XML Schema (W3C)|XML schema definition]] files (xsd's) and XML documents as native Gosu types. The latest version is 1.10, released in January 2016, along with a new IntelliJ IDEA editor plugin.
 
Guidewire continues to support and use Gosu extensively within InsuranceSuite applications. Guidewire has decided to freeze the development of new Gosu programming language constructs at this time. Guidewire continues to evolve InsuranceSuite through RESTful APIs and Integration Frameworks that can be accessed using Java.
==Examples==
 
==Philosophy==
Fibonacci
Gosu language creator and development lead, Scott McKinney, emphasizes pragmatism, found in readability and [[discoverability]], as the overriding principle that guides the language's design.<ref name=drdobbs>{{cite web|url=http://www.drdobbs.com/open-source/language-of-the-month-gosu/231001429#|title=Language of the Month: Gosu|date=2012-12-07|publisher=[[Dr. Dobb's Journal]]}}</ref> For instance, Gosu's rich static type system is a necessary ingredient toward best of breed tooling via [[static program analysis]], rich parser feedback, [[code completion]], deterministic refactoring, usage analysis, navigation, and the like.
 
==Syntax and semantics==
<source lang="C">
Gosu follows a syntax resembling a combination of other languages. For instance, declarations follow more along the lines of [[Pascal (programming language)|Pascal]] with name-first grammar. Gosu classes can have functions, fields, properties, and inner classes as members. Nominal inheritance and composition via [[delegation (object-oriented programming)|delegation]] are built into the type system as well as [[structural typing]] similar to the [[Go (programming language)|Go]] programming language.
function fib(n : int): int{
if (n < 2) return n
return fib(n-1) + fib(n-2)
}
 
Gosu supports several file types:
print (fib (20))
* Class (.gs files)
</source>
* Program (.gsp files)
* Enhancement (*.gsx files)
* Template (*.gst files)
In addition to standard class types Gosu supports enums, interfaces, structures, and annotations.
 
Program files facilitate Gosu as a scripting language. For example, Gosu's Hello, World! is a simple one-line program:<syntaxhighlight lang="gosu">
print("Hello, World!")
</syntaxhighlight>
 
Gosu classes are also executable a la Java:<syntaxhighlight lang="gosu">
XML
class Main {
static function main(args: String[]) {
print("Hello, World!")
}
}
</syntaxhighlight>
 
===Data types===
<source lang="C">
A unique feature of Gosu is its Open Type System, which allows the language to be easily extended to provide compile-time checking and IDE awareness of information that is typically checked only at runtime in most other languages. Enhancements let you add additional functions and properties to other types, including built-in Java types such as String, List, etc. This example demonstrates adding a print() function to java.lang.String.<syntaxhighlight lang="gosu">
/*
enhancement MyStringEnhancement : String {
Any XSD can be placed into a Gosu source directory, and types will automatically appear in the system that
function print() {
can be used to manipulate instance documents that conform to that schema. This example shows
print(this)
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" )
</syntaxhighlight>Now you can tell a String to print itself:<syntaxhighlight lang="gosu">
schema.Element[0].Name = "root"
"Echo".print()
schema.Element[0].ComplexType.Sequence.Element[0].Name = "child"
</syntaxhighlight>The combination of [[Closure (computer programming)|closures]] and enhancements provide a powerful way of coding with Collections. The overhead of Java streams is unnecessary with Gosu:
schema.Element[0].ComplexType.Sequence.Element[0].Type = schema.$Namespace.qualify( "string" )
<syntaxhighlight lang="gosu">
schema.print()
var list = {1, 2, 3}
</source>
var result = list.where(\ elem -> elem >= 2)
print(result)
</syntaxhighlight>
 
==Uses==
This general-purpose programming language is used primarily in [[Guidewire Software]]'s commercial products.
 
==References==
{{reflistReflist}}
 
*http://www.bobbywarner.com/2010/12/21/gosu/
==Further reading==
*http://www.sdtimes.com/content/article.aspx?ArticleID=35058&page=2&print
* {{cite web|url=http://wiki.jvmlangsummit.com/images/2/24/2011_Gross.pdf|title=Language Features As A Library: Using Gosu's Open Type System With External DSLs|first=Carson|last=Gross|work=JVM Language Summit 2011|publisher=Oracle|date=2011-07-18}} [https://video.oracle.com/detail/videos/featured-videos/video/1113248938001 Video]
 
==External links==
*[httphttps://gosu-lang.orggithub.io/ Official website]
*[https://github.com/gosu-lang/gosu-lang Source code repository]
**[http://gosu-lang.org/doc/wwhelp/wwhimpl/api.htm?&context=gosu&src=intro&topic=Welcome_to_Gosu Intro to the language]
 
*[http://lazygosu.org/ The Lazy Gosuer], an informal overview of the language
{{Portal bar|Free and open-source software}}
 
{{DEFAULTSORT:Gosu (Programming Language)}}
[[Category:Programming languages]]
[[Category:Object-oriented programming languages]]
[[Category:Java programming language family]]
[[Category:JVM programming languages]]
[[Category:ProgrammingSoftware languagesusing createdthe in theApache 2000slicense]]
[[Category:Programming languages created in 2002]]
[[Category:High-level programming languages]]
[[Category:Cross-platform free software]]
[[Category:Free and open source compilers]]
[[Category:Statically typed programming languages]]