Quantcast
Channel: Zynga Engineering » Cloud infrastructure
Viewing all articles
Browse latest Browse all 7

PlayScript – A Compiler and Runtime for a Cross Platform World

$
0
0

We are excited to announce that we are open sourcing the PlayScript compiler and runtime, which we hope will help developers with a toolset that aims to comprehensively target the diverse web and mobile platforms.  PlayScript is a new open source compiler and runtime built on the Mono platform which both compiles existing ActionScript to mobile devices, and introduces a brand new language “PlayScript” which is a dramatic extension of ActionScript with new advanced capabilities.  The PlayScript language adds new features to ActionScript such as generics, events, native arrays, native types, value types, and async programming, essentially combining the best features of C# and ActionScript to target all platforms.  We’ve heard this new language described as “ActionScript on Steroids”.  Here’s a taste of code that can be written in PlayScript.

// Basic types

var b:byte;
var l:long;
var f:float;
var d:double;

// Conditional compilation
#if DEBUG
#else
#endif

// Fixed arrays
var a:int[] = new int[100];

// Properties
public property MyProperty:int {
    get { return _myInt; }
    set { _myInt = value; }
}

// Events
public event MyEvent;

// Delegates
public delegate MyDelegate(i:int):void;

// Operator overloading
public static operator - (i:int, j:int):int {
}

// Indexers
public indexer this (index:int) {
   get { return _a[index]; }
   set { _a[index] = value; }
}

// Generics
public class Foo.<T> {
   public var _f:T;

   public function foo<T>(v:T):void {
   }
}

// Async
async function AccessTheWebAsync():Task.<int>
{
   var client:HttpClient= new HttpClient();
   var getStringTask:Task.<String> = client.GetStringAsync("http://msdn.microsoft.com");
   var urlContents:String = await getStringTask;
   return urlContents.Length;
}

We have been collaborating with the authors of Mono to build a smooth path to moving the compiler and base frameworks upstream into the Mono project, and the authors of Starling and Away 3D to ensure compatibility with our runtime and compiler.  Presently we have both Starling and Away 3D working with some minor tweaks, including fully functional demos and with further work to improve both the runtime and compiler compatibility we are targeting compatibility “out of the box” for these libraries.  We have made our current “work in progress” forks of these game engine libraries in our github repository.    We would also welcome collaboration with other projects commercial or free, in order to improve our compatibility and are very grateful for the contributions made so far to the effort from the open-source community.

The Starling 2D renderer library running in Mono on an iPhone 5 (screenshots)

screenshot1

Screenshot of an Away3D demo

screenshot2

 

The PlayScript compiler project, along with information and installation instructions and current Starling and Away3D libraries are available at playscriptlang.org.

We encourage anyone with interest in building great cross platform games and applications to take PlayScript for a spin.   If you would like to send feedback or participate in shaping this project or language, please join our playscript Google Group.

 

Authors:

Ben Cooley – Distinguished Engineer

Icer Addis – Senior Architect

 


Viewing all articles
Browse latest Browse all 7

Latest Images

Trending Articles





Latest Images