Skew

Try Live
Getting Started
Docs
GitHub

Skew is a web-first, cross-platform programming language with an optimizing compiler.

What is it?

Skew is a programming language for building cross-platform software. It compiles to straightforward, readable source code in other languages and is designed to be easy to integrate into a mixed-language code base. The main focus of the project has been to develop solid, production-quality code for the web. Skew looks like this:

# Execution starts at the entry point
@entry
def fizzBuzz {
  for i in 1..101 {
    var text = mod(i, 3, "Fizz") + mod(i, 5, "Buzz")
    document.write((text == "" ? i.toString : text) + "\n")
  }
}

# The compiler inlines this function in release mode
def mod(i int, n int, text string) string {
  return i % n == 0 ? text : ""
}

# Imported declarations are just for type checking
@import
namespace document {
  def write(text string)
}

The language and compiler are in development and are still somewhat subject to change. The compiler is bootstrapped, which means it's written in Skew and compiles itself. It currently contains production-quality JavaScript generation and working C# generation. C++ generation is next and is already in progress.

Why use it?

The intent is to use this language for the platform-independent stuff in an application and to use the language native to the target platform for the platform-specific stuff. When done properly, the vast majority of the code is completely platform-independent and new platforms can be targeted easily with a small platform-specific shim.

Pros: Cons:

Getting Started

Installation

First, install node if you don't have it already. The release version of the compiler is cross-compiled to JavaScript and node is a JavaScript runtime. Installing node also installs a package manager called npm that can be used to install the compiler:

npm install -g skew

The compiler command is called "skewc". Run "skewc --help" to see a list of all available command-line flags. Example usage:

skewc src/*.sk --output-file=compiled.js --release

Examples

Here are some simple examples to start from. Each example demonstrates how to do input and output using imported code from the target language:

All of these examples use the "dynamic" type for simplicity, but you'll likely want type imports for real work. Skew will eventually have a package manager and type imports will live there. I've put some HTML5 type imports on GitHub for convenience in the meantime.

An important thing to keep in mind when developing with Skew is that the compiler does dead code elimination. This means the compiler won't generate any output if nothing is marked for export. You can either indicate a "main" function with the "@entry" annotation as is done in the examples above, or you can use the "@export" annotation to ensure certain functions are exported.

To get a better feel for the language, it's probably helpful to take a look at the different examples of Skew code in the live editor in addition to looking at the documentation below.

IDE support

Language Reference

This reference is collapsed by default to make it easy to quickly get to different entries. Either click an entry below to expand it or expand all entries in this section to read them all at once.

Standard Library

This reference is collapsed by default to make it easy to quickly get to different entries. Either click an entry below to expand it or expand all entries in this section to read them all at once.

Compiler Optimizations

The compiler currently includes quite a few different optimizations aimed at reducing size code when compiling to JavaScript to speed up network transfer time. Most of these passes can be enabled individually with compiler flags but they are all enabled with the "--release" flag.

This reference is collapsed by default to make it easy to quickly get to different entries. Either click an entry below to expand it or expand all entries in this section to read them all at once.

Input
Output