Gosu (programming language)
Programming language
From Wikipedia, the free encyclopedia
Gosu formerly GScript, is a statically typed general-purpose programming language that runs on the Java virtual machine. Its influences include Java, 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 2.0.[2]
| Gosu | |
|---|---|
| Designed by | Scott McKinney |
| Developer | Guidewire Software, open source contributors |
| First appeared | November 11, 2010 |
| Stable release | |
| Typing discipline | static |
| Platform | Execute on Java virtual machine, statically and dynamically compiles to bytecode |
| OS | any supporting JVM |
| License | Apache 2.0 |
| Filename extensions | .gs, .gsp, .gst, .gsx |
| Website | gosu-lang |
| Influenced by | |
| Java, C# | |
| Influenced | |
| Kotlin | |
Gosu can serve as a scripting language, having free-form Program types (.gsp files) for scripting and statically verified Template files (.gst files). Gosu can optionally execute these and all other types directly from source code with no precompiling, which also distinguishes it from other static languages.
History
Gosu is often described as a Java variant that introduces practical improvements while maintaining compatibility and interoperability with Java. The language originated in 2002 at Guidewire Software, where it was first named GScript, a scripting language designed for use in Guidewire applications.[3][4] As GScript evolved from a simple scripting tool into a general-purpose programming language, it was renamed Gosu by its lead developer, Scott McKinney.
Originally created as a glue language to allow Guidewire customers to define business rules, Gosu quickly found broader use within the company’s products, supporting areas such as user interface bindings, templating, and document management. Over time, Gosu became the main implementation language across Guidewire’s application suite, surpassing Java in overall use.
Guidewire released Gosu 0.7 beta to the public in November 2010, followed by 0.8 beta in December 2010 and 0.8.6 beta in mid-2011. These releases introduced several enhancements, including new typeloaders that allowed Gosu to dynamically represent external data formats such as JavaScript Object Notation (JSON) and Extensible Markup Language (XML) as native Gosu types.
Guidewire continues to use and support Gosu extensively within its InsuranceSuite applications. While active development of new Gosu language features has been paused, the company continues to expand InsuranceSuite through Representational State Transfer (REST) application programming interfaces (APIs) and integration frameworks accessible from Gosu and Java.
Philosophy
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.[5] 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, use analysis, navigation, and the like.
Syntax and semantics
Gosu follows a syntax resembling a combination of other languages. For instance, declarations are similar to Pascal with name-first grammar. Gosu classes can have functions, fields, properties, and inner classes as members. Nominal inheritance and composition via delegation are built into the type system and structural typing similar to the Go 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!" program is a simple one-line string:
print("Hello, World!")
Gosu classes are also executable a la Java:
class Main {
static function main(args: String[]) {
print("Hello, World!")
}
}
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 {
function print() {
print(this)
}
}
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 = {1, 2, 3}
var result = list.where(\ elem -> elem >= 2)
print(result)
Uses
This general-purpose programming language is used mainly in Guidewire Software's commercial products.