Gosu is a
statically typed
In computer programming, a type system is a logical system comprising a set of rules that assigns a property called a ''type'' (for example, integer, floating point, string) to every '' term'' (a word, phrase, or other set of symbols). Usu ...
general-purpose programming language
In computer software, a general-purpose programming language (GPL) is a programming language for building software in a wide variety of application Domain (software engineering), domains. Conversely, a Domain-specific language, domain-specific pro ...
that runs on the
Java Virtual Machine
A Java virtual machine (JVM) is a virtual machine that enables a computer to run Java programs as well as programs written in other languages that are also compiled to Java bytecode. The JVM is detailed by a specification that formally descr ...
. Its influences include
Java
Java is one of the Greater Sunda Islands in Indonesia. It is bordered by the Indian Ocean to the south and the Java Sea (a part of Pacific Ocean) to the north. With a population of 156.9 million people (including Madura) in mid 2024, proje ...
,
C#, and
ECMAScript
ECMAScript (; ES) is a standard for scripting languages, including JavaScript, JScript, and ActionScript. It is best known as a JavaScript standard intended to ensure the interoperability of web pages across different web browsers. It is stan ...
. Development of Gosu began in 2002 internally for
Guidewire Software, and the language saw its first community release in 2010 under the
Apache 2 license.
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.
[https://gosu-lang.github.io/] It has been described as a
Java
Java is one of the Greater Sunda Islands in Indonesia. It is bordered by the Indian Ocean to the south and the Java Sea (a part of Pacific Ocean) to the north. With a population of 156.9 million people (including Madura) in mid 2024, proje ...
variant that attempts to make useful improvements while retaining the fundamental utility and compatibility with Java. It was used to configure
business logic
In computer software, business logic or domain logic is the part of the program that encodes the real-world business rules that determine how data can be created, stored, and changed. It is contrasted with the remainder of the software that might ...
in Guidewire's applications and was more of a simple rule definition language. In its original incarnation it followed
ECMAScript
ECMAScript (; ES) is a standard for scripting languages, including JavaScript, JScript, and ActionScript. It is best known as a JavaScript standard intended to ensure the interoperability of web pages across different web browsers. It is stan ...
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
XSD (XML Schema Definition), a recommendation of the World Wide Web Consortium (W3C), specifies how to formally describe the elements in an Extensible Markup Language (XML) document. It can be used by programmers to verify each piece of item cont ...
files 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.
Philosophy
Gosu language creator and development lead, Scott McKinney, emphasizes pragmatism, found in readability and
discoverability Discoverability is the degree to which something, especially a piece of content or information, can be found in a search of a file, database, or other information system. Discoverability is a concern in library and information science, many aspects ...
, as the overriding principle that guides the language's design.
For instance, Gosu's rich static type system is a necessary ingredient toward best of breed tooling via
static program analysis
In computer science, static program analysis (also known as static analysis or static simulation) is the analysis of computer programs performed without executing them, in contrast with dynamic program analysis, which is performed on programs duri ...
, rich parser feedback,
code completion
Code completion is an autocompletion feature in many integrated development environments (IDEs) that speeds up the process of coding applications by fixing common mistakes and suggesting lines of code. This usually happens through popups while typ ...
, deterministic refactoring, usage analysis, navigation, and the like.
Syntax and semantics
Gosu follows a syntax resembling a combination of other languages. For instance, declarations follow more along the lines of
Pascal with name-first grammar. Gosu classes can have functions, fields, properties, and inner classes as members. Nominal inheritance and composition via
delegation
Delegation is the process of distributing and entrusting work to another person.Schermerhorn, J., Davidson, P., Poole, D., Woods, P., Simon, A., & McBarron, E. (2017). ''Management'' (6th ed., pp. 282–286). Brisbane: John Wiley & Sons Australia. ...
are built into the type system as well as
structural typing
A structural type system (or property-based type system) is a major class of type systems in which type compatibility and equivalence are determined by the type's actual structure or definition and not by other characteristics such as its name o ...
similar to the
Go programming language.
Gosu supports several file types:
* Class (.gs files)
* 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:
print("Hello, World!")
Gosu classes are also executable a la Java:
class Main
Data types
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.
enhancement MyStringEnhancement : String
Now you can tell a String to print itself:
"Echo".print()
The combination of
closures and enhancements provide a powerful way of coding with Collections. The overhead of Java streams is unnecessary with Gosu:
var list =
var result = list.where(\ elem -> elem >= 2)
print(result)
Uses
This general-purpose programming language is used primarily in
Guidewire Software's commercial products.
References
Further reading
*
Video
External links
Official websiteSource code repository
{{DEFAULTSORT:Gosu (Programming Language)
Programming languages
Object-oriented programming languages
Java programming language family
JVM programming languages
Software using the Apache license
Programming languages created in 2002
High-level programming languages
Cross-platform free software
Free and open source compilers
Statically typed programming languages