Relax, a compiled programming language, implemented entirely in AHK

Post your working scripts, libraries and tools for AHK v1.1 and older
CloakerSmoker
Posts: 33
Joined: 07 Sep 2018, 15:54

Relax, a compiled programming language, implemented entirely in AHK

04 Feb 2020, 11:48

(I've been trying to decide if it's OK to copy-paste my reddit post to save my fingers, but there's no fun in that, so I'm only going to paste the good part).

Relax (https://github.com/CloakerSmoker/Relax-Language), a compiled C-like language implemented entirely in AHK.

Although it probably could have also been called 'sleep-deprivation' or 'over-ambition'.

This sounds like an advertisement, and I wish it was, but sadly this project is only a learning experience. Don't even get me started on how much money I would have made if I got a job instead of writing this.


Relax is my crack at writing a basic compiled language which runs at the same level of abstraction as C.
Of course, Relax is nowhere near as good as a C compiler, but thanks to generating AMD64 machine code and running that directly on the CPU, it reaches very high speeds.
There's lots of ways that it could be improved, but I've learned what I wanted to from the project, and I've gotten it to a point that I'm happy with.

So, I present my magnum opus (or at least my current magnum opus) to the ultimate judge of all things AHK: you, the forums. Any thoughts?
Helgef
Posts: 4709
Joined: 17 Jul 2016, 01:02
Contact:

Re: Relax, a compiled programming language, implemented entirely in AHK

04 Feb 2020, 12:25

I just speed read the documentation, can't wait to try this! Very cool stuff. :salute: :beer:

Cheers, and thanks for sharing.
User avatar
runie
Posts: 304
Joined: 03 May 2014, 14:50
Contact:

Re: Relax, a compiled programming language, implemented entirely in AHK

04 Feb 2020, 12:33

The man, the myth, the legend. The work of a madman
User avatar
rommmcek
Posts: 1470
Joined: 15 Aug 2014, 15:18

Re: Relax, a compiled programming language, implemented entirely in AHK

04 Feb 2020, 14:20

I can't find output file nowhere! What am I doing wrong (I'm an amateur)?
Spoiler
CloakerSmoker
Posts: 33
Joined: 07 Sep 2018, 15:54

Re: Relax, a compiled programming language, implemented entirely in AHK

04 Feb 2020, 14:36

Hmm, the output file should just be "out.exe" in the working directory.
I haven't had any problems with the output path, and you should get an error if it can't be opened, but I'll look into it.
It might be worth searching for "out.exe" to see if it was just created in the wrong folder.

Alternatively, you can also provide a full path for the output file, which should ensure the correct path is used.

And thank you (and Runie and Helgef) for the interest in the project!
User avatar
rommmcek
Posts: 1470
Joined: 15 Aug 2014, 15:18

Re: Relax, a compiled programming language, implemented entirely in AHK

04 Feb 2020, 15:09

This does no better Main.exe --verbose -i Examples\HelloWorld.rlx -o "C:\Users\RRR\My Ahk-s\Relax-Language-master\out.exe". I searched for out in the entire RRR folder including all subfolders and there is no out.exe.

P.s.: Running Main.ahk with appropriate parameters fixes the problem, but I get This app can't run on your PC if I try to execute out.exe.
The same for Main.ahk --verbose -i Examples\SimpleConsoleProgram.rlx -o out2.exe
Attachments
out.zip
(2.35 KiB) Downloaded 98 times
Last edited by rommmcek on 04 Feb 2020, 15:29, edited 1 time in total.
CloakerSmoker
Posts: 33
Joined: 07 Sep 2018, 15:54

Re: Relax, a compiled programming language, implemented entirely in AHK

04 Feb 2020, 15:26

rommmcek wrote:
04 Feb 2020, 15:09
This does no better Main.exe --verbose -i Examples\HelloWorld.rlx -o "C:\Users\RRR\My Ahk-s\Relax-Language-master\out.exe". I searched for out in the entire RRR folder including all subfolders and there is no out.exe.

P.s.: Running Main.ahk with appropriate parameters fixes the problem!
Oh, that actually makes a lot of sense. Chances are that Main.exe is being blocked for being a foreign executable file, which might be why it can't actually create/write to the output file (especially considering it is trying to write to a .exe file, which probably sets off an alarm bell or two).

The only difference between Main.ahk and Main.exe is that Main.exe will run as a console app, and won't open a whole new console window; so you can just remove Main.exe if it doesn't work and use Main.ahk instead.

I'll write myself a note to add something about that in the README or docs. Thanks for figuring that out, because I was honestly clueless why that would happen.
And thanks again for trying the language.

