• Stars
    star
    323
  • Rank 130,051 (Top 3 %)
  • Language Objective-C++
  • License
    Other
  • Created over 12 years ago
  • Updated over 3 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A language built on top of the Objective-C runtime, and ABI compatible with Objective-C.

Tranquil

This project is pretty much abandoned. It's too much work to keep up with the changing LLVM APIs

Tranquil is a programming language built on top of LLVM & the Objective-C Runtime.

It aims to provide a more expressive & easy to use way to write Mac and iOS Apps.

Its features include:

  • Compatibility with C/ObjC headers, meaning that there is no need to create special bindings for C APIs.
  • Automatic memory management.
  • Line by line debugging. (Using LLDB or GDB) — still under development, but breaking on, and stepping over source lines is supported
  • Dynamic Typing.
  • Language level concurrency support.
  • String interpolation.
  • Multiple assignment.
  • Message cascading.
  • Unlimited number range.
  • Unicode through&through (変数=123 works fine)
  • Good performance, even at this extremely early stage.
  • And more..

However, Tranquil is still extremely experimental and you shouldn't use it for anything other than exploration and learning.

How to build and run

The simplest way of getting started is to use the binary installer. Everything will be placed into /usr/local/tranquil (Requires Xcode 5.1 to be installed)

If you wish to contribute, you can use the install script instead which checks out the latest source and sets up the development environment.

> curl -fsSkL https://raw.github.com/fjolnir/Tranquil/master/Tools/install.sh | /bin/zsh
> /usr/local/tranquil/bin/tqrepl

Note: OS X ≥ 10.7 or iOS ≥ 5 is required to run compiled tranquil programs. 10.9 is required to compile.

Learning the language

To learn more about Tranquil you should read the specification and check out the tests.

You can also talk to me directly by visiting #tranquil on irc.freenode.net.

And here're a couple of examples:

Print a Mandelbrot fractal

mandelbrot = { x, y, bailout=16, maxIter=1000 |
    cr, ci = y-0.5, x
    zi, zr = 0
 
    maxIter times: {
        temp = zr*zi
        zr2, zi2 = zr^2, zi^2
        zr = zr2 - zi2 + cr
        zi = 2*temp + ci
        ^^no if zi2 + zr2 > bailout
    }
    ^yes
}
 
