The SunSed Language is the core of the SunSed platform. It is a rolling-release, all-batteries-included, and purely procedural programming language. It is most similar to PHP and JavaScript, but with an easier to master syntax that natively supports both HTML and Markdown.
Fundamentals
Hello World
Create your first ever .page file and print "Hello World" to the page. Basic structure of a SunSed program
Print
Print a value to the page. e.g. print "Hello World"Comments
Single-line and multi-line comments. e.g. // and /* */Data Types
Integer, float, string, boolean, array, object, and more. Atoms of a program
Variables
A container for a value. e.g. $name = "John"Type Conversion
Convert a value from one type to another. e.g. (int) "5"Strings
A sequence of characters. Single and double quotes. Concatenation and interpolation
Arrays
A collection of values. Indexed, associative, and multidimensional arrays
HTML
SunSed is a HTML-first language. It natively supports HTML and allows to extend tags
Markdown
Shortuct for wrting HTML: `#` for headings, `*` for emphasis, and backticks for code.
Sundown
Another shortcut for writing HTML in SunSed. e.g. `.h1 Header 1`
Operators
Comparison Operators
Equal, not equal, greater than, less than, and more. Returns a boolean
Math Operators
Addition, subtraction, multiplication, division, and more
Increment and Decrement Operators
Shortcut to increase or decrease a variable by one. e.g. $x++Compound Assignment Operators
Assignment and other operations in one. e.g. $x += 5Ternary Operator
Shortcut for if-else. e.g. $age >= 18 ? "Vote" : "No vote"Null Coalesce Operator
Easiest way to set default values. e.g. $username ?? "Guest"
Control Structures & Loops
if
Execute code if a condition is true
if ($age >= 18) { print "Vote" }else
Execute code if previous conditions are false
... } else { print "No vote" }elseif
Execute code if a condition is true and previous conditions are false
... } elseif ($age >= 16) { print "Drive" }while
Execute code while a condition is true
while ($i < 10) { print $i; $i++ }foreach
Execute code for each item in an array. e.g. foreach ($names as $name) { print $name }for
Execute code for a number of times
for ($i = 0; $i < 10; $i++) { print $i }
Functions
Definition
Define a function.
Parameters
Define parameters for a function.
Magical Functions
Let English be your programming language. `remove last word`('hello world') => 'hello'Return Value
Return a value from a function.
Testing & Documentation
Test and document a function.
Caching
Cache a function for better performance and lower resource usage.
Access
Specify who can access a function. Allows you to make API endpoints.
Schedule
Schedule functions to run recurrently at specified intervals.