Skip to content

Sibilisp is a Sibilant based s-expression language which transpiles to JavaScript.

License

Notifications You must be signed in to change notification settings

urbandrone/sibilisp

Repository files navigation

logo

GitHub license NPM version Github stars NPM downloads

A multi-paradigm, functional programming oriented, Sibilant based language dialect that transpiles to JavaScript. If you think that this sounds 👽, maybe you'd like to see some example code! The following function checks if a given String contains a palindrome by recursively comparing the characters at the start and end positions:

(defun string-is-palindrome? (s)
  (let ((low-s (.to-lower-case s)))
    (loop ((start 0)
          (end (decf (length s))))
      (cond ((not (eql? (getf low-s start) (getf low-s end))) false)
            ((>= start end) true)
            :else (recur (incf start) (decf end))))))

(string-is-palindrome? "kayak")  ; => true
(string-is-palindrome? "baobab") ; => false

And don't worry about "too much ( and )" - they are what enables a powerful macro system that you have right at your fingertips to meld the basic language into a real Domain Specific Language that reads almost as if it where a instructional book:

(include "./src/macros/categories")
(include "./src/macros/products")
(include "./src/macros/dom")

(defun find-products-by-hashtag (hashtag)
  (|> hashtag
      (escape-hashtag)
      (categories-find-id :by-hashtag)
      (products-query 
        :by-type 'category
        :sort-by ('popular 'descending)
        :per-page 50)
      ($render-html-template
        :render-async true
        :into-node "#products"
        :template "../templates/productpage.tpl"
        :vars (:pagination true
               :pagination-pagesize 10
               :viewtype 'grid
               :sort-types ('popular 'newest 'best-rated)
               :sort-by 'popular
               :sort-direction 'descending
               :recommendations true))))

Features

Sibilisp ...

  • brings the ES2015+ module system to Sibilant, as well as several new macros for ES2015+ promises, default function arguments, generator functions, yielding...
  • enables tail recursive programming via it's loop and recur construct.
  • is tailored towards functional programming concepts, but remains being a multi-paradigm language.
  • has build-in facilities for creating tagged type and sum type constructors.
  • supports .slisp, .sibilant and .js files in the same project and can compile all of them into plain JavaScript files.
  • results in readable JavaScript that does not modify built-in prototypes. 🤗
  • is fun to use. 😎

Documentation

As of now, documentation can be found in the GitHub wiki.

Wiki

Guides

API & Language

Examples
🚧 Under construction

Reasoning

Sibilant is a LISP-like language based on s-expressions, that is written in itself and transpiles to JavaScript. It ships a very nice macro system with it that almost* works like a real LISP macro system (awesome!). However, writing Sibilant code is almost the same as writing JavaScript code (that's by intention) whereas it could be operating on a much higher level of abstraction. This is when Sibilisp comes into play.

Sibilisp uses the underlying macro system of Sibilant to further develop a dialect that enhances it's base language, ranging from macros that implement various new JavaScript features - like the ES2015+ module system - to macros which provide pattern matching** or recursion.

As a free bonus, Sibilisp ships with a functional programming toolkit as separate ES2015+ module called prelude that you can use in your programs. If you are a JavaScript programmer, think of it as a built-in Lodash or Underscore.

Notes:
* Everything is based on JavaScript, so certain limitations apply
** Again, to a limited degree

About

Sibilisp is a Sibilant based s-expression language which transpiles to JavaScript.

Topics

Resources

License

Stars

Watchers

Forks