Shitlang

From Esolang
Jump to navigation Jump to search
Not to be confused with ShitLang.

Shitlang

Shitlang is a language created by Simyon the 19th Jan 2024 and the 24th Jan 2024. It is currently on version 2.3.x but continues to be developed. A syntax highlighter for VSC has been developed by Fiiral during that same time and is highly recommended for programming in Shitlang.

Features

The language is dynamically typed and does not support object-oriented nor functional programming. However, it does allow for the creation of functions and modules. In the language, everything is treated as an object without methods, requiring the use of functions instead. It also does not use a garbage collector except for functions as they create their own scope which is collapsed after the function finishes executing, requiring the programmer to remove all unused variables themselves.

Variables

An example code defining several variables.

There are multiple types of variables in Shitlang:

  • Numbers, following the IEEE754 standard as 64-bit floating point numbers.
  • Strings, contain text encoded in UTF-16.
  • Booleans, either True or False.
  • Void, the singleton type of Null.
  • Array, an array that can contain multiple elements of various types.
  • Dictionary, identical to arrays but use keyword-item pairs.

Additionally, there are several types of "objects" that cannot be assigned to variables:

  • Functions
  • Modules


All variables are declared and addressed using a : in front of their name. Additionally, they can be modified by assignment using the * modifier, making them a global variable, or the ! modifier, making them a constant.

Keywords

An example code showing various keywords.
Caption text
Keyword Function
if Used to create if-statment, where everything inside the conditional block will only be executed if the required condition is met.
else Optional addition to the if keyword. It will be executed when the condition is not met.
goto Used to go to a specific label (see below). It replaced while and for loops and keywords.
define Used to a function. All functions are their own scope and cannot modify non-global variables outside that scope.
export Identical to define but used to export a function for module use. A exported function cannot be used in its own file.
return Identical to using :return metavariable with a goto label at the end of a function.
quit Instantly exits the programm with status code 0.

Operations

Most operation symbols only use the Number type, everything else uses the buildin operations. However, inline math is not supported by Shitlang.

  • Addition ("+")
  • Subtraction ("-")
  • Multiplication ("*")
  • Division ("/")
  • Exponentiation ("^")
  • Comparisons
    • greater than (">")
    • greater than or equal to (">=")
    • equal to ("=")
    • less than or equal to ("=<")
    • less than ("<")

Functions

Build-In

  • arrayCreate()
  • arrayGet()
  • arrayPush()
  • arrayRemove()
  • dictAdd()
  • dictCreate()
  • dictGet()
  • dictRemove()
  • dictSet()
  • free()
  • import()
  • typeof()
  • in()
  • out()
  • raise()
  • sleep()

Math Module

  • floor()
  • ceiling()
  • trunc()
  • sin()
  • cos()
  • tan()
  • asin()
  • acos()
  • atan()
  • abs()
  • factorial()
  • log()
  • isInfinity()
  • isNaN()
  • e()
  • pi()
  • tau()
  • phi()

Random Module

  • randomNumber()
  • randomDecimal()
  • randomString()
  • normalDistribution()
  • betaDistribution()
  • gammaDistribution()
  • choice()
  • choices()

String Module

  • concat()
  • contains()
  • format()