Introduction


GitHub contributors GitHub Visual Studio Marketplace Last Updated Visual Studio Marketplace Downloads Crates.io


redditLang or PHL ( Programming Humor Language ) is a meme language devised by the r/ProgrammerHumor subreddit discord members

Why Redditlang?

  • ๐Ÿ”ฅ blazingly fast
  • ๐ŸŽฎ cross platform
  • very opinionated, only forcing the best of practices. For example, if you use inline macros, the police will be called with the message that a fire has broken out at your home, they will promptly come to put out you garbage code.
  • sometimes typed
  • If you still aren't devoting your entire carrer to this, it's like C ( minus the pointers ), Rust ( minus the copyright ) and JavaScript ( only the "good" featuress ) all in one neat package.

So what are you waiting for? Please invest your life savings in this! Check out the Official VSCode extension here

Compiler is WIP, if you are looking for it, it will be here. RedditLang will be compiled, a JIT implementation might exist in the future.

note: We have realized that we have a younger audience, so we have translated the spec into Gen Z Slang "to make it bussin". It is available here, We will not convert this into an mdBook and this might might be outdated.

Requirements

Usage

  • LLVM 15.x
  • GCC or Clang

Development

  • Rust
  • LLVM 15.x
  • GCC or Clang

Note

You might get an incorrect LLVM version when you install it with your systems package manager. Please head to LLVM's official website to find downloads for your OS.

Contributing

redditLang is FOSS. You can find the source code on Github. redditLang relies on the community to add bug fixes and features: if you'd like to contribute, please open a PR and message in the #"RedditLang ( PHL )" thread on the r/ProgrammerHumor discord server.

License

The redditLang source, documentation, and STL are all released under the MIT license.

Document Conventions

These are common syntaxes used in this document that refer to parts of the parser.

A name within chevrons (< >) refers to one of these:

  • IDENT

    Alphabetic character or underscore followed by alphanumeric characters or underscores. Short for 'identifier'.

    Example

    text   # This is valid   โœ…
    te_xt  # This is valid   โœ…
    _text  # This is valid   โœ…
    
    42     # This is invalid โŒ
    42text # This is invalid โŒ
    te xt  # This is invalid โŒ
    
  • DECLARATION

    <IDENT> damn <TYPE>

    More info about types is available here.

    Example

    identifier damn Number(x damn Number,)
    
  • A header with the same name, but different casing

A name within chevrons (< >), and suffixed by horizontal ellipses (...) refers to the below:

  • <IDENT...> An arbitrary ( at least one ) number of IDENT is allowed, based on requirements.

A token suffixed by a question mark (?) refers to the below:

  • <IDENT>? An IDENT is optional.

  • <IDENT...>? An arbitrary number of IDENT is allowed, including 0.

  • (<IDENT...>)? Parantheses and everything within are optional.

A <TERM> is an identifier, number, string or expression.

Blocks

  • Blocks are created by curly braces.

  • Standard form

    { # This is a block
      # Statements can appear within a block
    } # This terminates the block
    

Statements

  • Statements must all be on separate lines.

  • Semicolons shall not be used.

  • Statements shall only appear at the top level of the file, and inside blocks.

  • Top-level statements have priority in processing.

    Example

    # This is the top level of a file.
    statement # This is a statement.
    next_statement # This is another statement.
    statement_three statement_four # This is invalid.
    statement_five; statement_six # This is also invalid.
    {
      statement_seven # This is a statement in a block.
    }
    

Identifier Policy

  • All <IDENT>'s will have a max length of 25 characters.
  • If violated, an AntiJavaException bullet will be shot.

Variables

The variable creation keyword is meth.

They can ony be defined at the top level of modules, or in blocks.

An initializer is required.

Standard form:

meth <DECLERATION> โˆ‘ <EXPR>

Variables are scope-local and shadow previous variables with the same name.

Typing

Typing a variable or a function type is not optional.

Arrays

To type array's, you use the generic T >> Array type

  • Standard form:

    <TYPE> >> Array
    

Flat types

  • Standard form:

    <TYPE>
    

Generics

  • Standard form:

    (<TYPE,...>) >> <TYPE>
    

Types

Loops

  • Loops are infinite, they do not self-terminate ( terminate without a break ).

  • The loop are simmilar to Rust's syntax.

  • The loop keyword is repeatdatshid.

  • The break keyword is sthu.

  • Standard form:

    repeatdatshid { # Opens a loop
      # ...
      sthu # Breaks the loop
      # ...
    }
    

Conditional Branching

The if keyword is is.

Standard form:

is <EXPR> {
  # Code
}

The else keyword is isn't.

Standard form:

is <EXPR> {
  # Code
} isn't {
  # Code
}

The else-if keyword is but.

Standard form:

is <EXPR> {
  # Code
} but <EXPR> {
  # Code
} isn't {
  # Code
}

Expressions

Expression types

  • Conditional
  • Binary
  • Indexing

Conditional

  • Returns a boolean.

  • Standard form:

    <TERM> <CONDITIONAL_OPERATOR> <TERM>
    

Binary

  • Standard form:

    <TERM> <MATHEMATICAL_OPERATOR> <TERM>
    

Indexing

  • Returns type at index of array.

  • Standard form:

    <TERM>[<INDEX>]
    

Index

  • An Expr -> UNumber | String | Ident

Functions

