Narcoleptic Pasta Manufacturer

    beryl

    1.0.4 • Public • Published

    Beryl

    Welcome to Beryl, a template-based programming language meant to help you work smarter. While some languages focus on speed or size, Beryl focuses on readability and productivity (and it doesn't do too bad on speed or size, either). Forget all you know about formal syntax. Forget trying to explain to your coworkers what that weird one-line function on line 3732 does. Forget the speech your mentor gave you about commenting code; it's not needed anymore. For example, can you guess what this line of code does?

    Log Hello World to the console.
    

    You guessed it, it logs "Hello World" to the console. It does the same thing as console.log("Hello World");, but it's far more readable. You don't have to worry about the console object, or quoting what obviously are strings, or spending four hours hunting down a bug caused by a missing semi-colon. The cool part is, Beryl's way is only five characters more. And though I like to use them for extra readability, you don't technically need the to or the . Technically log Hello World to console does the trick, and it's actually one character shorter than the JavaScript version.

    It's based off of JavaScript (with implementations in PHP and Python on the way), so it can be used anywhere JavaScript can. It eliminates the need for different server-side and client-side languages, replaces all of CSS's functionality with more understandable code, and with the help of the mysql packages, can abstract MySQL away for you too.

    It's been over 170 years since Ada Lovelace published the first computer program. We shouldn't still have to use as many languages and frameworks and modules and whatnot to create a simple website.

    How To Use It

    Beryl works in the browser and NodeJS. Take a look at version 1.0.4 hosted on JSDelivr or the NodeJS version 1.0.4 on npm. It's dead simple to set up and get started.

    In The Browser

    Just create your template HTML file and include a <script src="https://cdn.jsdelivr.net/npm/beryl@1.0.2/browser/1.0.2.js"></script> in the <head> section. (For those of you screaming about putting a <script> in the <head>, only about 80 lines of JS run at first, so it's not slowing anything down.) Then whenever the browser's parser runs across <beryl-lang> tags, it'll run the Beryl code inside.

    <body>
    	<p>Hi there!</p>
        <beryl-lang>
    		x = 4 + 3
    		log x to console
    	</beryl-lang>
    </body>
    

    In NodeJs

    This one is super easy. Just npm install beryl on the command line. It'll install Beryl in the current folder and give you two options:

    1. Just run beryl filename on the command line. It'll start running the code in whatever file you give it.
    2. Or, move the node/beryl.js file into your root folder. Running that JavaScript file with NodeJS will run all the Beryl code in main.beryl (and it's not hard to change that to something else by poking around at the end of beryl.js).

    How It Works

    Beryl uses a dead-simple templating syntax. It's not required to understand this to use the language, but it helps greatly. Here are the rules:

    • Words in double square brackets are optional.
    • Colon-separated words in double parenthesis indicate that one of them must be chosen.
    • Words in double curly brackets indicate variables.

    What does that mean? Well, templates in Beryl are lines. Every line of Beryl code must match a template, and the Beryl or JavaScript code associated with that template is run with the variables taken from the line of code. For example, take this template:

    import ((the:a:an:)) package from [[the]] {{file}} [[file]]
    

    That template describes the syntax of a Beryl line. The word import is required in the beginning, then the coder can choose between the, a, an, and `` where the parentheses are. The words the and file are in double square brackets, meaning they're optional. The word file in double curly brackets is a variable. Whatever the coder puts there gets passed into the code associated with this template, like parameters into a function. Really, all that's required is import package from filename.beryl, however, it's encouraged to use the optional words for readability. All of the following lines will be matched to the above template, with the file variable being filename.beryl:

     - import package from filename.beryl
     - import the package from filename.beryl
     - import a package from filename.beryl
     - import an package from filename.beryl
     - import package from the filename.beryl file
     - import the package from the filename.beryl file
     - import a package from filename.beryl file
    

    and the list goes on. In the Beryl source code, this template is associated with a JavaScript function. Inside that function, this.file equals filename.beryl, since that's what we named the variable in the template. If the template had a {{myCrazyVariableName}} in it, then inside the JavaScript function, this.myCrazyVariableName would equal whatever the coder passed in, just like a function parameter in other languages.

    Now I hear you screaming, 'But doesn't that mean we still have to use JavaScript?!?!?!?' The answer is NO. In Beryl, you can define templates of your own (equivalent to functions in other languages), that let you create your own reusable blocks of code without being confined to the unintuitive syntax of most programming languages. Try this:

    define a new template named sum as add [[up]] {{first_number}} and {{second_number}}
        result = first_number + second_number
        return result
    end template sum
    

    That wasn't painful, now was it? Don't worry, it'll get even easier. Go ahead, ask Beryl for the sum of 4 and 9.

    four_plus_nine = add up 4 and 9
    log four_plus_nine to the console
    

    Guess what Beryl spits back out? You guessed it, 13. You can even put these template definitions into a separate file for clarity, and import them into the main file later on.

    When was the last time a language let you define syntax that you thought was intuitive? They say a lot of programming languages sound like natural language, but Beryl's unique templating system means that it is the only programming language that really IS natural language. So forget your fancy syntax and your misplaced semicolons and those one-liner functions that only Jim at the next cubicle over can read. Start working with Beryl, a template-based programming language for people who want their code to make sense.

    FAQs

    Where can I find documentation?

    It's almost complete! Inside the Beryl source code, every template is associated with the function to run and documentation for what that template does. That means that once every current feature is documented, it'll be a breeze to add new fully-documented features in the future. Expect detailed explanations, helpful code samples, and pointers on good practice. For now, if you have any questions about what certain templates do, you can email jaden.beryl@gmail.com or scroll through the source code to the templates object and find the docs property of each template.

    Is Beryl open-source?

    Well, not exactly. Anybody can see the source code, but not repackage it and claim it as their own. If you're interested in contributing, we'd love the help! We're looking to eventually make it completely open-source once it is fully established. For now, here's the license:

    Anyone may use Beryl unmodified or Beryl's source code unmodified in any personal, educational, or commercial project for free, without public attribution. Any piece of software using a modified version of Beryl or a modified version of Beryl's source code must somehow explicitly state that it is or uses a modified version of Beryl of a modified version of Beryl's source code.

    This license does not apply to or extend to external pieces of software built in the Beryl language, which are licensed separately and, unless otherwise explicitly stated, have no connection to Beryl or anyone involved in the creation of Beryl.

    Unless otherwise stated, this license only applies as long as it is packaged with the most recent version of Beryl. If future versions of Beryl are packaged with an altered version of this license or a new license altogether, that license would take precedence over this one unless explicitly contradicted by said new license.

    When can we expect a new Beryl version?

    Keep your eyes peeled. We've got several big new features in the works, and a full long-term plan. We'll be coming out with patches and new releases as regularly as possible.

    How Can I Help?

    If you're interested in Beryl and want to contribute, you can donate via PayPal or contact me via email at jaden.beryl@gmail.com to talk about contributing with code.

    Keywords

    none

    Install

    npm i beryl

    DownloadsWeekly Downloads

    3

    Version

    1.0.4

    License

    SEE LICENSE IN LICENSE.md

    Unpacked Size

    172 kB

    Total Files

    5

    Last publish

    Collaborators

    • jaden.beryl