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) + "

") } } # 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.

Advanced optimizations: The optimizations in the compiler combined with certain language features (integers, explicit exports, wrapped types, etc.) makes writing compact, efficient JavaScript code easy and pleasant.

The optimizations in the compiler combined with certain language features (integers, explicit exports, wrapped types, etc.) makes writing compact, efficient JavaScript code easy and pleasant. Fast compile times: Code compiles at the speed of a browser refresh. Web development still feels like web development despite using an optimizing compiler with static typing. This is in contrast to many other comparable compile-to-JavaScript languages.

Code compiles at the speed of a browser refresh. Web development still feels like web development despite using an optimizing compiler with static typing. This is in contrast to many other comparable compile-to-JavaScript languages. Natural debugging experience: Debugging is done in a single language using the platform-native debugger. No need to try to debug a multi-language app with a debugger that only understands one language.

Debugging is done in a single language using the platform-native debugger. No need to try to debug a multi-language app with a debugger that only understands one language. Easy integration: Generated code is very readable and closely corresponds with the original. Language features allow for the easy import and export of code to and from the target language.

Generated code is very readable and closely corresponds with the original. Language features allow for the easy import and export of code to and from the target language. Fast iteration time: In addition to a fast compiler and a good debugging experience, garbage collection is used instead of manual memory management. This eliminates a whole class of time-consuming bugs that get in the way of the important stuff.

In addition to a fast compiler and a good debugging experience, garbage collection is used instead of manual memory management. This eliminates a whole class of time-consuming bugs that get in the way of the important stuff. Native code emission: For native targets, application logic is compiled directly to native code and is not interpreted in a virtual machine. Native apps don't have to pay for JIT warmup time and native app performance is not at the whim of heuristics. The generated code can be compiled using industry-standard compilers that leverage decades of optimization work.

Lack of IDE support: IDE support is planned but is a significant undertaking and will not materialize for a while. Developers who normally lean heavily on IDEs will be less efficient than usual.

IDE support is planned but is a significant undertaking and will not materialize for a while. Developers who normally lean heavily on IDEs will be less efficient than usual. Immaturity: This is a new programming language and hasn't stood the test of time. There will likely be many rough edges both in the language design and in the tools. Many planned features are not yet implemented.

This is a new programming language and hasn't stood the test of time. There will likely be many rough edges both in the language design and in the tools. Many planned features are not yet implemented. Lack of community: New programming languages don't have the wealth of searchable Q&A data that established programming languages have. Solutions to random issues are likely not available online.

New programming languages don't have the wealth of searchable Q&A data that established programming languages have. Solutions to random issues are likely not available online. No cross-platform multithreading: Multithreading is not a language feature and needs to be done in the target language. This limits multithreading opportunities to cleanly separable tasks like image decoding.

Multithreading is not a language feature and needs to be done in the target language. This limits multithreading opportunities to cleanly separable tasks like image decoding. Lack of low-level features: Features such as memory layout, move semantics, destructors, and vector instructions are intentionally omitted. These features don't map well to all language targets and their emulation is expensive. Use of these features is limited to imported library routines implemented in the target language.

Getting Started

Installation

Pros:Cons:

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:

Example browser app (JavaScript) Create a file called "sparks.sk" that looks like this: Invoke the compiler to generate JavaScript code. Any compilation errors will show up here: skewc sparks.sk --output-file=sparks.js Create another file called "index.html" to serve the compiled code: <body></body> <script src="sparks.js"></script> That's it! Open "index.html" in a browser to see the app. To build a production-ready version of your app, just add the "--release" flag to the end of the compiler invocation: skewc sparks.sk --output-file=sparks.js --release

Example terminal app (JavaScript) Create a file called "calculator.sk" that looks like this: Invoke the compiler to generate JavaScript code. Any compilation errors will show up here: skewc calculator.sk --output-file=calculator.js That's it! Run the generated code to see the app: node calculator.js

Example terminal app (C#) Create a file called "calculator.sk" that looks like this: Invoke the compiler to generate C# code. Any compilation errors will show up here: skewc calculator.sk --output-file=calculator.cs Compile the C# code to generate a .NET executable. The example here uses Mono, an open-source implementation of Microsoft's .NET Framework. mcs calculator.cs -out:calculator.exe That's it! Run the generated executable to see the app: mono calculator.exe

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

Visual Studio Code



Install the skew package for syntax highlighting, inline errors, type tooltips on hover, and other nice IDE features. Visual Studio Code is a cross platform Chromium-based text editor that works on Windows, OS X, and Linux and has nothing to do with the original Visual Studio product. Installing extensions in Visual Studio Code is a little strange. Use to bring up the in-app command line, then type "ext install skew-vscode" and press enter when it loads.

Install the skew package for syntax highlighting, inline errors, type tooltips on hover, and other nice IDE features. Visual Studio Code is a cross platform Chromium-based text editor that works on Windows, OS X, and Linux and has nothing to do with the original Visual Studio product. Installing extensions in Visual Studio Code is a little strange. Use to bring up the in-app command line, then type "ext install skew-vscode" and press enter when it loads. Sublime Text



Follow these instructions to install syntax highlighting. Right-click and using the "Goto Definition" command sort of works (it looks for all declarations with that name).

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.