Edit: Just saw your edit, let me check out what's going wrong there
CloakerSmoker
Posts: 33
Joined: 07 Sep 2018, 15:54

Re: Relax, a compiled programming language, implemented entirely in AHK

04 Feb 2020, 15:39

Alright, so I've checked over the output file, and it is a valid .exe, all of the headers are correctly set, and it runs fine for me on Windows 10 Pro (64 bit).

All I can think of is that you're running a 32 bit system, or a version of windows older than Windows Vista (Those are the two constraints that I explicitly have in the output files).
This will *only* work on 64 bit systems, 64 and 32 bit have just enough differences to make the 64 bit code Relax generates incompatible.

Relax only targets AMD64 for the architecture, not regular x86, so none of the output code would work on 32 bit systems.

At various points I've thought about adding 32 bit support, but I'd have to rewrite lots of the compiler and code generation to not depend on the 8 new registers added by AMD64.

Of course, I forgot to mention this in any of the documentation, which is another thing I've written down to change. Once again, thanks for trying it.
User avatar
rommmcek
Posts: 1470
Joined: 15 Aug 2014, 15:18

Re: Relax, a compiled programming language, implemented entirely in AHK

04 Feb 2020, 15:50

I am using Win10 build 1803 x64. I'll try some different things and let you know (maybe it'll take some time... hours or even days...). But it's good to know it's a valid .exe file!
CloakerSmoker
Posts: 33
Joined: 07 Sep 2018, 15:54

Re: Relax, a compiled programming language, implemented entirely in AHK

04 Feb 2020, 16:01

Well, that's not good. I really had my fingers crossed you'd be on 32 bit lol. It's a lot easier to say "I don't support 32 bit" than to dive into the exe format.

The only other thing I can think of is if the output executable is also being blocked by windows for some reason.
The only time I had that error while developing was when I set the size of the executable file to be too small, but the value is set correctly now (and set correctly in that file).

For now, I'm going to try to get some sleep, but when I wake up tomorrow I'll look into what machine-dependent things could cause the files to not load.
User avatar
rommmcek
Posts: 1470
Joined: 15 Aug 2014, 15:18

Re: Relax, a compiled programming language, implemented entirely in AHK

04 Feb 2020, 16:05

O.k., thank you for now!
P.s.: I tried to run above out.exe file on Win7 x64.
Attachments
out.exe.png
out.exe.png (21.45 KiB) Viewed 3484 times
burque505
Posts: 1731
Joined: 22 Jan 2017, 19:37

Re: Relax, a compiled programming language, implemented entirely in AHK

04 Feb 2020, 19:03

@CloakerSmoker, this looks promising, thanks for all that work. I have exactly the same results as @rommmcek on Win7 SP1, 64-bit, using the provided "main.exe". I'm going to try a few other things now.
Looking forward to this!
Regards,
burque505

EDIT: Just tried it on Win10 Pro, Build 18362.
Both example programs compile and run, but don't write any output to console.
No errors while compiling!
SOTE
Posts: 1426
Joined: 15 Jun 2015, 06:21

Re: Relax, a compiled programming language, implemented entirely in AHK

04 Feb 2020, 20:32

@CloakerSmoker

I find what you have done fantastic. Very impressive, congratulations!

However, choosing the AGPL could be devastating to any potential use or collaboration with others. The AGPL is arguably the most viral of all copyleft licenses. Way more so than just the GPL. To comparatively understand the ramifications of choosing AGPL, let's compare it to licenses used by other well known programming languages.

The Rust Progamming Language is under the Apache and MIT license, very liberal licenses that are not viral and don't usually cause legal issues or confusion. Free Pascal (Object Pascal) is under the LGPL, which is the least viral and the friendliest of GNU licenses. The Red Programming language is under BSD, which is more user friendly than the GPL and can be a bit more so than the LGPL.

You might want to consider changing from the AGPL to MIT, BSD, or LGPL. This can allow you to receive full credit as the creator and/or keep the source code open, but be user friendly and allow users actual freedom to choose how to modify, distribute, or adapt it into other projects. A truly more liberal license can possibly make collaboration with other programmers or projects easier.
CloakerSmoker
Posts: 33
Joined: 07 Sep 2018, 15:54

Re: Relax, a compiled programming language, implemented entirely in AHK

05 Feb 2020, 05:04

Ok, I figured out what's wrong if you don't see any output.

