Anyone here made their own programming language?

Off-topic talk on music, art, literature, games and forum games.
teo123
Master of the Forum
Posts: 1393
Joined: Tue Oct 27, 2015 3:46 pm
Diet: Vegan

Re: Anyone here made their own programming language?

Post by teo123 »

Yesterday evening, I published another YouTube video about my programming language: https://youtu.be/YFZ-45ea5mo
teo123
Master of the Forum
Posts: 1393
Joined: Tue Oct 27, 2015 3:46 pm
Diet: Vegan

Re: Anyone here made their own programming language?

Post by teo123 »

Apparently, not everybody thinks I can be trusted about programming just because I made a programming language: https://discord.com/channels/1720184990 ... 7450117121
stuxxnet wrote:
Teo Samarzija wrote: Come on now, I have written a programming language that compiles to WebAssembly, I know that stuff.
you've also written a log function that runs in an infinite loop if the input is close to 1
you're trying to compare sort functions written in an interpreted language to those provided by that language in its native VM
you're overfitting measurement data to come up with a completely insane formula for the comparisons of quicksort
you're using rand in c++ code
you implement custom math functions using highschool maths that just doesn't work if you want to be numerically efficient or just even get a sane result for the whole range of possible inputs.
I'm sorry, but I really don't have much confidence in your judgement calls...
teo123
Master of the Forum
Posts: 1393
Joined: Tue Oct 27, 2015 3:46 pm
Diet: Vegan

Re: Anyone here made their own programming language?

Post by teo123 »

I have written my solution to the N-Queens Puzzle in my programming language: https://flatassembler.github.io/nQueensPuzzle.html
teo123
Master of the Forum
Posts: 1393
Joined: Tue Oct 27, 2015 3:46 pm
Diet: Vegan

Re: Anyone here made their own programming language?

Post by teo123 »

I made executable files for the AECforWebAssembly v1.5.6, because it seems to parse code 10 times faster than AECforWebAssembly v1.5, just because of some trivial (and mysterious as to how they could drastically speed up the parsing) fixes: https://sourceforge.net/projects/aecfor ... es/v1.5.6/

I have managed to tweak it to work in CLANG, but it still does not work in Visual Studio C++. Namely, my compiler runs into Stack Overflow error when set to compile complicated example programs if it itself is compiled using some C++ compilers.
teo123
Master of the Forum
Posts: 1393
Joined: Tue Oct 27, 2015 3:46 pm
Diet: Vegan

Re: Anyone here made their own programming language?

Post by teo123 »

I have added a few more features to the compiler for my programming language, including lvalue conditional operator and multi-line strings, both of them from C++.
teo123
Master of the Forum
Posts: 1393
Joined: Tue Oct 27, 2015 3:46 pm
Diet: Vegan

Re: Anyone here made their own programming language?

Post by teo123 »

I have just written a program that converts Arabic numbers to Roman numbers in my programming language.
teo123
Master of the Forum
Posts: 1393
Joined: Tue Oct 27, 2015 3:46 pm
Diet: Vegan

Re: Anyone here made their own programming language?

Post by teo123 »

So, thanks to the help from people on the VOGONS forum, I have managed to make my AEC-to-x86 compiler target i486. Now you can, for example, use it in DosBox.
teo123
Master of the Forum
Posts: 1393
Joined: Tue Oct 27, 2015 3:46 pm
Diet: Vegan

Re: Anyone here made their own programming language?

Post by teo123 »

Here is my first AEC 16-bit DOS program:

Code: Select all

;This is my attempt to port "rose.aec" to 16-bit DOS, using FlatAssembler.
;My previous DOS example, "anlalogClockForDOS.aec" is 32-bit and is assembled
;using GNU Assembler.
;Notice that we CANNOT use arrays here, as ArithmeticExpressionCompiler uses
;"ebx" to index arrays, which works in 32-bit and 64-bit mode, but doesn't work
;in the 16-bit mode.
AsmStart
    format binary as "COM"
    org 100h
    use16
