home.social

#badlang — Public Fediverse posts

Live and recent posts from across the Fediverse tagged #badlang, aggregated by home.social.

  1. Today I expanded on the direct to backend compiler directives:

    #emit puts the given string directly on the source code as a LinearOp
    #funattr adds function attributes to the current function
    #global puts the string into the top of the generated file
    #local puts the string into the top of the current function

    With these in place you can do things like adding linear assembly (useful to insert optimization fences or other shenanigans), hookup instrumentation, and to configure your functions as you would with a C compiler (add always_inline, force loop unrolls, put a function into a given section, etc.). I think these form a base that could work for most or all backends I can think of, so they are not limited to the current C one.

    #badlang #pldev

  2. Last #DecemberAdventure day, but work won't stop after today, have a really long trip ahead still, and will celebrate new year's on the plane.

    In the meantime, I used the new `#emit` directives to move all the stdlib specific code from the backend into std and added the option to compile without main to create standalone lib code that could run on any target with a crt. I also added raw string literals that extend until (and including) the newline.

    I would like to fully get rid of the need for libc, but I'm not familiar enough with macos syscalls to start writing assembly for those, would probably do that on my linux machine after I'm back home.

    #pldev #badlang

  3. Some more #DecemberAdventure work from the bus:

    - Improved codegen to avoid generating code for unused functions.
    - Added the `#if` compiler directive for conditional compilation based on a given --flag.
    - Added the `#error` compiler directive to ensure we have a way to signal a compilation error in some path (for example, unimplemented library functions for a given OS and such).
    - Added the `#emit` compiler directive to be able to generate code directly on the backend verbatim. Now #badlang is a C macro assembler lol.

    Here is everything together.

    #pldev

  4. Finally adding struct literals. Initially I was going to use a prefix to denote compoun literals, like `#Vec(x = 1, y = 2)` but I found them aesthetically unappealing.

    So alas, we overload the parenthesis syntax a bit (though I was already doing this for sum type literals anyway).

    Also going with parens instead of curly braces. Technically parens mean grouping in the language, so it's somewhat consistent with other use cases.

    #PLDev #badlang

  5. Finally adding struct literals. Initially I was going to use a prefix to denote compoun literals, like `#Vec(x = 1, y = 2)` but I found them aesthetically unappealing.

    So alas, we overload the parenthesis syntax a bit (though I was already doing this for sum type literals anyway).

    Also going with parens instead of curly braces. Technically parens mean grouping in the language, so it's somewhat consistent with other use cases.

    #PLDev #badlang

  6. Finally adding struct literals. Initially I was going to use a prefix to denote compoun literals, like `#Vec(x = 1, y = 2)` but I found them aesthetically unappealing.

    So alas, we overload the parenthesis syntax a bit (though I was already doing this for sum type literals anyway).

    Also going with parens instead of curly braces. Technically parens mean grouping in the language, so it's somewhat consistent with other use cases.

    #PLDev #badlang

  7. Finally adding struct literals. Initially I was going to use a prefix to denote compoun literals, like `#Vec(x = 1, y = 2)` but I found them aesthetically unappealing.

    So alas, we overload the parenthesis syntax a bit (though I was already doing this for sum type literals anyway).

    Also going with parens instead of curly braces. Technically parens mean grouping in the language, so it's somewhat consistent with other use cases.

    #PLDev #badlang

  8. Finally adding struct literals. Initially I was going to use a prefix to denote compoun literals, like `#Vec(x = 1, y = 2)` but I found them aesthetically unappealing.

    So alas, we overload the parenthesis syntax a bit (though I was already doing this for sum type literals anyway).

    Also going with parens instead of curly braces. Technically parens mean grouping in the language, so it's somewhat consistent with other use cases.

    #PLDev #badlang