Introduction to Gosu

Similar documents
Comp 411 Principles of Programming Languages Lecture 34 Semantics of OO Languages. Corky Cartwright Swarat Chaudhuri November 30, 20111

Overview. Elements of Programming Languages. Advanced constructs. Motivating inner class example

History OOP languages Year Language 1967 Simula Smalltalk

e ag u g an L g ter lvin v E ram Neal G g ro va P Ja

To Java SE 8, and Beyond (Plan B)

Xtext Documentation. September 26, 2014

Programming in C# with Microsoft Visual Studio 2010

Chapter 1 Fundamentals of Java Programming

Unlocking the Java EE Platform with HTML 5

Introduction to Object-Oriented Programming

The Java Series. Java Essentials I What is Java? Basic Language Constructs. Java Essentials I. What is Java?. Basic Language Constructs Slide 1

YouTrack MPS case study

CSCI 253. Object Oriented Programming (OOP) Overview. George Blankenship 1. Object Oriented Design: Java Review OOP George Blankenship.

JSR-303 Bean Validation

Ruby on Rails. Object Oriented Analysis & Design CSCI-5448 University of Colorado, Boulder. -Dheeraj Potlapally

LAB4 Making Classes and Objects

JavaScript. JavaScript: fundamentals, concepts, object model. Document Object Model. The Web Page. The window object (1/2) The document object

TypeScript for C# developers. Making JavaScript manageable

Java Interview Questions and Answers

Visual C# 2012 Programming

Certified PHP/MySQL Web Developer Course

The Decaffeinated Robot

Textual Modeling Languages

Free Java textbook available online. Introduction to the Java programming language. Compilation. A simple java program

core. Volume I - Fundamentals Seventh Edition Sun Microsystems Press A Prentice Hall Title ULB Darmstadt

Introduction to Java

Free Java textbook available online. Introduction to the Java programming language. Compilation. A simple java program

Getting Started with the Internet Communications Engine

Progressive Enhancement With GQuery and GWT. Ray Cromwell

TypeScript. Language Specification. Version 1.4

MDA Overview OMG. Enterprise Architect UML 2 Case Tool by Sparx Systems by Sparx Systems

How Scala Improved Our Java

Eclipse with Mac OSX Getting Started Selecting Your Workspace. Creating a Project.

The end. Carl Nettelblad

Tutorial on Writing Modular Programs in Scala

Dynamic website development using the Grails Platform. Joshua Davis Senior Architect Cognizant Technology Solutions

3D Animation of Java Program Execution for Teaching Object Oriented Concepts

Konzepte objektorientierter Programmierung

Android Developer Fundamental 1

Hibernate Language Binding Guide For The Connection Cloud Using Java Persistence API (JAP)


GContracts Programming by Contract with Groovy. Andre Steingress

Fundamentals of Java Programming

Specialized Programme on Web Application Development using Open Source Tools

Handout 1. Introduction to Java programming language. Java primitive types and operations. Reading keyboard Input using class Scanner.

Web development... the server side (of the force)

CA Identity Manager. Glossary. r12.5 SP8

Hands on exercise for

Creating Web Services Applications with IntelliJ IDEA

The C Programming Language course syllabus associate level

APACHE SLING & FRIENDS TECH MEETUP BERLIN, SEPTEMBER APACHE SLING & SCALA Jochen Fliedner

Specialized Programme on Web Application Development using Open Source Tools

Building and Using Web Services With JDeveloper 11g

Sonatype CLM Enforcement Points - Continuous Integration (CI) Sonatype CLM Enforcement Points - Continuous Integration (CI)

Java SE 6 Update 10. la piattaforma Java per le RIA. Corrado De Bari. Sun Microsystems Italia Spa. Software & Java Ambassador

Guile Present. version 0.3.0, updated 21 September Andy Wingo

Gallio: Crafting a Toolchain. Jeff Brown jeff.brown@gmail.com

qwertyuiopasdfghjklzxcvbnmqwerty uiopasdfghjklzxcvbnmqwertyuiopasd fghjklzxcvbnmqwertyuiopasdfghjklzx cvbnmqwertyuiopasdfghjklzxcvbnmq

Basic Java Constructs and Data Types Nuts and Bolts. Looking into Specific Differences and Enhancements in Java compared to C

Embracing Eclipse Orion

INTRODUCTION TO JAVA PROGRAMMING LANGUAGE

Working with Indicee Elements

JAAS Java Authentication and Authorization Services

GlassFish v3. Building an ex tensible modular Java EE application server. Jerome Dochez and Ludovic Champenois Sun Microsystems, Inc.

Outline. Lecture 18: Ruby on Rails MVC. Introduction to Rails

