www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.announce - styx, a programming languange written in D, is on the bootstrap path

reply Basile B. <b2.temp gmx.com> writes:
This is the last[1] occasion to speak about a programming 
language initiatly made in D, as the bootstrap phase is very near.

I'd like to thank the D compiler developers, that let me work on 
DMD even if I borrow another path.

[1] : https://gitlab.com/styx-lang/styx
Jan 14 2021
next sibling parent reply Daniel N <no public.email> writes:
On Thursday, 14 January 2021 at 17:51:51 UTC, Basile B. wrote:
 This is the last[1] occasion to speak about a programming 
 language initiatly made in D, as the bootstrap phase is very 
 near.

 I'd like to thank the D compiler developers, that let me work 
 on DMD even if I borrow another path.

 [1] : https://gitlab.com/styx-lang/styx
Love the design FWIW.
Jan 14 2021
parent Basile B. <b2.temp gmx.com> writes:
On Thursday, 14 January 2021 at 20:21:42 UTC, Daniel N wrote:
 On Thursday, 14 January 2021 at 17:51:51 UTC, Basile B. wrote:
 This is the last[1] occasion to speak about a programming 
 language initiatly made in D, as the bootstrap phase is very 
 near.

 I'd like to thank the D compiler developers, that let me work 
 on DMD even if I borrow another path.

 [1] : https://gitlab.com/styx-lang/styx
Love the design FWIW.
Initially I wanted something like libdparse + dsymbol, i.e a clean split of the AST the semantic phase, semi-success. There's still a Symbol class but the types have been moved to the AST. Another design idea is that I wanted to have useful visitors, i.e that always process a whole compilation unit, but that did not work well so now visitors are pretty much state-less and when a "state" is required it is stored in scopes, "like in dmd". I quote that because many times I've discovered that, in dmd, if things are done in a way and not another, it's not arbitrary. The main reason for that is that if you want to support out of order declarations and "auto" you have to drive the semantics like in dmd, declaration -> bodies -> statements -> expressions, and when you reach something that is not known you launch this chain...
Jan 15 2021
prev sibling next sibling parent reply Ola Fosheim =?UTF-8?B?R3LDuHN0YWQ=?= <ola.fosheim.grostad gmail.com> writes:
On Thursday, 14 January 2021 at 17:51:51 UTC, Basile B. wrote:
 This is the last[1] occasion to speak about a programming 
 language initiatly made in D, as the bootstrap phase is very 
 near.
Interesting project! How did you move from D to Styx? (I assume bootstrapping means a self hosting compiler?) Did you write some scripts to translate? I've found myself to sketch new programming languages whenever I hit things in existing languages that I find annoying over the past decade or so. I finally decided to start on a lexer for it... How long did it take you to get where you are now?
Jan 15 2021
next sibling parent reply Basile B. <b2.temp gmx.com> writes:
On Friday, 15 January 2021 at 09:54:59 UTC, Ola Fosheim Grøstad 
wrote:
 On Thursday, 14 January 2021 at 17:51:51 UTC, Basile B. wrote:
 This is the last[1] occasion to speak about a programming 
 language initiatly made in D, as the bootstrap phase is very 
 near.
Interesting project! How did you move from D to Styx? (I assume bootstrapping means a self hosting compiler?) Did you write some scripts to translate?
self-hosting is not started yet, maybe next month, classes are still to be implemented. I plan to use dparse for the most part, not only to convert but also to detect non bootstrapable code or missing features. Then, feature freeze, convert, catch and fix bugs as they will appear when feading the compiler with real food.
 I've found myself to sketch new programming languages whenever 
 I hit things in existing languages that I find annoying over 
 the past decade or so.
This is a noble reason. Styx has no such motivations. It is simpler than D1 for example and has no killer feature, just 3 or 4 creative things are - optional break/continue expression - explicit overloads - DotExpression aliases (they have been proposed to DMD this summer when I worked "under cover" as Nils.) - pointers to member function is very different from what I have seen so far (no fat pointer)
 I finally decided to start on a lexer for it... How long did it 
 take you to get where you are now?
The project exists since several years (2017-04-13 20:05:51) but is only actively developed since july 2020. The game changers were: - to use LLVM instead of libfirm - to that some part of the initial design were bad - proper lvalue implementation
Jan 15 2021
next sibling parent reply Per =?UTF-8?B?Tm9yZGzDtnc=?= <per.nordlow gmail.com> writes:
On Friday, 15 January 2021 at 19:18:09 UTC, Basile B. wrote:
 - DotExpression aliases (they have been proposed to DMD this 
 summer when I worked "under cover" as Nils.)
