Getting Started

From Swym Wiki
Jump to: navigation, search

Welcome to Swym. This programming language is designed to let you Say What You Mean, as clearly and elegantly as possible. (It's pronounced "swim", in case you were wondering.)

Swym is probably best categorized as a functional language. It's statically typed, with type inference and generics, and is implemented in Javascript - which means it can run right here in this wiki page.

print( "Swim for the win!".map(partial{"i":"y"}) )

(Click "Run" to run the program. Clicking "Sandbox" takes you to a separate page where you can try rewriting the program and run it. Your changes won't be saved to the wiki, so feel free to play around.)

I designed Swym in a crazy way - I wrote down some programs I wanted to be able to write, regardless of whether they were implementable; and then I reverse-engineered semantics for them. That process showed me how I needed to change the programs, to make them behave more consistently, and to make them parseable. It took about five years of iterating like this, on and off, before the language finally started to gel enough to be implementable. I hope you like the results. If nothing else, this process seems to have given it a unique feel, blending a bunch of new ideas with some preexisting ones hand-picked from Javascript, Python, Haskell, APL, Lisp, and no doubt others.

Swym's design goal is to be the most readable language ever made. (Obviously, that's very subjective, so don't be surprised if you disagree - especially at first sight. FAQ: No, that's not the same as trying to look "clean" or "pretty". Swym has quite a lot of punctuation to help ensure that the program's structure is clear even when users extend it. FAQ: No, of course not all Swym code will be maximally readable. The language can only provide tools to allow readable code to be written; it cannot enforce it.)

The language's strategy to maximize readability is to let users express their program's logic using familiar, intuitive high level concepts - such as "each", "all", "none", "etc", "where" - and define their own, with a minimum of fuss.

[edit] Reading List

But hey, maybe you're in a hurry, and you just want to get a taste of what the language is like. Well, here's a little buffet of code examples. Read on for full details.

Functional programming with a minimalist syntax:

"the quick brown fox jumps over the lazy dog"{.1st.uppercase + .tail}.categorizeBy{.length}

Multivalues - expressions that evaluate to fragments of a list

[10, 1..4, 0, 100, 1<..<8]

The etc keyword:

1/2 + 2/4 + 3/8 + etc

Quantifiers - the natural english concepts of "none", "some" and "all".

Int.'isPrime' returns [ this.divisibleBy(none[1<..this.sqrt.floor]) ]
// (My apologies; that's a horrible algorithm for detecting prime numbers...)


The first tutorial is: The Basics.

Personal tools