Blade - A simple, fast, clean, and dynamic language that allows you to develop complex applications quickly.

Overview

The Blade Programming Language

Quick links: BUILDING | CONTRIBUTING | DOCS | LICENSE | Chat on Gitter

code analysis Linux build macOS build Windows (MSVC) build Windows (MinGW64) build


tl;dr

Blade is a simple, fast, clean and dynamic language that allows you to develop complex applications quickly. Blade emphasises algorithm over syntax and for this reason, it has a very small but powerful syntax set with a very natural feel.


HELP IS URGENTLY NEEDED TO TEST BLADE WELL ON WINDOWS.

I currently lack a Windows device to test Blade on Windows. While I expect most features to work, I cannot guarantee that they do and therefore solicit the help of fellow and willing contributors who can actively test Blade on Windows devices.

Thanks!

Features

  • Simple syntax and minimal keywords.
  • Dynamically typed.
  • Fast.
  • Comprehensive builtin functions.
  • Object-oriented (only supports single inheritance for now. Multiple inheritance is open for discussion).
  • Exceptions.
  • Closures.
  • Custom iterable classes.
  • Garbage collection.
  • Stack-based VM.
  • REPL
  • Lightweight.
  • Highly portable.

Example

The following code prints the sum of all numbers in an array.

def sum(numbers) {
    var result = 0

    for num in numbers {
        result += num
    }

    echo 'the sum is ${result}'
}

sum([1, 2, 3, 4]) # this prints "the sum is 10"

Documentation

Documentation is currently in-progress in the blade-docs repo. You can read the Blade language documentation online at bladelang.com.

C Extensions to Blade

Blade supports external extensions built in C. While the website is yet to include documentation on writing C extensions, there is an easy-to-pick-up example in the blade-ext-demo repository.

GOTCHAS!

For some weird reasons yet unknown, thirdparty C modules for Blade don't work correctly on Blade installations built with MSVC (Visual Studio). To be able to use external C modules on Windows, build or use a Blade installation built with either TDM-GCC or MinGW64.

Directory Structure

Directory Contents
benchmarks Contains the sample benchmarks for Blade (some are based on the Benchmark games).
libs Contains the Blade standard library.
src The source code of the Blade language including the native implementation of some Blade library classes and functions in the modules directory.
scripts Helper scripts for various uses such as automated installation.
tests A few test cases that Blade implementation must pass.
thirdparty Contains open-source libraries and packages used by Blade

How to contribute

Along with Blade's goal to be simplicity, flexibility and expressiveness is a strong desire to make the community around it as friendly and welcoming as possible. Therefore, all forms of contributions from pull requests, suggestions, typo fixes in documentation, feature request, bug reports and any contribution at all is greatly welcomed and appreciated.

WE NEED HELP! From review of this documentation, to suggestions on the core features of Blade, testing of Blade features, writing more comprehensive tests, bug detection, code fixes and more. PLEASE CONTRIBUTE!

Contributing code, fixes and features

The standard. The general workflow is as follows.

  1. Find/file an issue on the Issues tab.
  2. Fork the repo and make your changes.
  3. Push your changes to a branch in your forked repo. For coding guidelines, see the project README file.
  4. Submit a pull request to Blade from your forked repo.

You can also just mail your issues to Ore Richard Muyiwa directly.

Coding Standard

  • I decided to break from the popular camel case common to C style languages and went with snake cases. Honestly speaking, the only justifiable reason is because I think it looks cool. I know you may have a differing opinion, but I will really appreciate it that you keep to that in your PRs. I used this same style for both the C source and the core library.

  • For formatting, simply follow the LLVM guide minus the whole braces {/} on separate line thing. It looks really ugly. I advice you use the JetBrains CLion or Visual Studio Code IDE(s) to format your code before submitting for PR.

That simple!

Sponsors

JetBrains Logo