JavaScript Patterns. Stoyan Stefanov. O'REILLY' Beijing Cambridge Farnham Koln Sebastopol Tokyo

Data Tool Platform SQL Development Tools

Tutorial: Getting Started

Java Programming Fundamentals

Integrating TAU With Eclipse: A Performance Analysis System in an Integrated Development Environment

The Sun Certified Associate for the Java Platform, Standard Edition, Exam Version 1.0

NASA Workflow Tool. User Guide. September 29, 2010

COSC282 BIG DATA ANALYTICS FALL 2015 LECTURE 2 - SEP 9

creating a text-based editor for eclipse

Server-side OSGi with Apache Sling. Felix Meschberger Day Management AG 124

Model-Driven Development - From Frontend to Code

Writing Self-testing Java Classes with SelfTest

Eclipse 4 RCP application Development COURSE OUTLINE

First Java Programs. V. Paúl Pauca. CSC 111D Fall, Department of Computer Science Wake Forest University. Introduction to Computer Science

Running and Testing Java EE Applications in Embedded Mode with JupEEter Framework

C++ INTERVIEW QUESTIONS

How to Improve Database Connectivity With the Data Tools Platform. John Graham (Sybase Data Tooling) Brian Payton (IBM Information Management)

Module 13 Implementing Java EE Web Services with JAX-WS

Lecture 1 Introduction to Android

Java CPD (I) Frans Coenen Department of Computer Science

How To Implement Lightweight ESOA with Java

The Service Revolution software engineering without programming languages

Introducing Apache Pivot. Greg Brown, Todd Volkert 6/10/2010

Tutorial 5: Developing Java applications

JavaScript Basics & HTML DOM. Sang Shin Java Technology Architect Sun Microsystems, Inc. sang.shin@sun.com

Java Programming Language

D06 PROGRAMMING with JAVA. Ch3 Implementing Classes

JAVA DSLs MIT VOLLER BANDBREITE. Sebastian Zarnekow itemis AG

REMOTE DEVELOPMENT OPTION

EMC Documentum Composer

Using ADOBE FLASH TM BUILDER 4.7

Chapter 1 Java Program Design and Development

latest Release 0.2.6

Programming Languages CIS 443

Editors Comparison (NetBeans IDE, Eclipse, IntelliJ IDEA)

Transcription:

Introduction to Gosu A New Language for the JVM from --------------- Scott McKinney Guidewire Software smckinney@guidewire.com www.gosu-lang.com

Today s Discussion Background Highlights Open Type System Language Features Tools Q&A

Background Guidewire Provide large scale, highly configurable applications Gosu enables unified configuration of customer facing resources: Rules, Workflows, Web pages, Messaging, Web-services, Tests, etc. Language History (2002 present) No statically typed, embeddable scripting language available Started small as a rule expression language Evolved slowly: Scripting OOP Open Type Sys Bytecode Roots Influenced by Java, C#, EcmaScript, Ruby, Pascal Static type system an absolute requirement, esp. for tooling Ideals: Pragmatic, Versatile, Professional

Highlights

Open Type System Open Type System = Pluggable Type System Open API for defining custom types Abstractions for type loading and type information Avoids messy code generation Alternative to DSL Domain Specific Type (DST) Examples of Types: Gosu & Java Templates XSD / XML Web Services / WSDL Database Entities Web Pages Name Resources Etc. Included in open source Internal to Guidewire

Type System Structure Type System Type System Type Loaders TypeLoader 1 TypeLoader 2... TypeLoader N Types Type 1 Type 2... Type N Type Information TypeInfo Open API Feature Information ConstructorInfo PropertyInfo MethodInfo AnnotationInfo

Open API ITypeLoader IType gettype( String name )... IType ITypeInfo gettypeinfo()... ITypeInfo List<IPropertyInfo> getproperties() List<IMethodInfo> getmethods() List<IConstructorInfo> getconstructors()... IMethodInfo IMethodCallHandler getcallhandler()... IMethodCallHandler Object handlecall( Object ctx, Object args )...

Included Types Gosu provides several kinds of types in the current open source release. These include: Classes, Interfaces, Enums Enhancements Programs Templates Blocks/Closures XSD / XML Web Services / WSDL Dynamic Type*

Language Features

Obligatory Hello World Brace for it

Hello World Hello.gsp print( "Hello World!" ) > gosu Hello.gsp Hello World! > Gosu runs Programs No boilerplate class No main() method More on programs later More on Command Line Gosu later

Back to Langauge Features