Can you give examples of what a DotExpression alias is?
Jan 15 2021
parent Basile B. <b2.temp gmx.com> writes:
On Friday, 15 January 2021 at 19:25:38 UTC, Per Nordlöw wrote:
 On Friday, 15 January 2021 at 19:18:09 UTC, Basile B. wrote:
 - DotExpression aliases (they have been proposed to DMD this 
 summer when I worked "under cover" as Nils.)
Can you give examples of what a DotExpression alias is?
They allow to pull heavily nested members, similarly as getters are sometime used and are supposed to make object composition easier. This [1] is the test file used to develop the feature. [1] https://gitlab.com/styx-lang/styx/-/raw/51611f2d5c023c0edfe97968b543660ae2e89c26/tests/backend/dotexp_alias.sx
Jan 15 2021
prev sibling next sibling parent reply Ola Fosheim =?UTF-8?B?R3LDuHN0YWQ=?= <ola.fosheim.grostad gmail.com> writes:
On Friday, 15 January 2021 at 19:18:09 UTC, Basile B. wrote:
 I plan to use dparse for the most part, not only to convert but 
 also to detect non bootstrapable code or missing features.
Ah, smart. I've been thinking about using an existing d-parser to convert unit tests from D to my Dex syntax (experimental project). Modifying the compiler is fun, but writing unit tests is not...
 This is a noble reason. Styx has no such motivations. It is 
 simpler than D1 for example and has no killer feature,
What made D1 attractive to many C++ programmers was that it was stripped down. Also, many language designers get tempted to add many features that are hollow, then they regret it and rip it all out again (lots of wasted effort and source code). So, being very restrictive and patient is a good thing, I believe. The truly good ideas takes time to "grow" (in ones mind).
 just 3 or 4 creative things are
 - optional break/continue expression
 - explicit overloads
 - DotExpression aliases (they have been proposed to DMD this 
 summer when I worked "under cover" as Nils.)
 - pointers to member function is very different from what I 
 have seen so far (no fat pointer)
"Nils" is a very scandinavian name? :-) It will be interesting to see what your codebase looks like after moving to self hosted. I assume you will keep us up to date.
 I finally decided to start on a lexer for it... How long did 
 it take you to get where you are now?
The project exists since several years (2017-04-13 20:05:51) but is only actively developed since july 2020. The game changers were: - to use LLVM instead of libfirm - to that some part of the initial design were bad - proper lvalue implementation
But that is only 6 months? Then you have come quite far if you are already going for self hosting. I'm still rethinking my lexer. Hehe. Like, do I want to make keywords tokens or should they just be lexed as identifiers? I did the first, but think maybe the last is more flexible, so a rewrite... is coming. ;)
Jan 15 2021
parent reply Basile B. <b2.temp gmx.com> writes:
On Friday, 15 January 2021 at 19:40:11 UTC, Ola Fosheim Grøstad 
wrote:
 On Friday, 15 January 2021 at 19:18:09 UTC, Basile B. wrote:
 I plan to use dparse for the most part, not only to convert 
 but also to detect non bootstrapable code or missing features.
Ah, smart. I've been thinking about using an existing d-parser to convert unit tests from D to my Dex syntax (experimental project). Modifying the compiler is fun, but writing unit tests is not...
 This is a noble reason. Styx has no such motivations. It is 
 simpler than D1 for example and has no killer feature,
What made D1 attractive to many C++ programmers was that it was stripped down. Also, many language designers get tempted to add many features that are hollow, then they regret it and rip it all out again (lots of wasted effort and source code). So, being very restrictive and patient is a good thing, I believe. The truly good ideas takes time to "grow" (in ones mind).
 just 3 or 4 creative things are
 - optional break/continue expression
 - explicit overloads
 - DotExpression aliases (they have been proposed to DMD this 
 summer when I worked "under cover" as Nils.)
 - pointers to member function is very different from what I 
 have seen so far (no fat pointer)
