Fork me on GitHub

Slogan                    Downloads       Documentation       Discuss       Home

Slogan is a programming language designed for high-performance concurrent, networked applications. It features first-class functions, lexical scoping and operations on structured data like strings, lists, arrays, sets and hash tables. Its powerful control flow and syntactic abstraction capabilities makes Slogan a highly extensible programming language.

A Taste of Slogan

let greetings = ["hello world", "हैलो दुनिया",
                 "안녕하세요 세계", "merhaba dünya"]
for_each(showln, greetings)

//> hello world
    हैलो दुनिया
    안녕하세요 세계
    merhaba dünya
// A concurrent TCP/IP "echo" server.
function echo_server(server_address = "", port = 1221)
  let (server = tcp_server_stream(server_address,
                                  port_number = port))
    letfn loop (client = read(server))
    { !respond_to(client)
      loop(read(server)) }

function respond_to(client)
{ showln(stream = client, string_upcase(read_line(client)))
  close_stream(client) }

// Start the server on port 1221:
echo_server()
// A client for the "echo" server.
let c = tcp_client_stream("localhost:1221")
showln(stream = c, "hello")
flush_writer(c)
read_line(c)
// HELLO
close_stream(c)
// Lazy Programming!
function integers(start) start:~integers(start + 1)
function primes(seq) filter(is_prime, seq)

let primes_from_1000 = primes(integers(1000))
first(primes_from_1000)
// 1009
second(primes_from_1000)
// 1013
nth(1234, primes_from_1000)
// 11689
// Actors in a concurrent computation.
function calc()
  let ([sender, [opr, a, b]] = !<)
  { sender !>
      case (opr)
        add  -> a + b
      | sub  -> a - b
      | div  -> a / b
      | mult -> a * b
      | _    -> 'invalid_operation
    calc() }

let calculator = !calc()
calculator !> [self(), ['add, 10, 20]] !<
// 30
calculator !> [self(), ['mult, 12, 93]] !<
// 1116
// Destrcuture and pattern-match composite objects.
function color(xs)
| [255, 0, 0] -> 'red
| [0, 255, 0] -> 'green
| [0, 0, 255] -> 'blue
| [r, g, b]
  where is_color(r)
        && is_color(g)
        && is_color(b)
               -> ['RGB, r, g, b]
| _            -> 'invalid_color_description

function is_color(n) is_integer(n) && n >= 0 && n <= 255

Summary of Features



Slogan is my hobby project and can be considered beta quality software. If you are a programmer and would like to hack on language implementation, you are welcome to contribute. You can work on one of the open issues or implement features/enhancements that you believe will make Slogan a better language. Send me your pull-request and it may make into the next release of Slogan!