Sage-Code Laboratory
index<--

Bee Features

Bee is a an experimental programming language design by Sage-Code. It is made for arithmetic, data algorithms, 2D graphics and geometric calculations. Bee has disruptive design aiming these goals:
#FeatureHow
1 readable use familiar keywords
2 efficient use native types
3 safe avoid invalid references
4 modular has reusable modules
5 explicit has type declarations
Disruptive: Bee is a little strange at first glance. That is becouse it has unusual keywords and symbols. We have made sactifices to maximize our goals. Bee code is readable but difficult to type in.

Readable

Bee is designed to be learn as your first computer language. We think that you can learn Bee by reading code. Next design choices will make Bee code easier to read therefore easyer to grasp and learn:

The result of these choices is demonstrate below. You can observe different comment notations enable different color. Syntax colorizer is able to identify also the keywords and highlite every statement.

Fibonacci-Rule

Bee program example


Efficient

Bee is aiming for efficiency not performance. There is a difference, performance can be obtained using intensive computer resources and distributed computing. Efficiency is achieved using better algorithms and data types. Bee is designed for multi-core CPU. It enable you to create efficient applications using following techniques and features:

Safe

Bee is designed to be a safe language. It is difficult to make a safe language that is also efficient. To fulfill these goals we setu-up a runway architecture based on next principles and believes:

  1. There are more than one ways to resolve a problem,
  2. If your problem is simple do not make it complicated,
  3. If your problem is large, split it into parts,
  4. Most of the time implicit behavior is good enough,
  5. When implicit do not work as expected, do it explicit,
  6. It is better to be proactive than reactive,
  7. If something can go wrong, eventually it will,
  8. Sometimes if you try a second time it will work,
  9. Aim for efficiency when performance is expensive,
  10. Aim for precision when perfection is impossible.

Modular

Bee applications are usually small, based on single source file. However Bee enable usage of multiple files for separation of concerns. There are 3 kind of modules in a large application:

    Bee Program

    Bee modular design


  1. One main module called "driver"
  2. Multiple application modules called "aspects"
  3. Multiple library modules called "modules"

Drivers and aspects are executable while modules are reusable. Aspects are executed from driver main rule. Once the aspect is resolved it is removed from memory, unlike modules that are persistent.

Explicit

Bee is an explicit language: We believe explicit is better than implicit. For this we try to give as much control to developers as possible. Next design choices make Bee an explicit language:

  1. Bee require declarations of data types for all elements: constants, variables, parameters and results. Unlike dynamic languages that use implicit data types that can be changed in the same scope.
  2. Most languages do not have a name for result variables in functions. Bee allow developers to declare explicit names and types for every result. This is helpful when a subroutine has multiple results.
  3. Precision is implicit and maximum possible in most other languages, forcing the computation of multiple decimals that are not necessary. In Bee you can define rational numbers that have fixed number of decimals therefore precision is explicit.
  4. Variables and parameters are automatically initialized with zero value when there is no explicit initialization. Also, if a parameter has explicit initial value it becomes optional.
  5. Bee has two assignment operators: ":" and ":=". First is called "pair up". Second is called "assign". Developers can control what assignment operator actually do by using kewords: "make" to declare a new variable and "alter" to modify an existing variable.
  6. In a rule, primitive type parameters are transferred by value while composite type parameters and objects are transferred by reference. Same rule apply for result variables.
  7. Bee do not have pointers nor pointer arithmetic. However you can define references to primitive types using explicit boxing operator [x] that are as good as pointers.