"Nils" is a very scandinavian name? :-)
Yeah, in addition to my real name, I've been invovled in dmd as "Nils Lankila" and "Stian Gulpen" which are names generated using specialized services. You can choose to have a swedish name for example.
Jan 18 2021
parent reply Basile B. <b2.temp gmx.com> writes:
On Monday, 18 January 2021 at 17:45:16 UTC, Basile B. wrote:
 On Friday, 15 January 2021 at 19:40:11 UTC, Ola Fosheim Grøstad 
 wrote:
 [...]
Yeah, in addition to my real name, I've been invovled in dmd as "Nils Lankila" and "Stian Gulpen" which are names generated using specialized services. You can choose to have a swedish name for example.
on the internet nobody knows you're a dog ;)
Jan 18 2021
parent reply Basile B. <b2.temp gmx.com> writes:
On Monday, 18 January 2021 at 17:51:16 UTC, Basile B. wrote:
 On Monday, 18 January 2021 at 17:45:16 UTC, Basile B. wrote:
 On Friday, 15 January 2021 at 19:40:11 UTC, Ola Fosheim 
 Grøstad wrote:
 [...]
Yeah, in addition to my real name, I've been invovled in dmd as "Nils Lankila" and "Stian Gulpen" which are names generated using specialized services. You can choose to have a swedish name for example.
on the internet nobody knows you're a dog ;)
https://de.fakenamegenerator.com/
Jan 18 2021
parent Ola Fosheim Grostad <ola.fosheim.grostad gmail.com> writes:
On Monday, 18 January 2021 at 17:58:22 UTC, Basile B. wrote:
 On Monday, 18 January 2021 at 17:51:16 UTC, Basile B. wrote:
 on the internet nobody knows you're a dog ;)
https://de.fakenamegenerator.com/
Awww... And here I thought you were a fellow Norwegian... But I guess a dog is ok too.
Jan 19 2021
prev sibling parent reply Max Haughton <maxhaton gmail.com> writes:
On Friday, 15 January 2021 at 19:18:09 UTC, Basile B. wrote:
 On Friday, 15 January 2021 at 09:54:59 UTC, Ola Fosheim Grøstad 
 wrote:
 [...]
self-hosting is not started yet, maybe next month, classes are still to be implemented. I plan to use dparse for the most part, not only to convert but also to detect non bootstrapable code or missing features. Then, feature freeze, convert, catch and fix bugs as they will appear when feading the compiler with real food. [...]
Thoughts on libfirm? I am thinking about writing an online book about compiler backends so I'm curious what it's like to work with.
Jan 19 2021
parent Basile B. <b2.temp gmx.com> writes:
On Tuesday, 19 January 2021 at 12:50:40 UTC, Max Haughton wrote:
 On Friday, 15 January 2021 at 19:18:09 UTC, Basile B. wrote:
 On Friday, 15 January 2021 at 09:54:59 UTC, Ola Fosheim 
 Grøstad wrote:
 [...]
self-hosting is not started yet, maybe next month, classes are still to be implemented. I plan to use dparse for the most part, not only to convert but also to detect non bootstrapable code or missing features. Then, feature freeze, convert, catch and fix bugs as they will appear when feading the compiler with real food. [...]
Thoughts on libfirm? I am thinking about writing an online book about compiler backends so I'm curious what it's like to work with.
There is this small wiki page https://proglangdesign.net/wiki/firm written by myself, so I have not much to add, as I've dropped FIRM at the very beginning of the backend exprimentation.
Jan 19 2021
prev sibling parent reply Basile B. <b2.temp gmx.com> writes:
On Friday, 15 January 2021 at 09:54:59 UTC, Ola Fosheim Grøstad 
wrote:
 On Thursday, 14 January 2021 at 17:51:51 UTC, Basile B. wrote:
 This is the last[1] occasion to speak about a programming 
 language initiatly made in D, as the bootstrap phase is very 
 near.
Interesting project! How did you move from D to Styx? (I assume bootstrapping means a self hosting compiler?) Did you write some scripts to translate?
It turns out that finally everything was translated manually. This was a bit painful but also an opportunity to review older parts and to change a details that otherwise would not have been done.
Jan 16 2022
parent reply Brian Callahan <bcallah openbsd.org> writes:
On Sunday, 16 January 2022 at 17:09:07 UTC, Basile B. wrote:
 On Friday, 15 January 2021 at 09:54:59 UTC, Ola Fosheim Grøstad 
 wrote:
 On Thursday, 14 January 2021 at 17:51:51 UTC, Basile B. wrote:
 This is the last[1] occasion to speak about a programming 
 language initiatly made in D, as the bootstrap phase is very 
 near.
