LDPL

From Esolang
Jump to navigation Jump to search
LDPL
Paradigm(s) Imperative, Procedural
Designed by Martín del Río
Appeared in 2019
Type system static, strong
Memory system variable-based
Dimensions one-dimensional
Computational class Turing complete
Reference implementation LDPL
Influenced by COBOL
File extension(s) .ldpl, .lsc

LDPL (an acronym for "Lartu's Definitive Programming Language") is a compiled English-like computer programming language designed from the ground up to be excessively expressive, fast, readable and easy to learn. It is imperative and procedural. It mimics English in the likeness of older languages like COBOL. It's highly portable and runs on a plethora of different architectures and operating systems including AMD-64, ARMv8 and PowerPC Linux and Mac OS X. It even supports UTF-8 out of the box.

History

LDPL Logo

The LDPL project was initially started by Martín del Río in 2018 with a group of colleagues, but after a few days of design by committee, and due to lack of interest, the project was abandoned. Martín decided he wanted to write a programming language and so picked up the project and created a syntax loosely based on that of COBOL. The original iteration of LDPL, Mauifish was released in the end of that year.

In 2019 Martín realized the language was lacking any sort of documentation and thus, in an effort to both document the language and standardize it, he wrote the LDPL 19 Standard, giving birth to LDPL as it is today.

LDPL was originally is a relatively slow interpreted language with no scoping, objects or functions and with data structures limited to just numbers, strings and lists of these types called VECTORs. In an effort to make the language more usable, however, the compiler was modified to transpilation LDPL code to C++. It thus became a compiled language.

Examples

Hello, World!

This program prints out the words Hello World!:

PROCEDURE:<br>
    DISPLAY "Hello World!" CRLF

The upper case characters are optional, the language is not case sensitive.

Disan Count

This program prints out all the even numbers from 20 to 0:

DATA:
    it IS NUMBER
    mod IS NUMBER

PROCEDURE:<br>
    STORE 20 IN it
    WHILE it IS GREATER THAN 0 DO
        MODULO it BY 2 IN mod
        IF mod IS EQUAL TO 0 THEN
            DISPLAY it " is even!" CRLF
        END IF
        SUBTRACT 1 FROM it IN it
    REPEAT

String Splitting

This program takes a string and a delimiter and splits the string using the given delimiter:

DATA:
explode/words is text vector
explode/index is number
explode/string is text
explode/length is number
explode/stringlength is number
explode/current-token is text
explode/char is text
explode/separator is text
i is number
    
PROCEDURE:
# Ask for a sentence
display "Enter a sentence: "
accept explode/string

# Declare explode Subprocedure
# Splits a text into a text vector by a certain delimiter
# Input parameters:
# - explode/string: the string to explode (destroyed)
# - explode/separator: the character used to separate the string (preserved)
# Output parameters:
# - explode/words: vector of splitted words
# - explode/length: length of explode/words
sub-procedure explode
    join explode/string and explode/separator in explode/string
    store length of explode/string in explode/stringlength
    store 0 in explode/index
    store 0 in explode/length
    store "" in explode/current-token
    while explode/index is less than explode/stringlength do
        get character at explode/index from explode/string in explode/char
        if explode/char is equal to explode/separator then
            store explode/current-token in explode/words:explode/length
            add explode/length and 1 in explode/length
            store "" in explode/current-token
        else
            join explode/current-token and explode/char in explode/current-token
        end if
        add explode/index and 1 in explode/index
    repeat
    subtract 1 from explode/length in explode/length
end sub-procedure

# Separate the entered string
store " " in explode/separator
call sub-procedure explode
while i is less than or equal to explode/length do
    display explode/words:i crlf
    add 1 and i in i
repeat

External resources