Comments
  • Remove copyleft code for Win32 support; compile with MinGW headers.

    Remove copyleft code for Win32 support; compile with MinGW headers.

    This PR removes the copyleft code I could find and tries to use permissive alternatives where possible.

    • Added three new vendored libraries in thirdparty/, which are distributed given their individual licensing conditions as seen in the license header and README.md in each of their seperate respective subdirectories, to accomplish compilation using Visual Studio:

      • asprintf
      • gettimeofday
      • strsep
    • Removed support for termios, use HAVE_TERMIOS to signal termios support.

    • Use configure_file() in CMakeLists.txt to generate config.h from config.h.in.

    • Introduced several new configuration variables to config.h.

    • Use BSD-licensed getopt instead.

    • Use system-provided unistd.h and getopt.h if possible, i.e. on *BSDs, Linux and macOS, rather than the included versions.

    • Add own dirname and basename implementation using _splitpath_s.

    GOTCHAS

    • Ctrl-C is no longer handled on Windows. The POSIX signal SIGINT is not supported by default on Windows; are handled differently and are handled on a different thread, and support for this must be added later.

    • Most #include directives need significant clean-up, because there is a lot of redundancy.

    • A pre-compiled header should be used in place of #include <Windows.h> and so on as there are a large number of subsequent dependencies of that header, which slows compilation down; also, this is considered good practice on Windows.

    • credits() in the REPL should present the licenses for thirdparty libraries if they are linked in.

    Fixes issue #47.

    opened by galexite 21
  • Creation of a programming language based on Blade.

    Creation of a programming language based on Blade.

    Hello,

    We want to create a programming language for professional, personal and utility needs. We want to base ourselves on your language, which we find very interesting in its simplicity and speed. Can we fork your project? Or take over the project for free?

    Cordially, Zuygui

    opened by waterdrop-io 11
  • Program execution that use Cygwin utilities disable Ansi sequence (cmd.exe terminal)

    Program execution that use Cygwin utilities disable Ansi sequence (cmd.exe terminal)

    Windows 10 21H1 cmake version 3.21.4 VSC 2019 - 16.11.6 / MSVC v142 / kit SDK Windows 10 (10.0.19041.0)

    install Cygwin/mingw64 if necessary

    try this script:

    import os
    
    echo '\x1B[31m' + ' Hello foo: before c++/\msys64 use ' + '\x1B[0m'
    os.exec('C:\\msys64\\mingw64\\bin\\c++ --version')
    echo '\x1B[32m' + ' Hello foo:  after c++/\msys64 use ' + '\x1B[0m'
    
    echo ""
    echo '\x1B[31m' + ' Hello foo: before c++/cygwin use ' + '\x1B[0m'
    os.exec('C:\\cygwin64\\bin\\c++ --version')
    echo '\x1B[32m' + ' Hello foo:  after c++/cygwin use ' + '\x1B[0m'
    

    result:

    Hello foo: before c++/\msys64 use 
    Hello foo:  after c++/\msys64 use 
    
    Hello foo: before c++/cygwin use 
    ←[32m Hello foo:  after c++/cygwin use ←[0m
    

    P.S. easier to test the 'bug': download wgrib2.exe and all cygwin dll at: https://ftp.cpc.ncep.noaa.gov/wd51we/wgrib2/Windows10/v3.0.2/

    echo '\x1B[31m' + ' Hello foo: before wgrib2 use ' + '\x1B[0m'
    os.exec('path_to_wgrib2\\wgrib2 --version')
    echo '\x1B[32m' + ' Hello foo:  after wgrib2 use ' + '\x1B[0m'
    
    opened by progamateur 11
  • Reassigning/overwriting file variable breaks a loop that creates a long string

    Reassigning/overwriting file variable breaks a loop that creates a long string

    OS: Windows 10 Professional version: 21H1 Blade version : 0.0.6

    Run the following script,

    var str_len = 1500
    #str_len = 200
    var file_id = file('foo')
    file_id = file('bar')
    # Loop for creating 'str' string
    var str = ''
    iter var idx = 0; idx < str_len; idx++ {
        str += '1'
    }
    echo 'End of iter loop'
    

    Result: the last line is not executed because the loop that creates the string stops before the end and interrupts the script.

    If you either uncomment line 2 # str_len = 200 (the string length is reduced to 200 characters) or comment line 4 file_id = file('bar') (file_id is no longer overwrited), End of iter loop is displayed as expected.

    bug good first issue 
    opened by progamateur 8
  • Failed to compile

    Failed to compile

    Describe the bug

    A clear and concise description of what the bug is.

    To Reproduce

    Steps to reproduce the behavior:

    1. Go to '...'
    2. Click on '....'
    3. Scroll down to '....'
    4. See error

    Expected behavior

    A clear and concise description of what you expected to happen.

    Screenshots

    If applicable, add screenshots to help explain your problem.

    Desktop (please complete the following information):

    • OS: [e.g. iOS]
    • Browser [e.g. chrome, safari]
    • Version [e.g. 22]

    Smartphone (please complete the following information):

    • Device: [e.g. iPhone6]
    • OS: [e.g. iOS8.1]
    • Browser [e.g. stock browser, safari]
    • Version [e.g. 22]

    Additional context

    Add any other context about the problem here.

    opened by waterdrop-io 7
  • A loop that creates a long list is unexpectedly interrupted

    A loop that creates a long list is unexpectedly interrupted

    Windows 10 / 21H1 Blade 0.0.6 (latest)

    The following script that creates a list of 'n' numbers breaks if 'n' is above 406

     def create_list(list_len) {
         var list = []
         echo "Trying to create a ${list_len}-elements list"
    	     iter var j = 0; j < list_len; j++ {
    		     list += [j]
    	     }
         echo "      list content: " + list[0] + ", " + list[1] + " ... " + list[-2] + ", " + list[-1]
    }
     
     var n = 500
     echo ""
     create_list(n);
    
    echo "\nEnd of script"
    

    Result if 'n' equals 500:

     Trying to create a 500-elements list
    

    Result if 'n' equals 400:

     Trying to create a 400-elements list
               list content: 0, 1 ... 398, 399
    
     End of script
    
    opened by progamateur 6
  • README code example

    README code example

    Often times what gets me and many other people to not look further into projects, is the lack of very minimal examples. I think the README should contain a tiny example, so that people can get a feel for the language right away. Since the language is very small, it doesn't really make that much sense to have a hello world example.

    I propose something like:

    def sum(numbers) {
        var result = 0
    
        for num in number {
            result += num
        }
    
        print(result)
    }
    
    sum([1, 2, 3, 4]) # this will print "10"
    

    This presents the developer with information about:

    • functions
      • defining functions
      • calling functions
      • function arguments
    • variables
    • for loops
    • assignment
    • printing
    • arrays
    • single-line comments
    opened by BenStigsen 6
  • Linking with `blade_termios.h` in any form means whole project must comply with GPL v3 or later license conditions

    Linking with `blade_termios.h` in any form means whole project must comply with GPL v3 or later license conditions

    blade_termios.h has a file header which shows that it has been originally licensed under GPL v3.

    This file must be removed to keep blade under the permissive conditions of the MIT license.

    opened by galexite 6
  • Installation Error

    Installation Error

    I followed the instructions for installation, however once I get to curl the repo, I get an error 46% into the make saying the following:

    [ 46%] Built target linenoise
    cc: fatal error: Killed signal terminated program cc1
    compilation terminated.
    gmake[2]: *** [thirdparty/pcre2/CMakeFiles/pcre2.dir/build.make:251: thirdparty/pcre2/CMakeFiles/pcre2.dir/pcre2_match.c.o] Error 1
    gmake[1]: *** [CMakeFiles/Makefile2:351: thirdparty/pcre2/CMakeFiles/pcre2.dir/all] Error 2
    gmake: *** [Makefile:114: all] Error 2
    cp: cannot create directory '/home/root/.blade': No such file or directory
    mv: cannot stat '/home/root/.blade': No such file or directory
    Linking Blade...
    

    Desktop:

    • OS: Raspbian / Raspberry Pi OS
    • Version: 11 (Bullseye)
    opened by greped 5
  • Remove REPL `

    Remove REPL `"nil"` printing

    Is your feature request related to a problem? Please describe.

    print(10) in the REPL outputs 10nil It does not look nice when printing, that it is followed by nil.

    Describe the solution you'd like

    print(10) should print 10 and not include nil.

    This can be fixed by changing: https://github.com/blade-lang/blade/blob/main/src/vm.c#L1549-L1553

    Currently this is the code:

    if (vm->is_repl) {
      echo_value(peek(vm, 0));
    } else {
      print_value(peek(vm, 0));
    }
    

    I propose:

    if (vm->is_repl) {
      // maybe have a variable to avoid peeking twice
      if (!IS_NIL(peek(vm, 0))) {
        echo_value(peek(vm, 0));
      }
    } else {
      print_value(peek(vm, 0));
    }
    

    I'm curious as to why this is a thing. Is this a bug or is it for something like debugging? If wanted I can go ahead and PR this.

    Proposal 
    opened by BenStigsen 5
  • Replacing `# comments` with `// comments`

    Replacing `# comments` with `// comments`

    Currently comments are being made like so:

    # Hello World
    
    /* 
    Hello
    There
    World 
    */
    

    This to me does not make sense. Not only is this inconsistent with languages like JS, C, Python and a whole bunch of other languages. But it's also a bit harder to remember. My proposal is to use // comment instead as it makes switching to Blade easier. It's easier to remember, not only because of other languages, but also because one character less is used.

    If this isn't going to be changed to // that is fine, but I do at least propose some more consistency between single line and multiline comments. In JS, C and many more languages this is the / character, since it is used for both single-line and multiline. In Lua this is --, etc...

    Proposal 
    opened by BenStigsen 5
  • echo not requiring braces

    echo not requiring braces

    Long time since I've been here, but I've been following the project closely. One thing that I have not been a fan of, is the exception with echo not requiring braces. It's inconsistent and I'm not quite sure I understand the purpose of it?

    opened by BenStigsen 0
  • Professional looking new logo and icon for Blade

    Professional looking new logo and icon for Blade

    Hi All,

    The current Blade icon and logo are not very professional or attractive. Using this issue to request help from designers to help create one that looks cool and professional.

    Thanks in advance.

    Regards

    help wanted good first issue 
    opened by mcfriend99 0
  • Add support for operator overloading

    Add support for operator overloading

    Is your feature request related to a problem? Please describe.

    As it stands, Blade classes are first class and can be used in almost anything including iterables, values and more. It will greatly increase consistency to have Blade classes support operator overloading from classes.

    Proposed Solution

    Since today, Blade classes can become iterators by implementing the @iter and @itern decorators, Blade can employ decorators for operator overloading support.

    E.g.

    class A {
        @+(a2) {
            return self.value + a2.value
        }
    }
    
    var a1 = A()
    a1.value = 5
    
    var a2 = A()
    a2.value = 7
    
    echo a1 + a2
    

    The above sample code should print 12 to terminal.

    Alternative Solution

    As an alternative, we could use a keyword operator.

    For example:

    class A {
        operator + {
            return self.value + __arg__.value
        }
    }
    
    var a1 = A()
    a1.value = 5
    
    var a2 = A()
    a2.value = 7
    
    echo a1 + a2
    

    This will at best require an extra conditionally valid keyword __arg__.

    Proposal 
    opened by mcfriend99 3
Releases(v0.0.77)
Owner
Blade Programming Language
A simple, fast, clean and dynamic language that allows you to develop complex applications quickly.
Blade Programming Language
A simple tool that aims to efficiently and quickly parse the outputs of web scraping tools like gau

massurl is a simple tool that aims to parse the outputs of tools like gau, and extract the parameters for each URL, remove duplicates and do it all very quickly. Because web scraping tools' outputs can get very large very quickly, it is nice to have a tool that parses them and and outputs something clean and easy to read.

Fr1nge 13 Jul 24, 2022
fx is a workspace tool manager. It allows you to create consistent, discoverable, language-neutral and developer friendly command line tools.

fx is a workspace tool manager. It allows you to create consistent, discoverable, language-neutral and developer friendly command line tools.

null 19 Aug 27, 2022
Had a tough time playing Microsoft Wordament ? Well WORDament_Solver has your back. It suggests you meaningful words you can use while playing the game and help you top the leaderboard.

WORDament_Solver Had a tough time playing Microsoft Wordament ? Well WORDament_Solver has your back. It suggests you meaningful words you can use whil

Tushar Agarwal 3 Aug 19, 2021
"Sigma File Manager" is a free, open-source, quickly evolving, modern file manager (explorer / finder) app for Windows, MacOS, and Linux.

"Sigma File Manager" is a free, open-source, quickly evolving, modern file manager (explorer / finder) app for Windows, MacOS, and Linux.

Aleksey Hoffman 1.1k Dec 31, 2022
King Hamlet is a simple tool, which allows you to perform a Process Ghosting Attack

KingHamlet Process Ghosting Tool - 64 bits Only! King Hamlet is a simple tool, which allows you to perform a Process Ghosting Attack

null 149 Dec 27, 2022
Tightly coupled GNSS-Visual-Inertial system for locally smooth and globally consistent state estimation in complex environment.

GVINS GVINS: Tightly Coupled GNSS-Visual-Inertial Fusion for Smooth and Consistent State Estimation. paper link Authors: Shaozu CAO, Xiuyuan LU and Sh

HKUST Aerial Robotics Group 587 Dec 30, 2022
Step-by-step guide through the abstract and complex universe of Fragment Shaders.

The Book of Shaders by Patricio Gonzalez Vivo and Jen Lowe This is a gentle step-by-step guide through the abstract and complex universe of Fragment S

Patricio Gonzalez Vivo 4.9k Jan 2, 2023
Helper C++ classes to quickly preintegrate IMU measurements between SLAM keyframes

mola-imu-preintegration Integrator of IMU angular velocity readings. This repository provides: IMUIntegrator and RotationIntegrator: C++ classes to in

The MOLA SLAM framework 12 Nov 21, 2022
A set of projects for quickly calculating the sine function using Chebyshev polynomials

sin_approx_04 Содержит несколько проектов, написанных на языке С. Цель их создания - реализовать быстрое вычисление тригонометрической функции синуса

null 8 Jul 11, 2022
A Script to thin Universal Apps on macOS quickly

UBThinner A Script to thin Universal Apps on macOS quickly. It traverses through the given folder recursively, identifies any universal binaries and t

Arm 2 Dec 26, 2021
🔥 A number of Flutter projects that cover slightly more complex topics.

Check out the YouTube videos to see the indepth process of each project! Reactive Grid https://youtu.be/OEtt_8_FU0s Fancy Full Screen Animation https:

Philip Vu 27 Dec 18, 2022
A C++11 large integer library with effective high performance, simplistic in nature and also clean in the eyes.

BigIntegerCPP BigIntegerCPP is a C++11 port of large integer library used in CryptoLib4Pascal. It allows mostly parsing of numbers as strings in diffe

Telepati 26 Dec 22, 2022
Clean tab-less browser based on webkit2 and GTK4.

Rose Browser Simple browser based on webkit2-5.0/GTK4. Showcase Requirements In order to build rose you need gtk4 and webkit2gtk-5.0. In order to use

Rosé 287 Jan 2, 2023
A bright opening, a clear sight, a clean slate.

Skylight A bright opening, a clean window. Etymology According to dictionary.com, a "skylight" is: an opening in a roof or ceiling, fitted with glass,

null 52 Dec 24, 2022
Source Code for 'Clean C++20' by Stephan Roth

Apress Source Code This repository accompanies Clean C++20 by Stephan Roth (Apress, 2021). Download the files as a zip using the green button, or clon

Apress 20 Dec 24, 2022
A library to develop kernel level Windows payloads for post HVCI era

A library to develop kernel level Windows payloads for post HVCI era

Dmytro Oleksiuk 283 Dec 15, 2022
Develop easily on devices like the Samsung Galaxy Z Flip / Z Flip 3

Helper for "Flip" devices A plugin to easily develop Flutter applications for Flip devices like Samsung Galaxy Z Flip or Samsung Galaxy Z Flip 3. It w

Edouard Marquez 4 Sep 8, 2021