/DreamBerd

perfect programming language

OtherNOASSERTION

DreamBerd

DreamBerd is a perfect programming language. These are its features!
When you've finished reading through all the features, check out the examples.

Exclamation Marks!

Be bold! End every statement with an exclamation mark!

print("Hello world")!

If you're feeling extra-bold, you can use even more!!!

print("Hello world")!!!

If you're unsure, that's ok. You can put a question mark at the end of a line instead. It prints debug info about that line to the console for you.

print("Hello world")?

You might be wondering what DreamBerd uses for the 'not' operator, which is an exclamation mark in most other languages. That's simple - the 'not' operator is a semi-colon instead.

if (;false) {
    print("Hello world")!
}

Declarations

There are four types of declaration. Constant constants can't be changed in any way.

const const name = "Luke"!

Constant variables can be edited, but not re-assigned.

const var name = "Luke"!
name.pop()!
name.pop()!

Variable constants can be re-assigned, but not edited.

var const name = "Luke"!
name = "Lu"!

Variable variables can be re-assigned and edited.

var var name = "Luke"!
name = "Lu"!
name.push("k")!
name.push("e")!

Arrays

Some languages start arrays at 0, which can be unintuitive for beginners. Some languages start arrays at 1, which isn't representative of how the code actually works. DreamBerd does the best of both worlds: Arrays start at -1.

const const scores = [3, 2, 5]!
print(scores[-1])! //3
print(scores[0])!  //2
print(scores[1])!  //5

New for 2022!
You can now use floats for indexes too!

const var scores = [3, 2, 5]!
scores[0.5] = 4
print(scores) //[3, 2, 4, 5]!

When

Mutating variables is very dangerous and must be avoided at all costs. But in case you really need to vary variables, the when keyword lets you check a variable each time it mutates.

const var health = 10!
when (health = 0) {
   print("You lose")!
}

Installation

To install DreamBerd to your command line, first install the DreamBerd installer.
To install the DreamBerd installer, install the DreamBerd installer installer.

New for 2022!
Due to the complicated installation process, you can now install the 'Create DreamBerd App' app that installs everything for you!

Booleans

Booleans can be true, false or maybe.

const var keys = {}!
after ("keydown") e => keys[e.key] = true!
after ("keyup") e => keys[e.key] = false!

function isKeyDown(key) => {
   if (keys[key] = undefined) return maybe!
   return keys[key]!
}

Technical info: Booleans are stored as one-and-a-half bits.

Perhaps

You can use the perhaps keyword for deciding what to do when a condition is maybe.

const const isTuesday = maybe!

if (isTuesday) {
   print("It's Tuesday")!
} else {
   print("It's not Tuesday")!
} perhaps {
   print("It's maybe Tuesday")!
}

Indents

When it comes to indentation, DreamBerd strikes a happy medium that can be enjoyed by everyone: All indents must be 3 spaces long.

function main() => {
   print("DreamBerd is the future")!
}

-3 spaces is also allowed.

   function main() => {
print("DreamBerd is the future")!
   }

Equality

JavaScript lets you do different levels of comparison. == for loose comparison, and === for a more precise check. DreamBerd takes this to another level.

You can use == to do a loose check.

3.14 == "3.14"! //true

You can use === to do a more precise check.

3.14 === "3.14"! //false

You can use ==== to be EVEN MORE precise!

const const pi = 3.14!
print(pi ==== pi)! //true
print(3.14 ==== 3.14)! //true
print(3.14 ==== pi)! //false

If you want to be much less precise, you can use =.

3 = 3.14! //true

Function

To declare a function, you can use any letters from the word function (as long as they're in order):

function add (a, b) => a + b!
func multiply (a, b) => a * b!
fun subtract (a, b) => a - b!
fn divide (a, b) => a / b!
functi power (a, b) => a ** b!

Types

Type annotations are optional.

const var age: Int = 28!

By the way, strings are just arrays of characters.

String == Char[]!

Similarly, integers are just arrays of digits.

Int == Digit[]!

If you want to use a binary representation for integers, Int9 and Int99 types are also available.

const var age: Int9 = 28!

Technical info: Type annotations don't do anything, but they help some people to feel more comfortable.

Previous

The previous keyword lets you see into the past!
Use it to get the previous value of a variable.

const var score = 5!
score++!
print(score)! //6
print(previous score)! //5

Similarly, the next keyword lets you see into the future!

const var score = 5!
after ("click") score++!
print(await next score)! //6 (when you click)

File Structure

Write five or more equals signs to start a new file. This removes the need for multiple files or any build process.

const const score = 5!
print(score)! //5

=====================

const const score = 3!
print(score)! //3

You can give files names.

======= add.db =======
function add(a, b) => {
   return a + b!
}

Export

Many languages allow you to import things from specific files. In DreamBerd, importing is simpler. Instead, you export to specific files!

===== add.db ==
function add(a, b) => {
   return a + b!
}

export add to "main.db"!

===== main.db ==
import add!
add(3, 2)!

By the way, to see DreamBerd in action, check out this page.

Class

You can make classes, but you can only ever make one instance of them. This shouldn't affect how most object-oriented programmers work.

class Player {
   const var health = 10!
}

const var player1 = new Player()!
const var player2 = new Player()! //Error: Can't have more than one 'Player' instance!

This is how you could do this:

class PlayerMaker {
   function makePlayer() => {
      class Player {
         const var health = 10!
      }
      const const player = new Player()!
      return player!
   }
}

const const playerMaker = new PlayerMaker()!
const var player1 = playerMaker.makePlayer()!
const var player2 = playerMaker.makePlayer()!

Now

Use Date.now() to get the current date and time.

Date.now()

By the way, you can set the time.

// Move the clocks back one hour
Date.now() -= 3600000

Important!
Please remember to do this when the clocks change.

Time Travel

You can use this to your advantage!
Let's say you're keeping track of whether the space bar is down or up...

let down = maybe!
after ("keydown") e => {
   if (e.key = " ") down = true!
}

after ("keyup") e => {
   if (e.key = " ") down = false!
}

You can check the state of the space bar in the past..

Date.now() -= 5000
if (down) {
   print("5 seconds ago, the space bar was down")!
}

Or the future!

Date.now() += 3000
if (down) {
   print("3 seconds from now, the space bar will be down")!
}

Examples

For examples of DreamBerd in action, check out the examples page!