Giter VIP home page Giter VIP logo

bish's Introduction

bish

Shell scripting with a modern feel.

What

Bish is a lightweight language created to bring shell scripting into the 21st century. It gives programmers the comfort of modern syntax but compiles to Bash, resulting in good portability (in as much as Bash is portable).

Currently, Bish is still a very new language. I am adding new features as fast as I can, but it is bound not to support something you might like. In that case, see if you can implement it and submit a pull request!

As a side note, I won't stop you, but you would probably be crazy to use Bish in any sort of production environment until it stabilizes a bit more.

Some small examples are below, but see the introduction wiki page for a more comprehensive introduction.

Examples

Function calls
def fib(n) {
    if (n < 2) {
        return 1;
    }
    return fib(n-1) + fib(n-2);
}
Shell commands
def printall(files) {
    for (f in files) {
        println(f);
    }
}
# cwd, ls, and cd are all builtin functions.
dir = cwd();
files = ls();
println("Files in current directory $dir:");
printall(files);
cd("/");
println("Files in root directory:");
printall(ls());
Shell-like features
# I/O redirection (like pipes) is a first-class language feature.
pattern = "bish";
matches = ls() | @(grep $pattern);
println("Files in current directory matching $pattern:");
for (m in matches) {
    println(m);
}

How

Just clone and build with 'make'. There are no dependencies other than the C++ standard library. Compile bish to bash with the command:

$ ./bish input.bish > output.bash

Then run the compiled file:

$ bash output.bash

Why

I can't count the number of times when I wanted to write a quick shell script to automate an easy task, only to waste hours tracking down idiosyncrasies in Bash syntax and semantics. Bish tries to fill this niche: when you want a lightweight shell scripting language and don't wish to break out the larger hammer of Python, Perl, etc...

However, I created this language first and foremost as a weekend project and exercise in writing a compiler from scratch. I've dealt with pieces of compilers before, but have never written one from start to finish. Thus, I hope this project can also serve as a good teaching tool. I tried to design it with clarity in mind, so it should be simple to extend the language, or write a new back end.

To do

The language and compiler are pretty bare-bones as of now. A selection of things I intend to do:

  • Improve parsing error messages
  • Implement type checking
  • Figure out what to do about floats
  • Expand standard library of builtin functions

bish's People

Contributors

amitsaha avatar digitalsurgeon avatar edschouten avatar egorsmkv avatar inndy avatar marcelometal avatar noahmorrison avatar richq avatar tdenniston avatar tristil avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.