Git is replacing `r`n in the __Precompiled__ files (which just hold the generated code for the built in libraries to speed up compiling) with just `n, and that's breaking them. If you remove all of the __Precompiled__ files and run it again, it will rebuild the files with the correct line endings. (Which fixed it for me)

I'll be updating the repo so the __Precompiled__ files don't come with, so they are always regenerated with the correct line endings.

Sorry about the troubles, this was a big pain considering everything looked fine on my local copy, but a simple "git pull" seemed to break everything.

Hopefully that was the whole problem. As for not running on some versions of windows, I'm looking into if I've got a header set to use a rare feature or something.
CloakerSmoker
Posts: 33
Joined: 07 Sep 2018, 15:54

Re: Relax, a compiled programming language, implemented entirely in AHK

05 Feb 2020, 05:07

SOTE wrote:
04 Feb 2020, 20:32
@CloakerSmoker

However, choosing the AGPL could be devastating to any potential use or collaboration with others. The AGPL is arguably the most viral of all copyleft licenses. Way more so than just the GPL. To comparatively understand the ramifications of choosing AGPL, let's compare it to licenses used by other well known programming languages.

The Rust Progamming Language is under the Apache and MIT license, very liberal licenses that are not viral and don't usually cause legal issues or confusion. Free Pascal (Object Pascal) is under the LGPL, which is the least viral and the friendliest of GNU licenses. The Red Programming language is under BSD, which is more user friendly than the GPL and can be a bit more so than the LGPL.

You might want to consider changing from the AGPL to MIT, BSD, or LGPL. This can allow you to receive full credit as the creator and/or keep the source code open, but be user friendly and allow users actual freedom to choose how to modify, distribute, or adapt it into other projects. A truly more liberal license can possibly make collaboration with other programmers or projects easier.
Thank you for letting me know, when I picked a license I had lots of other things on my mind and didn't bother researching very much. I just saw "strongest copyleft" and figured that it sounded pretty good compared to "copyright".

I'll look over the other licenses and pick a new one shortly.

Edit: I've switched to LGPL, and sorry if this has caused any problems. I picked AGPL at first because it seemed like it would be the most "equal-opportunity", but I clearly misunderstood what I was reading.
CloakerSmoker
Posts: 33
Joined: 07 Sep 2018, 15:54

Re: Relax, a compiled programming language, implemented entirely in AHK

05 Feb 2020, 05:39

@burque505 @rommmcek

If possible, could you try on an older version of windows (or in rommmcek's case: your version of Windows 10) using the latest version of Relax?
In the latest version I've removed some more "modern" things from the .exe file headers (that were only set because I copied them from a .exe file that VS2019 built for me), which might have been the problem.

If the problem still persists, I'll look into starting up a windows 7 VM, although considering it also seems to happen on Windows 10, I'm a bit stumped.
User avatar
Delta Pythagorean
Posts: 627
Joined: 13 Feb 2017, 13:44
Location: Somewhere in the US
Contact:

Re: Relax, a compiled programming language, implemented entirely in AHK

05 Feb 2020, 05:49

So...
Is this just a way to create dll files/library executables using ahk? Or am I reading the documentation wrong?

[AHK]......: v2.0.12 | 64-bit
[OS].......: Windows 11 | 23H2 (OS Build: 22621.3296)
[GITHUB]...: github.com/DelPyth
[PAYPAL]...: paypal.me/DelPyth
[DISCORD]..: tophatcat

SOTE
Posts: 1426
Joined: 15 Jun 2015, 06:21

Re: Relax, a compiled programming language, implemented entirely in AHK

05 Feb 2020, 05:58

CloakerSmoker wrote:
05 Feb 2020, 05:07

Thank you for letting me know, when I picked a license I had lots of other things on my mind and didn't bother researching very much. I just saw "strongest copyleft" and figured that it sounded pretty good compared to "copyright".

I'll look over the other licenses and pick a new one shortly.

Edit: I've switched to LGPL, and sorry if this has caused any problems. I picked AGPL at first because it seemed like it would be the most "equal-opportunity", but I clearly misunderstood what I was reading.
Thought that was a possibility, because AGPL is rarely seen on GitHub (as it's very restrictive), so wanted to put that out there for reasoning and clarification. LGPL is a good choice.

The documentation you have created, https://cloakersmoker.github.io/Relax-Language/#how-it-works/, is a good read. Especially as cooked up as a sleepless experiment.
User avatar
rommmcek
Posts: 1470
Joined: 15 Aug 2014, 15:18

Re: Relax, a compiled programming language, implemented entirely in AHK

05 Feb 2020, 06:17

I tried new version quickly on Win10 and it seems to show no changes, i.e. running Main.exe yields no output and output from Main.ahk can't be run on my PC.
P.s.: Is Main.exe on GitHub identical with that compiled on PC or is it a separate version?

Return to “Scripts and Functions (v1)”

Who is online

Users browsing this forum: No registered users and 64 guests