LANGUAGE BASICS

Every project has a #config.bst file that defines the entry points and dependencies of the project.

If instead, you build or run a specific Beanstalk file, it will create a single module from that entry point and pull in all the file's dependencies.


    # page_title = "Welcome"

    say_hello || -> String:
        return "Hi, welcome to Beanstalk"
    ;

    [say_hello()]
    

Quick Syntax Summary

For developers coming from most other languages, here are some key idiosyncrasies from other C-like languages to note:

Formatting

Comments

Comments use a double minus sign. --

Documentation comments will eventually be created via special templates.


    -- normal comment
    

Data Types

Beanstalk data type keywords use UpperCamelCase. Mutibility can change the underlaying data type but is not actually part of the type.

Type Description
Float 64-bit floating point number
Int 64-bit signed integer
String UTF-8 string slice or string template

Numerical Types

These will be extended to smaller sized and unsigned variants in the future. By default, "Float" and "Int" will become 64 bit signed types.

The language currently supports a small set of core types but may be extended in the future.

Strings and String slices

String is the keyword for string types in Beanstalk. Double quotes are automatically string slices.

"Double quotes for a UTF-8 string slice"`

Backticks are used for RAW strings. To escape a backtick it must be preceded with a backslash \.

Scenes are used instead of format strings.

Operators

Logical and Comparison Operators

The 'is' keyword is used to check equality. The "and / or" keywords are used for logical and / or and 'not' is used to invert a truthy value to falsy or vice versa.

Mathematical Operators

Operator Description Precedence
^ Exponent 4
* Multiplication 3
/ Division 3
// Integer Division 3
% Modulo (Euclidean) 3
+ Sum 2
- Subtraction 2