Dorklang

From Esolang
Jump to navigation Jump to search
dorklang
Paradigm(s) Imperative
Designed by User:Golang
Appeared in 2023
Memory system Stack-based
Computational class Turing complete
Major implementations Dorklang interpreter
File extension(s) .dork
This is still a work in progress. It may be changed in the future.

Dorklang is an esoteric programming language created by James Smith.

Each dorklang program has access to a 64-bit unsigned integer known as the current value, which is automatically set to 0 when the program begins. There are also two stacks available for storage, but only one of these is set as the current stack at any one time.

For full documentation, please see the Github repository for the language's main interpreter, which is written in Go.

Examples

Printing the Alphabet

{ SET CURRENT VALUE TO TWENTY-SIX, THE NUMBER OF LETTERS IN THE ALPHABET }
''/+[']+

{ BEGIN LOOP, SAVING DECREMENTED COUNTER VALUE }
<-:

	{ SET CURRENT VALUE TO NINETY, THE UNICODE/ASCII VALUE OF 'Z' }
	''+(''/)[']+

	{ LOAD COUNTER VALUE, SAVE IT AGAIN, SO IT CAN BE REUSED, THEN SUBTRACT IT FROM NINETY }
	[;:]

	{ PRINT THE UNICODE/ASCII CHARACTER AT THE CURRENT VALUE }
	!

{ RESTORE SAVED COUNTER VALUE AND JUMP BACK TO THE START OF LOOP IF IT IS GREATER THAN ZERO }
;>

The example above prints all of the letters of the English-language alphabet to the console (in sequential order from A to Z).

The comments between the braces explain how the code works.

Hello, World

''(')!
[+*+$:]!
(+ +^*)-! !
(+*+):!
~++^$$:[++*][++/]!
;:/!
;:++[++/]!
$;!
+(+)+!
--+!
''/+!

The example above prints a friendly greeting to the console.

Summing All Integers Between 1 and 1,000,000

''(''/)('/)^^ii:%++!!

The example above calculates the sum of every integer between one and a million inclusive, then prints the result to the console.

The program begins by setting the current value to 100, using a sequence of commands.

The ^^ command is then used to cube it, making it equal a million.

The ii command fills the currrent stack with a range of integers from 1 up to the current value exclusive.

The : command pushes the current value to the current stack, so that the range becomes inclusive.

The important work is done by the %++ command, which sums all of the values in the current stack and assigns the result to the current value, which is finally printed to the console by the !! command.