Object Oriented Superset of Java s OO capabilities Fully compatible w/ Java Single class, multiple interface inheritiance Composition/Delegation support Properties Annotations Enhancements (add behavior to existing types) Anonymous types with variable capture

Class Structure package demo uses java.util.list... class Foo { var _name : String construct()... function foo()... property get Name() class Inner... } package keyword same as Java uses keyword = Java import class public by default fields constructors methods properties inner types

Programs Gosu executes Programs/Scripts No more boilerplate class with static main() Can be a simple expression or Can define any number of statements Can define functions and properties Can define classes, inner classes, and closures Type-safe access to command line arguments

Programs uses javax.swing.jframe uses java.awt.rectangle var frame = new MyFrame() showmyframe() function showmyframe() { frame.visible = true } Mix statements with Functions and Classes class MyFrame extends JFrame { construct() { super( "Hello" ) DefaultCloseOperation = DISPOSE_ON_CLOSE Bounds = new Rectangle( 100, 100, 100, 100 ) } }

Templates Are types e.g., com.foo.sometemplate Support JSP/ASP-style syntax: <%, <%=, etc Support ${ syntax too Declare parameters: <%@ params( x: String ) %> Can be used anywhere Are supported in String Literals

Templates MyTemplate.gst <% uses java.util.date %> <%@ params(x : String) %> Template text <% if( x.hascontent ) { %> Invisible template text <% } %> <%- - comment - - %> Usage: // Render directly to String var str = MyTemplate.renderToString( "hello" ) // Render to writer MyTemplate.render( _writer, "hello" ) // Embedded in a String literal var str = "The date is ${new Date()}" The param is: ${x}

Generics Reified! var foo = new Foo<String> print( foo typeis Foo<String> ) // true! Array-style Variance (no wildcards, easy to understand!) var l : List<CharSequence> l = new ArrayList<String>() Type parameters of non-bytecode types var l = new ArrayList<xsd.abc.Person>() Fully Compatible with Java Generics class Album<T extends Photo> extends ArrayList<T>

Enhancements package demo enhancement MyListEnhancement<T> : List<T> {... function each( visit(item: T) ) {... } } e.g., var list = {"Pascal", "Java", "Gosu"} list.each( \ e - > print( e ) ) Add methods and properties to existing types (including Java) Look and feel like a class, implicit this reference Fully support generics Don t modify existing class; just type information Statically dispatched Can t add state no fields allowed

Closures/Blocks Let s turn a list of Strings into a list of their lengths... var list = {"Pascal", "Java", "Gosu"} // Collections with blocks (and enhancements)... var list2 = list.map( \ e - > e.length() ) // The declaration site looks like: function map<q>( mapper(elt : T):Q ) : List<Q> {... } Anonymous functions declared inline Can be either expressions or statement lists Argument and return types inferred based on context True closures with captured variables Invoked like normal functions Covariance on return types, contravariance on argument types

Type Inference var list = {"Pascal", "Java", "Gosu"} Life without type inference var list2 : List<Integer> = list.map<integer>( \ e : String - > e.length() ) The String type is inferred from the map() method map() s type parameter is inferred from the block s return type Finally, list2 s type is inferred from map() s generic return type var list2 = list.map( \ e - > e.length() )

Composition/Delegation Composition in Gosu // Sample Mixin interface public interface IClipboardPart { boolean cancopy(); void copy(); boolean canpaste(); void paste();... } class MyWindow extends Window implements IClipboardPart { delegate _clipboardpart represents IClipboardPart... } delegate keyword represents clause specifies interfaces, owning class must declare Compiler automatically dispatches to delegate s implementation Otherwise behaves just like a field A single delegate can represent multiple interfaces

More Language Features Context sensitive eval() support (in a static language? really!) Using-statement supports RAII (Resource Acquisition Is Initialization) Map and Collection initialization syntax Object initializer syntax Extensive interval support e.g., 1..10 Enhanced switch-statement (any type, any expression) Smarter for-statement (handle more types, provides index) Associative array syntax for dynamic access to properties Null short-circuit in property access expressions No checked exceptions! Etc.

Tools!!! In our view: A professional, general purpose language is impractical without full-featured IDE support The larger the project, the greater the pressure on tools Huge productivity gains via build-time type-safety, editor feedback, code completion, navigation, usage searching, and refactoring are not achievable without the ability to perform solid static analysis Good news: Gosu s type system enables a rich set of static analysis tools We ve been busy

Eclipse Plug-in Full-Featured Syntax coloring Instant feedback as you type Code completion Code navigation Member Usage Search Type Usage Search Refactoring Hover text Structure views Occurrence highlighting Full featured debugger

Eclipse Plug-in

REPL Command Line

Interactive Script Editor

Q&A