Jump to page: 1 2
Thread overview
I've made a language! \o/ Introducing Neat
Sep 18, 2022
FeepingCreature
Sep 19, 2022
Tejas
Sep 19, 2022
FeepingCreature
Sep 19, 2022
Max Samukha
Sep 19, 2022
React
Sep 20, 2022
FeepingCreature
Sep 19, 2022
Abdulhaq
Sep 19, 2022
Daniel N
Sep 19, 2022
Dukc
Sep 21, 2022
Quirin Schroll
Sep 22, 2022
FeepingCreature
September 18, 2022

Alright, since I've ran out of critical issues on my TODO, here's Neat!

https://neat-lang.github.io/

https://github.com/neat-lang/neat

The syntax will seem very familiar to people here. :) It's sort of like D1 circa 2003 but with macros instead of CTFE and a very underpowered template engine. Note that while all the features I want are in there, some (such as templates) are only 10% there. Still, it's usable as it stands, and it's self-hosting.

The biggest divergences to D are probably that it's reference-counted rather than GC, the macro support, and variables being (head) immutable and unreferenceable by default.

It also has built-in: tuple types, sumtypes with implicit conversion, named parameters and format strings. But D will have all of those eventually. (Any year now...!!) So how about I show you something cool that will probably never be in D:

How do you encode two structs to JSON?

module test;

macro import std.json.macro;
macro import std.macro.assert;

import std.json;

struct B {
    A first, second;
}

struct A {
    int v;
}

JSONValue encode(B b) {
    return JSONValue({
        "first": encode(b.first),
        "second": encode(b.second)
    });
}

JSONValue encode(A a) {
    return JSONValue({ "v": a.v });
}

void main() {
    assert(encode(B(A(2), A(3))) == JSONValue({
      "first": {"v": 2},
      "second": {"v": 3}
    }));
}

"So you have hashmap literal syntax, like D?" No, I don't. Look again. The parameter passed to JSONValue is a genuine JSON expression, with embedded Neat expressions. No JSONValue() spam required. If it were XMLValue, it could just as easily be XMLValue(<tag attribute=$variable>$(encode(body))</tag>).

Macros, fuck yes!

September 18, 2022

On Sunday, 18 September 2022 at 20:28:58 UTC, FeepingCreature wrote:

>

Alright, since I've ran out of critical issues on my TODO, here's Neat!

Congratulations! This sounds like a fun project!

September 19, 2022

On Sunday, 18 September 2022 at 20:28:58 UTC, FeepingCreature wrote:

>

Alright, since I've ran out of critical issues on my TODO, here's Neat!

[...]

Looks pretty... Neat

💨

September 19, 2022

On Monday, 19 September 2022 at 04:54:38 UTC, Tejas wrote:

>

On Sunday, 18 September 2022 at 20:28:58 UTC, FeepingCreature wrote:

>

Alright, since I've ran out of critical issues on my TODO, here's Neat!

[...]

Looks pretty... Neat

💨

Thank you! ♥

September 19, 2022

On Sunday, 18 September 2022 at 20:28:58 UTC, FeepingCreature wrote:

>
return JSONValue({
    "first": encode(b.first),
    "second": encode(b.second)
});

}

Too easy. Programmers should live in pain, and their evil intentions should be exposed. What about __evil(JSONValue(q{{...}}))?

September 19, 2022

On Sunday, 18 September 2022 at 20:28:58 UTC, FeepingCreature wrote:

>

Alright, since I've ran out of critical issues on my TODO, here's Neat!

https://neat-lang.github.io/

https://github.com/neat-lang/neat

Nice!

I hope that the underscores instead of spaces are just a rendering issue.

September 19, 2022

On Sunday, 18 September 2022 at 20:28:58 UTC, FeepingCreature wrote:

>

Alright, since I've ran out of critical issues on my TODO, here's Neat!

https://neat-lang.github.io/

https://github.com/neat-lang/neat

The syntax will seem very familiar to people here. :) It's sort of like D1 circa 2003 but with macros instead of CTFE and a very underpowered template engine. Note that while all the features I want are in there, some (such as templates) are only 10% there. Still, it's usable as it stands, and it's self-hosting.

The biggest divergences to D are probably that it's reference-counted rather than GC, the macro support, and variables being (head) immutable and unreferenceable by default.

It also has built-in: tuple types, sumtypes with implicit conversion, named parameters and format strings. But D will have all of those eventually. (Any year now...!!) So how about I show you something cool that will probably never be in D:

Very interesting :-) and congratulations on getting this far. Can you tell me what is a macro in this context, I'm not getting it from the code?

September 19, 2022

On Sunday, 18 September 2022 at 20:28:58 UTC, FeepingCreature wrote:

>

Alright, since I've ran out of critical issues on my TODO, here's Neat!

https://neat-lang.github.io/

https://github.com/neat-lang/neat

Finally a language that "gets it". Impressive.

September 19, 2022

On Sunday, 18 September 2022 at 20:28:58 UTC, FeepingCreature wrote:

>

It also has built-in: tuple types, sumtypes with implicit conversion, named parameters and format strings. But D will have all of those eventually. (Any year now...!!)

The definitely do look epic, and I'd be happy to have them in D. Though I do prefer int[4] to (int, int, int, int) that I think I saw somewhere (hopefully they will be the one and the same someday!).

September 20, 2022

On Monday, 19 September 2022 at 15:31:03 UTC, React wrote:

>

On Sunday, 18 September 2022 at 20:28:58 UTC, FeepingCreature wrote:

>

Alright, since I've ran out of critical issues on my TODO, here's Neat!

https://neat-lang.github.io/

https://github.com/neat-lang/neat

Nice!

I hope that the underscores instead of spaces are just a rendering issue.

Yes, it's an issue with the dark mode rendering of Sphinx's RTD theme. I have no idea how to fix that, so patches welcome.

On Monday, 19 September 2022 at 16:20:38 UTC, Abdulhaq wrote:

>

Very interesting :-) and congratulations on getting this far. Can you tell me what is a macro in this context, I'm not getting it from the code?

Basically, there's locations in the compiler that allow hooks to be loaded. There's a syntax construct that tells the compiler, "stop what you're doing, and instead of compiling for the target platform, compile everything up to here for the current platform. Then take the function I gave you from the object you just compiled, load it with dlopen, and execute it with the module macro state object." (Or, abbreviated, macro(someFun);.) Then the function adds some object to the macro state, which changes the behavior of the compiler (via the hook system) for that module and others that import it. So it's a compiletime plugin.

On Monday, 19 September 2022 at 17:25:21 UTC, Dukc wrote:

>

The definitely do look epic, and I'd be happy to have them in D. Though I do prefer int[4] to (int, int, int, int) that I think I saw somewhere (hopefully they will be the one and the same someday!).

Yes, that is definitely a placeholder. I don't have a non-tagged union type right now, so the C import macro doesn't know what to make of them. I don't have a static-array type either, because I never use them myself. So I make do with that hack. TODO!

« First   ‹ Prev
1 2