(-1 to: 1 withStep: 1/40) each: { y |
    (-1 to: 1 withStep: 1/40) each: { x |
        (mandelbrot(x, y) ? #● ! #◦) printWithoutNl
    }
    #"" print
}

Iterate an array

alternatives = ["Objective-C", "Ruby", "Nu", "Perl", "Python"]
alternatives each: `alternative | "Tranquil is nicer than «alternative»" print`
"Or so I hope at least." print

Reduce

sum = (0 to: 1000000) reduce: `obj, accum=0 | obj+accum`

Do two things at the same time

a = async foo()
b = bar()
whenFinished {
    "a is «a» and b is: «b»" print
}

Chain messages (Without having to return self from every method you write)

var = Character new setName: "Deckard"; setOccupation: "Blade Runner"; self

Do multiple assignment

a, b = b, a  \ Swap b&a

Return non-locally

a = {
    b = {
        ^^123
    }
    b()
    ^321
}
a() print \ This prints '123'

Calculate fibonacci numbers (In a not-so-performant manner)

fib = `n | n > 1 ? fib(n-1) + fib(n-2) ! n`
fib(10) print

Make a database query (Using DatabaseKit)

import "DatabaseKit"
db = DB withURL: "sqlite://data/database.sqlite"
query = db[#aTable] select: #field; where: { #anotherField => aValue }
val   = query[#field]

\ We can write that more concisely as:
val   = table[{ #anotherField => aValue }][#field]

Create a Web Server (Using HTTPKit)

import "HTTPKit"
HTTP new handleGet: "/"
              with: `connection| "Hello World!"`;
      listenOnPort: 8080
           onError: `"Unable to start server" print`

Evaluate a regular expression

"Foobar starts with foo." print if /foo[a-z]+/i matches: "Foobar"

Use the OpenGL & GLUT APIs

import "GLUT" \ This simply reads in your GLUT.h header. No bindings are required.

GlutInit(0, nil)
GlutInitDisplayMode(GLUT_DOUBLE)
GlutInitWindowSize(640, 480)
GlutInitWindowPosition(200, 200)
GlutCreateWindow("Tranquil is cool as beans!")

GlClearColor(0, 0, 0, 0)
GlScalef(0.4, 0.4, 0.4)

GlutDisplayFunc({
    GlRotatef(0.1, 0, 1, 0)
    GlClear(GL_COLOR_BUFFER_BIT)
    GlColor3f(0, 1, 0)
        GlutWireDodecahedron()
    GlColor3f(1, 1, 1)
        GlutWireTeapot(0.7)
    GlutSwapBuffers()
})

lastX, lastY = 0
GlutMotionFunc({ x, y |
    dx, dy = lastX - x, lastY - y
    GlRotatef(dx, 0, 1, 0)
    GlRotatef(dy, 1, 0, 0)
    lastX, lastY = x, y
})

GlutIdleFunc(GlutPostRedisplay)
GlutMainLoop()

More Repositories

1

xnomad

A tiling window manager for OS X, written in tranquil.
C
483
star
2

DatabaseKit

An Objective-C database abstraction framework.
Objective-C
383
star
3

HTTPKit

A minimal, high-performance Objective-C library to write self-sufficient web applications. Built on top of Mongoose.
Objective-C
210
star
4

TLC

The Tiny Lua Cocoa Bridge
Lua
136
star
5

CoreFoundation-Lite-Linux

CFLite fixed to build correctly on linux (Tested on debian with clang 3.0)
C
38
star
6

Menufela

A little SIMBL hack that enables you to toggle the menubar on/off.
Objective-C
34
star
7

Tranquil-Live

A Lua LiveCoding environment for Mac
Objective-C
16
star
8

CodeRunner-templates

My CodeRunner templates (See readme for list)
Shell
15
star
9

GLMath

Simple math toolkit for use in computer graphics
C
14
star
10

Blackshades

Blackshades fixed to make it build on osx (Blackshades was created by Wolfire games - http://www.wolfire.com)
C++
13
star
11

yaccviso

Yacc grammar visualizer –– This repo is no longer maintained, please use Kaplan's official repo instead.
C
10
star
12

sekwenser

A step sequencer for use with the Korg PadKONTROL
Objective-C
10
star
13

Dynamo

A little OpenGL powered 2d engine written in C (That is very much in progress)
C
8
star
14

Beets

A little iPhone utility that listens to music through the mic and displays its BPM
Objective-C
7
star
15

FABatching

A single header library for adding allocation batching&pooling to Objective-C classes.
C
3
star
16

ShaderToy

A little app that runs fragment shaders in a ShaderToy.com like environment locally
Objective-C
3
star
17

FConvenience

Nice to have macros, for writing less cluttered code
Objective-C
3
star
18

Foundation-Lite

A subset of Foundation for Linux [Not maintained]
Objective-C
3
star
19

CoreFoundation-Lite-OS-X

CoreFoundation fixed to build on retail OS X (See readme for build instructions)
C
2
star
20

Dynamo-Android-Sample

A simple Android sample for Dynamo
C
2
star
21

objc-autoinit

Automatic init methods for Objective-C
C
2
star
22

Dynamo-iOS-Sample

A simple iOS sample for Dynamo
Objective-C
1
star
23

qdnes

Quick&Dirty NES, a toy project I'm using to learn how to write emulators (Not even close to working, and may never)
C++
1
star
24

marklit

A little tool for writing literate C code using markdown
Ruby
1
star
25

FLazyObjects

Classes for lazily allocating objects.
Objective-C
1
star
26

Scroll-availability-indicators

A little hack that adds a shadow on the edges of scroll views if there is content out of view (in Lion)
Objective-C
1
star