Function Declaration

  • The declare keyword is callmeonmycellphone.

  • Functions have an identifier, and a return type.

  • They can optionally include a modifier and an arbitrary number of arguments.

  • All arguments, last one or not, will end with a comma.

  • Standard form:

    <FUNCTION_MOD...> callmeonmycellphone <DECLARATION>(<DECLARATION,...>) {
      # Block
    }
    
  • Modifiers

    • Debug modifier: Will print every variable when it is changed to the console. Only works in debug builds when the jesse debugger is ran with walter.
    • bar modifier: Makes function public to its scope. Only works in classes and top-level of non-main modules.
    • Modifiers are separated by spaces.
  • Arguments

    • Arguments are separated by commas.

Function Calls

  • All arguments, last one or not, will end with a comma.

  • The call keyword is call.

  • Standard form:

    call <IDENT>(<EXPR,...>?)
    

Function returns

  • The return keyword is spez.

  • Standard form:

    spez <EXPR>
    
  • The returned expression's type must match the return type, if specified.

Errors

  • An error is called a bullet.

  • The throw keyword is shoot.

  • Only expressions can be shot.

  • Standard shoot form:

    shoot <EXPR>
    
  • The try keyword is test.

  • The catch keybord is wall.

  • A test-wall is composed of one test and one wall.

  • Wall statements can optionally have one expression. Without a expression, wall will catch all expressions shot.

  • Standard test-wall form:

    test {
      # Code that possibly shoots a bullet
    } wall <IDENT>? {
      # Handle exception
    }
    

Comments

Single line comments are prefixed by #.

Multi-line comments are prefixed by #* and suffixed by *#.

Standard form

# Single line

#* Multi
   Line
*#

Types

Boolean

VarientMeaning
YupTrue
NopeFalse

Foolean

  • Contains all varients of a Boolean
  • Has these additional varients
VarientMeaning
DunnoNull
HuhI/O Failure
YeetRandom Foolean

String

  • An array of characters, denoted with two double quotes ( " )
  • You can use escape sequences inside of strings

Number

  • Decimal support
  • Positive by default
  • Doesn't require a <SIGN>
  • Standard form:
<SIGN?><UNSIGNED_INTEGER>

Sign

  • Add or Subtract operator symbol

Null

  • The null keyword is wat.

Arrays

  • Arrays are declared with brackets and have comma seperated expressions inside.

  • Standard form:

[<EXPR,...>]
  • Array indexes start with 1.

Operators

Conditional

  • The equality operator is โ…€
  • The inequality operator is โ‰ 
  • The greater than operator is >
  • The greater than or equal to operator isโ‹
  • The less than operator is <
  • The less than or equal to operator is โ‹œ

Math

  • The addition binary operator is โจ‹
  • The subtraction binary operator is โ€“ Note: This is not U+2012 ( dash ), this is U+2013 ( en dash )
  • The multiplication binary operator is โ‹‡
  • The XOR binary operator is โŠ•
  • The division binary operator is โŽฒ
  • The modulus binary operator is โจŠ

Unary

  • The positive unary operator is โจ‹
  • The negative unary operator is โ€“
  • The negation unary operator is ยก

Other

  • The assignment operator is โˆ‘

Classes

Not implemented in the compiler yet

The class definition keyword is school.

Standard form:

school <IDENT> {
  # Parts of the class
}

The constructor member function name is cooK.
The destructor member function name is snoRt.

Constructors and destructors have the bar function modifier by default.

Standard form

school myClass {
  callmeonmycellphone cooK() {
    # Constructor
  }

  callmeonmycellphone snoRt() {
    # Destructor
  }
}

Feilds

  • Fields are placed at the top of the class.
  • They are private by default.

Modules

Importing modules

  • The import directive is weneed, or bringme.

  • weneed and bringme are equivalent.

  • The module path is a dot seperated list of <IDENT>.

  • Standard form:

    weneed "<MODULE_PATH>"
    

    or,

    bringme "<MODULE_PATH>"
    

Creating modules

  • Modules are created from the filesystem
  • For example
main.rl
a.rl
b/
  b.rl
  c.rl
  • The module paths for this are r/main r/a r/b.b r/b.c

Build system

The build system is walter.
The standard debugger is jesse.

Walter

How to create a new project

  1. Navigate to your project folder in your command line.
  2. Run walter rise <PACKAGE_NAME> to initialize a new project, if you don't specify a name it is created in the current directory with the current directories name if it is empty.

Default project structure

  • src/main.rl
  • .gitignore
  • walter.yml

All source files are placed in src/.

src/main.rl is the main build target.

walter.yml should contain a name and version key, which are both strings.

name: <NAME>
version: <SEMVER_VERSION_NUMBER>

CLI Documentation

Run walter help <COMMAND?> to see info about a specific command, or to see info about the entire program. You can add --help or -h to get help aswell.

There used to be a documentation here, but it was not up to date and became a hassle to update. Please refer to the cli instead.

Jesse

INCOMPLETE

Standard library

The standard library is globally available by default. It is available at https://github.com/elijah629/redditlang-std

I/O

  • coitusinterruptus

    • Standard print function.

    • Function signature:

      call coitusinterruptus(text damn String)
      
  • pulloutnt

    • Standard readline.

    • Reads a line from stdio and returns it without a newline at the end.

    • Function signature:

      call String pulloutnt()
      

System

  • exit

    • Standard exit function

    • Function signature:

      call exit(code damn Number)
      
    • Decimal codes are truncated

Time

  • zzz

    • Standard sleep function.

    • Stops the current thread for timeMs seconds.

    • Function signature:

      call zzz(timeMs damn Number)