Programming language made for sigma males.
To get started simply add SigmaScript loader to your web page:
<script src="https://gulgdev.github.io/SigmaScript/sigmascript.js"></script>
Then, create a SigmaScript file (or write it directly in script tag like JavaScript code):
<script type="text/sigmascript" src="index.ss"></script>
print "Hello world!";
You can change variable values using assignment operator:
x = 1;
You can define functions using fn
statement:
fn example() {
ret "something";
}
You can write if/else and while statements like this:
a = 1;
b = 1;
if a = b {
print "a = b";
} else {
print "a ≠ b";
}
x = 0;
while x < 10 {
x = x + 1;
print x;
}
You can write comments using //
:
x = 1; // Very important value
There's no types in SigmaScript. If the operation is invalid you get unknown
.
In SigmaScript, variables and functions are two different things. For example, you could create a variable and a function with the same name and use them without any problems:
fn x() {
print "I'm working!";
}
x = 10;
x();
print x;
Thus, you can't use callbacks as functions can't be passed as arguments to other functions. But you can use lambda functions.
Lambda functions are function expressions that can be stored in variables and passed as arguments:
use fn;
fn function() {
print "Function is called!";
}
lambda = () => {
print "Lambda is called!";
};
function();
call(lambda);
print "function = " @ function;
print "lambda = " @ lambda;
There's 8 default libs in SigmaScript: js
, dom
, fn
, ref
, string
, struct
, array
, math
. To use a lib in your program simply add use
header:
use js;
// ...
You can also create custom libs using the lib
directive:
lib example;
// ...
Lib files aren't executed unless they are used in non-lib scripts.
JS lib allows you to access JavaScript functions and objects from SigmaScript. Use js
function to evaluate JavaScript code from string. Use js_get
and js_set
to get/set properties of objects. Use js_new
and js_call
to call JavaScript object as a constructor/function. Use js_object
to create an empty JS object and js_array
to create an empty array. Use js_call_method
to call a method of given object. There's js_window
variable to access the window
object. To make crossplatform libs you can use js_global
instead of js_window
. To check the current environment you can use js_env
variable.
DOM lib allows you to manipulate the DOM. Use dom_title
to change the title of the page. Use dom_create
to create a new element. Use dom_find
to query an element by selector. Use dom_append
to append a child to an element. Use dom_remove
to remove an element. Use dom_add_class
, dom_remove_class
, dom_toggle_class
to change element classes. Use dom_set_text
or dom_set_html
to change the contents of an element. Use dom_get_attr
and dom_set_attr
to change attributes of an element. Use dom_css
to change CSS properties of an element. There are dom_body
and dom_head
to quickly access document body and head.
Fn lib allows you to call lambda functions using call
.
Ref lib allows you to create references to objects. Use ref
to create a reference. Use ref_get
and ref_set
to get/set the current value of reference.
String lib allows you to manipulate strings. Use string_at
to access characters of a string. Use string_length
to get length of a string. Use string_slice
to get substring of a string. Use string_replace
to replace substring in a string.
Struct lib allows you to create and modify structures. Use struct
to create a new struct. Use struct_get
and struct_set
to get/set fields of a structure.
Array lib allows you to create and modify arrays. Use array
to create a new array. Use array_add
and array_remove
to add/remove elements of array. Use array_at
to access elements of array. Use array_set
to modify elements of array. Use array_length
to get length of array. Use array_find
to find index of specific element in array.
Math lib allows you to use math functions. It supports abs
, sign
, sqrt
, mod
, sin
, cos
, tan
, asin
, acos
, atan
, sinh
, cosh
, tanh
, asinh
, acosh
, atanh
, exp
, round
, floor
, ceil
, random
, randint
.
You can create your own JS libs and then use them in SS. See this article to learn how to do it.
Did you hear about JSX? Of course you did! Well, I'm glad to introduce you SigmaScriptX! It is way more convenient than just using boring DOM. To use SSX add the SigmaScriptX loader to your page (SSX loader includes SS loader so you don't have to add two different loader scripts):
<script src="https://gulgdev.github.io/SigmaScript/sigmascriptx.js"></script>
And now use it in your project:
use dom;
dom_append(dom_body, <h1>Hello world!</h1>);
See this article to learn more about SSX.
See this article to be a good sigma-scripter!
You can also run scripts in NodeJS environment by installing SigmaScript globally:
npm i -g sigmascript
And then:
npx sigmascript lib1.ss lib2.ss main.ss
See this article for more info.
Browse the source code if you want to know more about how this project works.
This project is mostly a joke but if there's any bugs please feel free to report them on GitHub. Libs can be buggy because I didn't want to debug them properly and make them safe. You clearly shouldn't use this in production.