Interesting project! How did you move from D to Styx? (I assume bootstrapping means a self hosting compiler?) Did you write some scripts to translate?
It turns out that finally everything was translated manually. This was a bit painful but also an opportunity to review older parts and to change a details that otherwise would not have been done.
Interesting language. I was able to make a quick port to OpenBSD; works fine there too. Thanks for your work on this! ~Brian
Jan 16 2022
parent reply Basile B. <b2.temp gmx.com> writes:
On Sunday, 16 January 2022 at 18:53:45 UTC, Brian Callahan wrote:
 I was able to make a quick port to OpenBSD; works fine there 
 too. Thanks for your work on this!

 ~Brian
holly s**t ! I'm a bit surprised that it works, especially because of the way linking is done.
Jan 16 2022
parent Brian Callahan <bcallah openbsd.org> writes:
On Sunday, 16 January 2022 at 19:40:33 UTC, Basile B. wrote:
 On Sunday, 16 January 2022 at 18:53:45 UTC, Brian Callahan 
 wrote:
 I was able to make a quick port to OpenBSD; works fine there 
 too. Thanks for your work on this!

 ~Brian
holly s**t ! I'm a bit surprised that it works, especially because of the way linking is done.
That's the only thing the port needs. You just have to teach the styx compiler how to link things on OpenBSD. It's incredibly straightforward :) ~Brian
Jan 16 2022
prev sibling parent reply IGotD- <nise nise.com> writes:
On Thursday, 14 January 2021 at 17:51:51 UTC, Basile B. wrote:
 This is the last[1] occasion to speak about a programming 
 language initiatly made in D, as the bootstrap phase is very 
 near.

 I'd like to thank the D compiler developers, that let me work 
 on DMD even if I borrow another path.

 [1] : https://gitlab.com/styx-lang/styx
Interesting project. A few questions. I see that you use "var auto name" in order to automatically infer the type. Would it be possible just using "var name" for that, similar to other popular languages. There is currently no information about memory management, is this something you have an idea how to design right now?
Jan 18 2021
next sibling parent Basile B. <b2.temp gmx.com> writes:
On Monday, 18 January 2021 at 18:03:12 UTC, IGotD- wrote:
 On Thursday, 14 January 2021 at 17:51:51 UTC, Basile B. wrote:
 This is the last[1] occasion to speak about a programming 
 language initiatly made in D, as the bootstrap phase is very 
 near.

 I'd like to thank the D compiler developers, that let me work 
 on DMD even if I borrow another path.

 [1] : https://gitlab.com/styx-lang/styx
Interesting project. A few questions. I see that you use "var auto name" in order to automatically infer the type. Would it be possible just using "var name" for that, similar to other popular languages. There is currently no information about memory management, is this something you have an idea how to design right now?
yes, it would be possible, but it wont be done. In Styx "auto" is a type joker and that's it.
Jan 18 2021
prev sibling parent Basile B. <b2.temp gmx.com> writes:
On Monday, 18 January 2021 at 18:03:12 UTC, IGotD- wrote:
 On Thursday, 14 January 2021 at 17:51:51 UTC, Basile B. wrote:
 This is the last[1] occasion to speak about a programming 
 language initiatly made in D, as the bootstrap phase is very 
 near.

 I'd like to thank the D compiler developers, that let me work 
 on DMD even if I borrow another path.

 [1] : https://gitlab.com/styx-lang/styx
Interesting project. A few questions. I see that you use "var auto name" in order to automatically infer the type. Would it be possible just using "var name" for that, similar to other popular languages. There is currently no information about memory management, is this something you have an idea how to design right now?
It has a memory management system very comparable to older Delphi (<= 2007) or current FreePascal. So dynamic arrays are reference counted and automatically managed when used a local var. Classes and structures are manually managed but the dtor is automatically called when the instance is a local. This system is proven to work as the compiler itself is now rewritten in styx. (example, the valgrind report after running the compiler with the equivalent of D "-unittest" CLI option : https://gitlab.com/styx-lang/styx/-/jobs/1980055910#L110. To be honest I already knew it will work before implementing ref counting. This has been used for something like 30 years by hundreds and hundreds of programmers.
Jan 16 2022