We are currently working on new rules for what content should and shouldn't be allowed on this website, and are looking for feedback! See Esolang:2026 topicality proposal to view and give feedback on the current draft.
B+
B+ is a C and GLSL-based esolang made by User:Cordership.
Syntax
Basics
Declaring variables
make var_type var_name;
A variable can be an integer, a float, a double, or a string.
Assigning values
varf(format_specifier, var_name, var_value)
It can be a string (%s), an integer (%d), or a float (%f).
STDIO
Output by the printf() function:
#include <stdio>
main() {
printf("Whatever you want");
exit 0;
}
Assign input to a variable using getinp (reads the full input):
#include <stdio>
main() {
make str a;
getinp("%s", a);
}
#include <stdio>
main() {
make str a;
getinp("%s", a);
printf(a);
exit 0;
}
Operators
The order of operators is the same as C.
| Precedence | Operator | Description | Associativity |
|---|---|---|---|
| 1 | ++ --
|
Postfix increment and decrement | Left-to-right |
()
|
Function call | ||
[]
|
Array subscripting | ||
.
|
Structure and union member access | ||
->
|
Structure and union member access through pointer | ||
(type){list}
|
Compound literal | ||
| 2 | ++ --
|
Prefix increment and decrement | Right-to-left |
+ -
|
Unary plus and minus | ||
! ~
|
Logical NOT and bitwise NOT | ||
(type)
|
Cast | ||
*
|
Indirection (dereference) | ||
&
|
Address-of | ||
count
|
Size-of in elements | ||
sizeof
|
Size-of | ||
_Alignof
|
Alignment requirement | ||
| 3 | * / %
|
Multiplication, division, and remainder | Left-to-right |
| 4 | + -
|
Addition and subtraction (Addition is concatenation if both sides are strings) | |
| 5 | << >>
|
Bitwise left shift and right shift | |
| 6 | < <=
|
For relational operators < and ≤ respectively | |
> >=
|
For relational operators > and ≥ respectively | ||
| 7 | == !=
|
For relational = and ≠ respectively | |
| 8 | &
|
Bitwise AND | |
| 9 | ^
|
Bitwise XOR (exclusive or) | |
| 10 | |
|
Bitwise OR (inclusive or) | |
| 11 | &&
|
Logical AND | |
| 12 | ||
|
Logical OR | |
| 13 | ?:
|
Ternary conditional | Right-to-left |
| 14 | =
|
Simple assignment | |
+= -=
|
Assignment by sum and difference | ||
*= /= %=
|
Assignment by product, quotient, and remainder | ||
<<= >>=
|
Assignment by bitwise left shift and right shift | ||
&= ^= |=
|
Assignment by bitwise AND, XOR, and OR | ||
| 15 | ,
|
Comma | Left-to-right |
If-else
1-branch:
#include <stdio>
main() {
if (condition) {
//code;
}
2-branch:
#include <stdio>
main() {
if (condition) {
//code;
} else {
//code;
}
Multiple if-then-elses:
#include <stdio>
main() {
if (cond1) {
//code;
// } else if (cond2) {...
Ternary operator:
#include <stdio>
main() {
make int a, make int b;
getinp("%d", "%d", a, b);
make int max;
varf("%d", max, (a < b) ? b : a);
printf("The largest number is %d", max);
exit 0;
Loops
For loop:
for (cond1; cond2; cond3;…) {
//code
}
While loop:
while (cond) {
//code
Arrays
In B+, arrays are the same as C. They must be the same data type. To assign the value of an array, the same format specifier for its elements are used. For example,
make array n;
varf("%d", n, {0, 1, 2, 5})
There are matrices too.
make matrix n;
varf("%d", n, {{0, 1, 2}, {1, 2, 3}}
The sizeof function returns the size of an array using bytes, while the count function returns the number of elements in an array.
Functions
In B+, functions are defined almost the same way as C.
#include <stdio>
float f(float n) {
exit 0;
}