AsmEnd
y:=0
While y<24
    x:=0
    While x<79
        distance:=sqrt(pow(abs((x-40)/2),2)+pow(abs(y-12),2))
        angle:=atan2(y-12,(x-40)/2)
        r:=cos(angle*3)*12
        If (distance < (r + 0.5) ) | ( (y = 12) & (x > 40-1) & (x < 40 + (13 * 2) ) )
            AsmStart
                mov dl,'*'
                mov ah,2
                int 0x21
            AsmEnd
        Else
            AsmStart
                mov dl,' '
                mov ah,2
                int 0x21
            AsmEnd
        EndIf
        x:=x+1
    EndWhile
    AsmStart
        mov dl,0xa ;The newline character
        mov ah,2
        int 0x21
    AsmEnd
    y:=y+1
EndWhile
AsmStart
int 0x20

result dd ?
x dd ?
y dd ?
distance dd ?
angle dd ?
r dd ?
AsmEnd
teo123
Master of the Forum
Posts: 1393
Joined: Tue Oct 27, 2015 3:46 pm
Diet: Vegan

Re: Anyone here made their own programming language?

Post by teo123 »

Recently, I got the Starstruck achievement on GitHub, as my AEC-to-WebAssembly compiler got its 16th star: https://github.com/FlatAssembler?achiev ... hievements
teo123
Master of the Forum
Posts: 1393
Joined: Tue Oct 27, 2015 3:46 pm
Diet: Vegan

Re: Anyone here made their own programming language?

Post by teo123 »

I've tried to write a as-portable-as-possible script for downloading the source code and building the Analog Clock in AEC.
For AEC-to-x86:

Code: Select all

mkdir ArithmeticExpressionCompiler
cd ArithmeticExpressionCompiler
if [ $(command -v wget > /dev/null 2>&1 ; echo $?) -eq 0 ] # Check if "wget" exists, see those StackOverflow answers for more details:
                                                                                         # https://stackoverflow.com/a/75103891/8902065
                                                                                         # https://stackoverflow.com/a/75103209/8902065
then
  wget https://flatassembler.github.io/Duktape.zip
else
  curl -o Duktape.zip https://flatassembler.github.io/Duktape.zip
fi
unzip Duktape.zip
if [ $(command -v gcc > /dev/null 2>&1 ; echo $?) -eq 0 ]
then
  gcc -o aec aec.c duktape.c -lm # The linker that comes with recent versions of Debian Linux insists that "-lm" is put AFTER the source files, or else it outputs some confusing error message.
else
  clang -o aec aec.c duktape.c -lm
fi
./aec analogClock.aec
if [ $(command -v gcc > /dev/null 2>&1 ; echo $?) -eq 0 ]
then
  gcc -o analogClock analogClock.s -m32
else
  clang -o analogClock analogClock.s -m32
fi
./analogClock
        
For AEC-to-WebAssembly:

Code: Select all

if [ $(command -v git > /dev/null 2>&1 ; echo $?) -eq 0 ]
then
  git clone https://github.com/FlatAssembler/AECforWebAssembly.git
  cd AECforWebAssembly
elif [ $(command -v wget > /dev/null 2>&1 ; echo $?) -eq 0 ]
then
  mkdir AECforWebAssembly
  cd AECforWebAssembly
  wget https://github.com/FlatAssembler/AECforWebAssembly/archive/refs/heads/master.zip
  unzip master.zip
  cd AECforWebAssembly-master
else
  mkdir AECforWebAssembly
  cd AECforWebAssembly
  curl -o AECforWebAssembly.zip -L https://github.com/FlatAssembler/AECforWebAssembly/archive/refs/heads/master.zip # Without the "-L", "curl" will store HTTP Response headers of redirects to the ZIP file instead of the actual ZIP file.
  unzip AECforWebAssembly.zip
  cd AECforWebAssembly-master
fi
if [ $(command -v g++ > /dev/null 2>&1 ; echo $?) -eq 0 ]
then
  g++ -std=c++11 -o aec AECforWebAssembly.cpp # "-std=c++11" should not be necessary for newer versions of "g++". Let me know if it is, as that probably means I disobeyed some new C++ standard (say, C++23).
else
  clang++ -o aec AECforWebAssembly.cpp
fi
cd analogClock
../aec analogClock.aec
npx -p wabt wat2wasm analogClock.wat
node analogClock

Is there anybody knowledgeable about various operating systems here to know how to make the scripts better? @TelepathyConspiracy, you mentioned you considered making your own operating system, so perhaps you are knowledgeable about those things?
Post Reply