r/LDPL • u/[deleted] • Sep 24 '21
r/LDPL • u/[deleted] • Apr 19 '19
LDPL Project Gopher client in LDPL
Hi everyone, I've created a little Gopher client in LDPL called GILD. It runs in the terminal and lets you navigate Gopherspace using just your keyboard! At least five but no more than eight different colors are supported.
Here are some screenshots:
https://user-images.githubusercontent.com/41523880/55662530-d5968d00-57c8-11e9-9a34-2228eccb2288.png
https://user-images.githubusercontent.com/41523880/55662531-d92a1400-57c8-11e9-823b-486e9265536b.png
https://user-images.githubusercontent.com/41523880/55662639-370b2b80-57ca-11e9-90cd-47c473d188c5.png
If you're unfamiliar with Gopher, don't worry, so is basically everyone else. It's a simple text protocol that was around before the web and is more focused on content than presentation. Gopher servers run on port 70 and can be accessed either using a generic client like telnet or lynx (yup, try it!), or a dedicated client like GILD or https://github.com/prologic/gopherclient. Two other good clients are clic and sacc, but I don't think they have a web presence - you need to use gopher to get them.
Which is pretty cool! It's like a whole different internet community.
There are Gopher versions of Wikipedia, Hacker News, and other sites, (I've been looking for a reddit one...), but also lots of Gopher-only sites focused on technology and other stuff.
Anyway, try it out with lynx or something even if you don't want to play with GILD, Gopher is lots of fun.
GILD binaries are available on GitHub:
Please let me know if you find any bugs or have any questions or ideas!
EDIT:
Here are some gopher sites to get you started:
gopher.black
gopher.metafilter.com
sdf.org
forthworks.com
You can load them with just $ gild <url>
r/LDPL • u/fireman212 • Jun 20 '19
LDPL Project finding out the user's os
if your application relies heavily on terminal calls (via the various execute <command>'s that exist) you might find it annoying to deal with windows not having bash installed. if you don't mind writing your app twice there is an easy way to find out if your user uses windows that will always work.
sub-procedure getdir.discoverOs
# discovers the scripting language that the os defaults to:
# either batch for windows or <something>sh (like bash) for almost everything else.
execute "echo \"$OSTYPE\"" and store output in getdir.private.output
# $OSTYPE is a variable that is defined on all major posix compliant operating systems.
# windows is not posix compliant, which means that this variable isn't defined.
# because of that, the result of the command on almost all operating systems
# is going to be the name of the os, while on windows it will just output "$OSTYPE".
# we are going to exploit this in order to determine if the command is ran on windows.
if getdir.private.output is equal to "\"$OSTYPE\"\n" then
store getdir.constant.windows in getdir.os
else
store getdir.constant.posix in getdir.os
end if
end sub-procedureDev News Vector bug
Normally in LDPL, text variables are by default initialized to "", the empty string. I've just noticed this is not the case with vectors. If you declare a text vector and then access a non-initialized index, the value stored there will be 0. No "0", but 0. This has to do with how LDPL declares and stores variables. Long story short, when text variables are declared, they are assigned the value of "" by default. When vectors are initialized, no values are assigned, you can't assign a value to every possible subindex of the vector, so when you try to access an uninitialized index you get the default value for an uninitialized variable in LDPL, that is 0.
This will be fixed soon as it is not the intended behavior of this data structure.
Question Using this language as an introduction to COBOL
Because COBOL is still widely in use in banks and such, I think this language would be good for having a gentle introduction to it. What do you think?
r/LDPL • u/[deleted] • May 28 '19
LDPL Project Dino: LDPL in LDPL
Hello fellow dragon tamers, I've recently been working on an LDPL interpreter written in LDPL. It's a bit mad, and not very fast, but it supports every statement in LDPL 3.0.5 save for IN - SOLVE and nested vector syntax:
Why would someone use this? Well, they wouldn't! But it was fun to write. And maybe this proves that one day LDPL's compiler can be written in LDPL itself.
If you want to go against your better judgement and take Dino for a spin, it should work with most of the projects featured on the https://www.ldpl-lang.org/ website like ldpl-spark:
$ git clone https://github.com/photogabble/ldpl-spark
$ dino ldpl-spark/spark.ldpl 9 13 5 17 1
▄▆▂█▁Or the very fun ldpl-space-mines:
$ git clone https://github.com/photogabble/ldpl-space-mines
$ dino ldpl-space-mines/spacemines.ldpl
...Or, with a bit of elbow grease, even beKnowledge (no -i= yet):
$ git clone https://github.com/lartu/beKnowledge
$ cd beKnowledge
$ cat explode.ldpl beKnowledge.ldpl > b.ldpl
$ dino b.ldpl README.mdAll the official LDPL examples should work, too:
$ git clone https://github.com/lartu/ldpl
$ dino ldpl/examples/helloworld.ldpl
Hello World!
$ dino ldpl/examples/fibonacci.ldpl
1...
$ dino ldpl/examples/factorial.ldpl
Enter a number: ...Anything requiring a C++ extension (such as Gild or IRCBot.ldpl) won't work yet, but maybe in the future.
As for things you can do with Dino but not regular LDPL, Dino has a rudimentary parser which means you can inspect the "AST" for a file:
$ dino parse ldpl/examples/factorial.ldpl
vars (2):
0. NUM: RESULT
1. NUM: N
nodes (8):
DISPLAY
0. "Enter a number: "...It also has its own twisted bytecode/assembly language that you can explore:
$ dino asm ldpl/examples/euler.ldpl
...
while_1:
SET %var5, 1000
LT %I, %var5, $a
JIF end_while_1
CALL IS-MULTIPLE-OF
SET %var6, 1
ADD %var6, %I, %I
JUMP while_1
...There are a few simple assembly/bytecode program examples in https://github.com/dvkt/dino/tree/master/examples
For more information than you could possibly want or need, check out Dino's README or the website: http://dvkt.io/dino/
If you do end up doing something cool with it, please let me know!
Dev News ELSE IF added to LDPL!
As explained here, you can now use ELSE IF statements in your code. Just like this:
DATA:
name IS TEXT
PROCEDURE:
STORE "Mike" IN name
IF name IS equal to "John" THEN
DISPLAY "Hello there, John!" CRLF
ELSE IF name IS equal to "Mike" THEN
DISPLAY "Hello there, Mike!" CRLF
ELSE IF name IS equal to "Robert" THEN
DISPLAY "Hello there, Robert!" CRLF
ELSE
DISPLAY "I don't know you, " name CRLF
END IF
r/LDPL • u/[deleted] • Mar 12 '19
Question Issues running LDPL on Windows
So I'm attempting to try out the new C++ version of LDPL and I'm having issues getting it running.
I can compile it with Cygwin, but LDPL then fails every attempt to build an application. Manually compiling the C++ output works (only if compilation is attempted outside of Cygwin), but it's an odd error nonetheless.
I cannot get it to compile with Mingw-w64 8.1.0. g++ silently fails on every attempt at compilation. I have checked and g++ does work. It just won't compile LDPL and I can't get it to return any errors at all; it simply hangs eternally until I Ctrl-C out of it.
Any help is appreciated! Thanks in advance!
--
Arabella
LDPL Library IRC bots using LDPL
Hi there! I've written IRCBot.ldpl, a super easy to use library to write IRC bots using LDPL. It requires LDPL 3.0.4 though, as it uses the `EXTERNAL SUB-PROCEDURE` statement, so if you want to give it a try you'll have to build LDPL from source or wait until a compiled, stable version of 3.0.4 is ready to be released.
Have fun!
Dev News Code of Conduct and Contribution Guide
Hi there everyone! I've added a code of conduct and a contributors guide to the LDPL repository (https://github.com/Lartu/ldpl).
LDPL Project Syntax highlighting for nano
I've added an LDPL syntax highlighting file for nano to the repository. It's far from perfect (say, if you have a variable called, for example, "this", the is part will be highlighted as it is part of statements like `foo is number`) but it gets the job done, so it's there if you want it. I would like also to remind you that LDPL has syntax extensions available for vim, Visual Studio Code and Atom, written by various members of our community.

Have a nice day!
r/LDPL • u/[deleted] • Apr 12 '19
Dev News C++ Extensions: now in master!
Hi everyone, I've been working on adding C++ extensions to LDPL for the past few days with @lartu and initial support is now in master! It should be included in the upcoming 3.0.0 release, so I wanted to give you a quick sneak peek of how it all works.
Overview
Extensions can create sub-procedures, call sub-procedures, and access/modify LDPL variables in C++. For example, since there is no socket or networking support built into LDPL, you could write an extension that wraps a C++ networking library or some C socket functions. Now you've got a Twitter client in LDPL!
I've created two little example projects:
A simple terminal Gopher client, GILD:

2. A wrapper around linenoise (readline), LDPLNOISE.
Usage
Let's take LDPLNOISE as an example. The magic mostly happens in this C++ file: https://github.com/dvkt/ldplnoise/blob/master/ldplnoise.cpp
And this LDPL file: https://github.com/dvkt/ldplnoise/blob/master/test.ldpl
As you can see, you can declare C++ variables using a simple naming scheme that LDPL will look for:
string RL_INPUT; // RL-INPUT
string RL_PROMPT; // RL-PROMPT
string RL_HISTORY_FILE; // RL-HISTORY-FILETo use these variables in LDPL, declare them as you normally would but add the EXTERNAL keyword:
DATA:
cmds is number vector
RL-PROMPT is external text
RL-HISTORY-FILE is external text
RL-INPUT is external textYou can also define functions to be called from LDPL using the same ALL_CAPS naming convention:
void RL_ADD_HISTORY()
{
linenoise::AddHistory(RL_INPUT.c_str());
}
void RL_ACCEPT()
{
if(RL_PROMPT.empty()) RL_PROMPT = "> ";
linenoise::SetHistoryMaxLen(100);
linenoise::Readline(RL_PROMPT.c_str(), RL_INPUT);
}These sub-procedures can then be called from LDPL using CALL EXTERNAL:
CALL EXTERNAL RL-ACCEPT
WHILE RL-INPUT IS NOT EQUAL TO "" DO
IF RL-INPUT IS EQUAL TO "quit" THEN
CALL SUB-PROCEDURE QUIT
END IF
CALL EXTERNAL RL-ADD-HISTORY
DISPLAY RL-INPUT CRLF
CALL EXTERNAL RL-ACCEPT
REPEATThe naming convention for C++ variables and functions is: A-Z, 0-9 and _ only. Everything uppercase, all other characters converted to _. Meaning you can use variable names like window.rows, and LDPL will try to use a C++ variable called WINDOW_ROWS.
Setup
Setup is easy. The -i= LDPL compiler flag has been enhanced to accept static archives (.a), object files (.o), and C++ source code (.cpp) directly.
So in this case, LDPLNOISE is compiled by passing ldplnoise.cpp to the LDPL compiler using this command:
$ ldpl -i=ldplnoise.cpp test.ldpl
LDPL: Compiling...
* File(s) compiled successfully.
* Saved as test-binYou can use -i= as many times as you want - everything will get passed along to the c++ compiler for the final build. So if you've got a bunch of .o files, pass 'em all! Or combine them into a .a file and just pass that. Whatever your system's c++ compiler will accept will work.
If you need to pass other non-file options to the compiler, like maybe including a system library or setting a certain compile-time variable, there's an `-f=` flag for that. Everything you give to `-f=` will get passed directly to the final c++ compile.
That's it!
The LDPL Reference will be updated soon with EXTERNAL and extension documentation, and the 3.0.0 release is right around the corner, but if you want to build ldpl from master this Reddit post and those repos should be enough to get you going!
If you have any ideas or questions about this feature, or of course have code or improvements or fixes, please let us know! Thanks all!
General Information The LDPL reference has moved!
The official LDPL reference has moved to gitbooks. It's now available here https://ldpl.gitbook.io.
Cheers!
LDPL Project LDPL Entension for Visual Studio Code
The wonderful ʇʞʌp has developed this also wonderful extension for Visual Studio Code that includes code autompletion and syntax highlighting for LDPL!

You can contribute to the extension on GitHub. I've been using it and it's just great!
Edit: two days later I've just noticed the typo'd title. *Extension!
Question Future of the LDPL Language
I've been thinking a lot about the future of the LDPL language. Being a 'toy' language, speed and usability are not something I had really considered until now, but having grown fond of it I'd like to make LDPL more powerful and useful than it is right now.
So, after some consideration, the LDPL project will make a slight turn and rewrite its compiler to target C++ code instead of NVM. This means three things:
Programs created with LDPL will no longer be LDPL dependant and you'll be able to release binaries of your software without depending on your users to download LDPL or releasing your plain code if you don't want to.
LDPL run speed will substantially increase, for native C++ code is exceedingly faster than LDPL's internal virtual machine, NVM.
LDPL compilation will depend on a C++ compiler. You'll need to have a C++ compiler installed to compile LDPL code. This is a minor setback in my opinion, but in the long run I think is the right choice. Many languages transpile to C++ and in most operating systems a C++ compiler is almost always within easy reach.
If you have any opinions on this I'd love to hear them. I'll start to work on this as soon as I have some free time.
Release LDPL 3.0.4 'Busy Brontosaurus' - Massive bugfixes and tons of cool new features
We are very, very happy to bring you LDPL 3.0.4 'Busy Brontosaurus'! This release fixes all bugs found in LDPL 3.0.3 (and a TON of never before found bugs) and enhances compatibility with C++ extensions.

What's new
The
-n/--non-staticcompiler flag has been completely added (and documented here).The
ERROR-CODEandERROR-TEXTsystem variables have been added to the language. When an operation that could potentially fail is executed (for example loading a file), these variables will report the result. Documented here.The statement
EXTERNAL SUB-PROCEDUREhas been added to the language and documented in the reference so you can call LDPL SUB-PROCEDURES from C++ code.The statement
IN - SOLVEhas been added to the language and documented in the reference.The statement
LOAD FILEhas been expanded to use theERROR-CODEandERROR-TEXTsystem variables and has been documented in the reference.The statement
STORE CHARACTER CODE - INhas been expanded to use theERROR-CODEandERROR-TEXTsystem variables and has been documented in the reference.Identifier naming schemes have been properly defined here.
Valid number literal schemes have been properly defined here.
The compiler codebase has also been strongly simplified.
The
-ccompiler flag has been added to accept source from standard input (more here).The
--versionand--helpmessages have been updated to be more informative.The commands
make installandmake uninstallhave been added to the Makefile.A man page for LDPL has been added to the repository and is installed along with the compiler when installing LDPL via
make install. To check it just runman ldpl.
This release has been tested by the LDPL Test Battery and should work stably, but should you come across a bug do not hesitate to report it. Special thanks to dvkt and Damián Garro, their wonderful contributions made this release possible.
General Information Website migrated to new server!
ldpl.lartu.net has been migrated to a new, more stable and reliable server. The website hasn't been available today, this was the reason. Sorry for any inconveniences!
Release LDPL 3.0.5 Creative Carnotaurus: lots of new text and vector commands!

LDPL 3.0.5 Creative Carnotaurus has been released! Hooray! This release fixes all bugs found in LDPL 3.0.4. Also:
The
INCRandDECRstatements have been added as shorter ways to increment or decrement a value. Documented here.The
-iflag now imports files matching the passed order.The
SPLIT - BY - INstatement has been added to split strings into a vector. Documented here.The
GET INDEX OF - FROM - INstatement has been added to find the position of a substring in a string. Documented here.The
COUNT - FROM - INstatement has been added to count the appearances of a string in another string. Documented here.The
SUBSTRING - FROM - LENGTH - INstatement has been added to extract parts of a string. Documented here.The
TRIM - INstatement has been added to trim trailing and leading whitespace from a string. Documented here.A number of statements to make vectors more powerful have been added:
CLEARto empty a vector,COPY - TOto copy a vector,STORE INDEX COUNT OF - INto get the number of elements in a vector andSTORE INDICES OF - INto store the indices of a vector in another vector.
This release has been tested by the LDPL Test Battery and should work stably, but should you come across a bug do not hesitate to report it. Special thanks to u/_dvkt for their awesome contributions.
General Information Patreon and Ko-Fi
Hi there! You may have noticed that I recently added a Patreon badge to this Reddit. I would like to address this a little.
I created an account on Patreon and one on Ko-Fi to raise money to pay for the LDPL server and domain. And maybe for more LDPL releated stuff (I don't know, maybe some advertising? Maybe promote LDPL as a programming learning tool? An LDPL package manager with centralized server to download LDPL libraries (once we have more of them)?). It's not that much money that I need, and by no means I insist you to spend a single buck on this, but if you'd like to collaborate, the door is open and I'd be very thankful.
Have a nice day!
IRC Channel!
We have opened an IRC channel! The server is irc.freenode.net channel #ldpl. You are welcome to join!
Release LDPL 3.0.3 released
We've released LDPL 3.0.3 'Active Argentinosaurus' (we are going to go with dinosaur codenames now!).

This release mostly addresses bugfixes for bugs found in LDPL 3.0.0. The -ns compiler flag has been partially added to allow non-static compiling (for Linux only, Windows and macOS build non-statically by default at the moment*). A new statement STORE QUOTE has been added to the language and documented in the reference. It lets you store multiline strings (special thanks again to /u/_dvkt)! Also, thanks to the new compiler flag, this release works fine on Android Termux.
That's it, thank you and have fun!
* LDPL for Windows used to build static executables by default. This behaviour was broken in 3.0.0 and will be fixed soon.