Open Type System
Even with all its features, Gosu would not exist today if it were not for its innovative type system. Earlier, I mentioned that Gosu is the language that unifies the configuration of our very large-scale applications. By this I mean that Gosu brings together a host of otherwise disparate domains under one language. For example, our Gosu classes, web UI components, XSD models, OR entities, Java classes, and various other stores of information are all represented as first-class types in Gosu. Does this mean we do a bunch of code generation? No. How then do these types find their way into our type system?
Metatypes are abstractions in Gosu's type system. Unlike other languages, Gosu is not limited to a single, rigid, metatype definition. For instance, Java's metatype is the
Class class. If you need to plug into Java's type system, you've got one option: generate code that can be compiled to a Java class. Gosu's metatype and type loader are pure interfaces. So, instead of a closed system of concrete classes, Gosu's type system is open, with public interfaces anyone can implement. Our base language includes type loaders and metatype definitions for all forms of Gosu classes (classes, interfaces, enums, programs, and templates). But internally, these types are no more significant to Gosu's compiler than the ones we built to access entities, XSDs, or Java classes.
So what does it mean, for example, when I say XSDs are first-class types? Leveraging the open type system, we've implemented a type loader and metatype to represent XSDs as types in Gosu. For example, say you have an XSD file,
location.xsd, that defines element types relating to a location. You put this file in your class path somewhere. Now, you can reference its element types in Gosu as if they were real Gosu types, because they are real Gosu types! For instance, the expression
xsd.location.Address is a legal type reference corresponding to the
Address element defined in the XSD. The attributes of elements are exposed as properties on the corresponding type. No code generation is done behind the scenes it's all statically typed.
There's a lot more to discuss regarding the open type system and its capabilities, but I hope I've provided enough to pique your interest. Some folks are already at work. For instance, Ronin, an MVC web framework for Gosu, together with Tosa, a zero-configuration OR layer, leverage Gosu and metatypes to provide an impressive framework. If you're interested in building something nontrivial with Gosu, I highly recommend giving this framework a go.
It's difficult to talk about the benefits of a new language without having a tooling conversation. One reason Gosu is statically typed is because tooling is so vitally important to us, both as a company and as programmers with a keen interest in productivity. It is not some dogmatic attempt at stoking the dynamic-versus-static fire. It should come as no surprise, then, that we've been busy building IDE plugins for Gosu.
IntelliJ IDEA and Eclipse are the most popular Java IDEs on the market, so we set out to build full-featured plugins in both. Our Eclipse plugin has been generally available since the release of Gosu in November of last year. If Eclipse is your IDE, give the Gosu plugin a spin.
At Guidewire, we use IntelliJ IDEA as our primary IDE (Gosu was built using IntelliJ). I've personally used both Eclipse and IntelliJ extensively and have never been disappointed with IntelliJ it is rock solid. We are currently working on revising our IntelliJ plugin and it should be generally available soon. Install the "Gosu" plugin directly from IntelliJ's Project Settings dialog.
I should mention that the Gosu core language bundles a simple code editor with some tooling built in. For instance, it supports syntax highlighting, parser feedback, code completion, and navigation. You can also directly execute programs you write from inside the editor. It's ideal for experimenting with Gosu or writing very small projects.
Now that Gosu has been properly introduced, you might feel compelled to learn more on your own. You can check out all the details at gosu-lang.org. Experiment with it, kick the tires, involve it in your next project and let us know what you think. We're working hard to make Gosu the catalyst for your next innovation.
Scott McKinney is the creator and architect of Gosu and works on Gosu and Gosu-based tools at Guidewire.