Disruptive

  1. Bee use Unicode operators. This is the main factor that makes Bee disruptive: { ÷ · × ¬ ∧ ∨ ∈ ≤ ≥ ≡ ≠ ≈ ± ⊂ ⊃ ∪ ∩ ↑ ↓ » « ⊕ ⊖ ∀ ∃}. This can be difficult to type without a programmable keyboard.
  2. Bee use one single letter for primitive types: {A B C D T F L W U N Q R S X Z} This come from mathematics. We have not used Unicode symbols: { ℂ ℍ ℕ ℙ ℚ ℝ ℤ }. We could have, but not all capital letters are available: {A B F L D S T X} there are all missing and the Bee language could look inconsistent.
  3. Single letter symbols make type annotation very compact. Sometimes a list of parameters could be long with various type annotations. Avoiding long expressions is one of Bee goals, so it is logical to use short type identifiers.
  4. Bee support some Greek and Cyrillic letters: {∀ ∃ Σ Π Δ Γ Λ Φ Ψ Ω Б Г Д Ж И Л Ф Ц Ч Ш Щ Э Я}. We could have support all but some look too much like the Latin letters. Also we enable some lowercase Greek letters: {λ φ π α β ɣ ε δ μ ω }
  5. Bee support superscript numbers: {⁺⁻⁰¹²³⁴⁵⁶⁷⁸⁹}. We recognize superscript as power: x² and xⁿ. You can also use any Latin superscript characters: (ᵃ..ᶻ). Caret symbol ^ is used to deal with fraction exponent: X^(¹/₂)
  6. Subscript numbers are recognized as numbers in fractions like: {¹/₂,⁻¹/₄,³/₄...}. You can also use composite identifiers starting with a letter: (x₁, x₂, α₁, β₂ ω₂) are some valid identifiers in Bee.
  7. Bee use Unicode symbols for geometric types. These symbols are intuitive and make geometric types shorter. For example: ∠ = Angle, ⊡ = Dot, ◷ = Arc. Many other shapes are recognized.
  8. Bee define the "if" statement differently than most other languages. The "if" keyword is used as a conditional for other statements or as ternary operator in lambda expressions.
  9. Bee is using "#" for module single line comments outside of any rule or block of code. This is same symbol used in Wiki *.md pages for titles and sub-titles. It does not support indentation.
  10. Bee is using "**" for single line comment inside rules and blocks. This is used in Wiki *.md files for bold. You can use "**" only at begginning of new line or after space indentation but not at the end of a line.
  11. Bee use "+- ... -+" for block comment. In combination with "|" you can create boxed comments where "+" is the corner of the box. This is useful to create a module header.
  12. Bee support C like comments: /* ... */ is for "expression comments" that can be used in parenthesis. Two slashes "//" represent end of line comment or statement comment. This can not be used in parenthesis or brackets and can not be used at beginning of new line. You must use ** for line comments.
  13. For string pattern replication you can use star: "*" operator. For example "01" * 4 = "01010101". In other languages the same operator is numeric times but in Bee we are using "·" for times like in mathematics.
  14. For concatenation between two strings We have chosen: "+" and "-". A number can be appended to a string like: "10" + 1 = "101" that may look strange but you get used to it. Alternative operators: {-, ., /, ?} can be used to combine two strings.
  15. Bee is an imperative language. That is the reason we use verb statements. For example "make" will create variables, "alter" modify variables, "apply" execute a rule and so on. It will make Bee more verbose but we use short keywords. Typing a word many times help you learn.
  16. Bee do not use any abbreviation for keywords. This enable spell checking tools, to avoid typos in source code. Also, not all developers know English. Bee offer this opportunity to learn some English while learning the language.
  17. Data type is declared after the identifier, as an optional hint. This makes type inference possible. In contrast, for example in Java, ussage of type keyword is mandatory before identifier. We think sometimes implicit types are good enaugh.
  18. Bee use keyword rule to define a subroutine and keyword apply to execute a subroutine. We have considered other keyword alternatives: {"routine", "functor", "relation", "rule"}, but the rule is more general for all these cases.
  19. Bee use prefix "*" to declare variable number of arguments. In C and JavaScript you must use 3 dots for this job "...". I think this was a poor choice. In Bee we use dots (more) to describe syntax patterns.
  20. Bee use sigils: "$" for system constants and "@" for system variables. These are globals. Protecting them with a sigil is useful to prevent overriding by mistake.
  21. Bee use starting and ending keywords to define blocks of code, not curly brackets. This eliminate the nested bracket nightmares and improve visual aspect of the code. We can use brackets for data literals: ordinals, sets, hash tables and objects.

Read next: Bee Syntax