home.social

Search

1000 results for “KoPPeR”

  1. @kopper

    as the basis of the language, modern c by jans gustedt[1] is great – if you already know the basics of c, skimming it works nicely

    in general i’m not exactly sure what parts to focus on since it’s more like, a lot of small things, than a few big ones – so i’ll write down a few that come to mind, and feel free to ask about those or anything else

    imo modern tooling and good api design are the best points of writing modern c

    gcc’s -fanalyzer or clang’s -analyze, runtime debug tooling like asan or ubsan (-fsanitize=address, -fsanitize=bounds), valgrind, etc

    if you’re writing for posix, there’s plenty of newer apis that help making tasks less painful, getline, asprintf, are two i end up using a lot

    do avoid inventing syntax with macros that are hard to read, and apis that are hard to follow the flow, think about memory ownership when designing apis

    i usually avoid opaque structs with getters and setters, making structs public is not as big of a deal as most people say

    i also usually try to structure my code in the most self-documenting way i can, e.g. i like doing void foo(size_t count, int some_array[static count]); over void foo(int *some_array, size_t count); – both tooling and developers can make use of the self-documenting syntax

    here’s a bit of a showcase about bounds safety: https://uecker.codeberg.page/2025-07-09.html

    c11’s _Generic and anonymous structures are great, the latter specifically makes writing tagged unions a lot simpler:

    struct foo {
        enum {
            FOO_NYA,
            FOO_MEW,
            FOO_BOOP,
        } type;
        union {
            struct nya nya;
            struct mew mew;
            struct boop boop;
        };
    };
    

    switch on foo.type, and then access foo.nya, foo.mew, or foo.boop

    designated initializers are great, use them, for the example above you could do:

    struct foo foo = {
        .type = FOO_NYA,
        .nya = nya_default(),
    };
    

    c23 adds [[deprecated(reason)]], and you can use it to emulate private fields in structs if you want, by going

    #ifndef MY_LIB
    #    define my_lib_private [[deprecated("private field")]]
    #endif
    

    defer is getting a proper technical specification soon, which means a published official spec and if implementation experience with the spec goes well, then it’ll be part of the next C standard – the latest clang release already implements defer (under -fdefer-ts), i did implement defer for gcc, though my patches are still only floating in the mailing list

    a few up-and-coming features past defer, there’s papers on an _Optional qualifier that marks pointers as nullable or not

    things like if-declarations (if (int err = some_func()) { return err; }), named loops, and switch ranges, were already accepted, iirc

    1: https://www.manning.com/books/modern-c-third-edition (you can read it for free on the bottom of the page)

  2. @kopper

    as the basis of the language, modern c by jans gustedt[1] is great – if you already know the basics of c, skimming it works nicely

    in general i’m not exactly sure what parts to focus on since it’s more like, a lot of small things, than a few big ones – so i’ll write down a few that come to mind, and feel free to ask about those or anything else

    imo modern tooling and good api design are the best points of writing modern c

    gcc’s -fanalyzer or clang’s -analyze, runtime debug tooling like asan or ubsan (-fsanitize=address, -fsanitize=bounds), valgrind, etc

    if you’re writing for posix, there’s plenty of newer apis that help making tasks less painful, getline, asprintf, are two i end up using a lot

    do avoid inventing syntax with macros that are hard to read, and apis that are hard to follow the flow, think about memory ownership when designing apis

    i usually avoid opaque structs with getters and setters, making structs public is not as big of a deal as most people say

    i also usually try to structure my code in the most self-documenting way i can, e.g. i like doing void foo(size_t count, int some_array[static count]); over void foo(int *some_array, size_t count); – both tooling and developers can make use of the self-documenting syntax

    here’s a bit of a showcase about bounds safety: https://uecker.codeberg.page/2025-07-09.html

    c11’s _Generic and anonymous structures are great, the latter specifically makes writing tagged unions a lot simpler:

    struct foo {
        enum {
            FOO_NYA,
            FOO_MEW,
            FOO_BOOP,
        } type;
        union {
            struct nya nya;
            struct mew mew;
            struct boop boop;
        };
    };
    

    switch on foo.type, and then access foo.nya, foo.mew, or foo.boop

    designated initializers are great, use them, for the example above you could do:

    struct foo foo = {
        .type = FOO_NYA,
        .nya = nya_default(),
    };
    

    c23 adds [[deprecated(reason)]], and you can use it to emulate private fields in structs if you want, by going

    #ifndef MY_LIB
    #    define my_lib_private [[deprecated("private field")]]
    #endif
    

    defer is getting a proper technical specification soon, which means a published official spec and if implementation experience with the spec goes well, then it’ll be part of the next C standard – the latest clang release already implements defer (under -fdefer-ts), i did implement defer for gcc, though my patches are still only floating in the mailing list

    a few up-and-coming features past defer, there’s papers on an _Optional qualifier that marks pointers as nullable or not

    things like if-declarations (if (int err = some_func()) { return err; }), named loops, and switch ranges, were already accepted, iirc

    1: https://www.manning.com/books/modern-c-third-edition (you can read it for free on the bottom of the page)

  3. @kopper

    as the basis of the language, modern c by jans gustedt[1] is great – if you already know the basics of c, skimming it works nicely

    in general i’m not exactly sure what parts to focus on since it’s more like, a lot of small things, than a few big ones – so i’ll write down a few that come to mind, and feel free to ask about those or anything else

    imo modern tooling and good api design are the best points of writing modern c

    gcc’s -fanalyzer or clang’s -analyze, runtime debug tooling like asan or ubsan (-fsanitize=address, -fsanitize=bounds), valgrind, etc

    if you’re writing for posix, there’s plenty of newer apis that help making tasks less painful, getline, asprintf, are two i end up using a lot

    do avoid inventing syntax with macros that are hard to read, and apis that are hard to follow the flow, think about memory ownership when designing apis

    i usually avoid opaque structs with getters and setters, making structs public is not as big of a deal as most people say

    i also usually try to structure my code in the most self-documenting way i can, e.g. i like doing void foo(size_t count, int some_array[static count]); over void foo(int *some_array, size_t count); – both tooling and developers can make use of the self-documenting syntax

    here’s a bit of a showcase about bounds safety: https://uecker.codeberg.page/2025-07-09.html

    c11’s _Generic and anonymous structures are great, the latter specifically makes writing tagged unions a lot simpler:

    struct foo {
        enum {
            FOO_NYA,
            FOO_MEW,
            FOO_BOOP,
        } type;
        union {
            struct nya nya;
            struct mew mew;
            struct boop boop;
        };
    };
    

    switch on foo.type, and then access foo.nya, foo.mew, or foo.boop

    designated initializers are great, use them, for the example above you could do:

    struct foo foo = {
        .type = FOO_NYA,
        .nya = nya_default(),
    };
    

    c23 adds [[deprecated(reason)]], and you can use it to emulate private fields in structs if you want, by going

    #ifndef MY_LIB
    #    define my_lib_private [[deprecated("private field")]]
    #endif
    

    defer is getting a proper technical specification soon, which means a published official spec and if implementation experience with the spec goes well, then it’ll be part of the next C standard – the latest clang release already implements defer (under -fdefer-ts), i did implement defer for gcc, though my patches are still only floating in the mailing list

    a few up-and-coming features past defer, there’s papers on an _Optional qualifier that marks pointers as nullable or not

    things like if-declarations (if (int err = some_func()) { return err; }), named loops, and switch ranges, were already accepted, iirc

    1: https://www.manning.com/books/modern-c-third-edition (you can read it for free on the bottom of the page)

  4. @kopper

    as the basis of the language, modern c by jans gustedt[1] is great – if you already know the basics of c, skimming it works nicely

    in general i’m not exactly sure what parts to focus on since it’s more like, a lot of small things, than a few big ones – so i’ll write down a few that come to mind, and feel free to ask about those or anything else

    imo modern tooling and good api design are the best points of writing modern c

    gcc’s -fanalyzer or clang’s -analyze, runtime debug tooling like asan or ubsan (-fsanitize=address, -fsanitize=bounds), valgrind, etc

    if you’re writing for posix, there’s plenty of newer apis that help making tasks less painful, getline, asprintf, are two i end up using a lot

    do avoid inventing syntax with macros that are hard to read, and apis that are hard to follow the flow, think about memory ownership when designing apis

    i usually avoid opaque structs with getters and setters, making structs public is not as big of a deal as most people say

    i also usually try to structure my code in the most self-documenting way i can, e.g. i like doing void foo(size_t count, int some_array[static count]); over void foo(int *some_array, size_t count); – both tooling and developers can make use of the self-documenting syntax

    here’s a bit of a showcase about bounds safety: https://uecker.codeberg.page/2025-07-09.html

    c11’s _Generic and anonymous structures are great, the latter specifically makes writing tagged unions a lot simpler:

    struct foo {
        enum {
            FOO_NYA,
            FOO_MEW,
            FOO_BOOP,
        } type;
        union {
            struct nya nya;
            struct mew mew;
            struct boop boop;
        };
    };
    

    switch on foo.type, and then access foo.nya, foo.mew, or foo.boop

    designated initializers are great, use them, for the example above you could do:

    struct foo foo = {
        .type = FOO_NYA,
        .nya = nya_default(),
    };
    

    c23 adds [[deprecated(reason)]], and you can use it to emulate private fields in structs if you want, by going

    #ifndef MY_LIB
    #    define my_lib_private [[deprecated("private field")]]
    #endif
    

    defer is getting a proper technical specification soon, which means a published official spec and if implementation experience with the spec goes well, then it’ll be part of the next C standard – the latest clang release already implements defer (under -fdefer-ts), i did implement defer for gcc, though my patches are still only floating in the mailing list

    a few up-and-coming features past defer, there’s papers on an _Optional qualifier that marks pointers as nullable or not

    things like if-declarations (if (int err = some_func()) { return err; }), named loops, and switch ranges, were already accepted, iirc

    1: https://www.manning.com/books/modern-c-third-edition (you can read it for free on the bottom of the page)

  5. @kopper

    as the basis of the language, modern c by jans gustedt[1] is great – if you already know the basics of c, skimming it works nicely

    in general i’m not exactly sure what parts to focus on since it’s more like, a lot of small things, than a few big ones – so i’ll write down a few that come to mind, and feel free to ask about those or anything else

    imo modern tooling and good api design are the best points of writing modern c

    gcc’s -fanalyzer or clang’s -analyze, runtime debug tooling like asan or ubsan (-fsanitize=address, -fsanitize=bounds), valgrind, etc

    if you’re writing for posix, there’s plenty of newer apis that help making tasks less painful, getline, asprintf, are two i end up using a lot

    do avoid inventing syntax with macros that are hard to read, and apis that are hard to follow the flow, think about memory ownership when designing apis

    i usually avoid opaque structs with getters and setters, making structs public is not as big of a deal as most people say

    i also usually try to structure my code in the most self-documenting way i can, e.g. i like doing void foo(size_t count, int some_array[static count]); over void foo(int *some_array, size_t count); – both tooling and developers can make use of the self-documenting syntax

    here’s a bit of a showcase about bounds safety: https://uecker.codeberg.page/2025-07-09.html

    c11’s _Generic and anonymous structures are great, the latter specifically makes writing tagged unions a lot simpler:

    struct foo {
        enum {
            FOO_NYA,
            FOO_MEW,
            FOO_BOOP,
        } type;
        union {
            struct nya nya;
            struct mew mew;
            struct boop boop;
        };
    };
    

    switch on foo.type, and then access foo.nya, foo.mew, or foo.boop

    designated initializers are great, use them, for the example above you could do:

    struct foo foo = {
        .type = FOO_NYA,
        .nya = nya_default(),
    };
    

    c23 adds [[deprecated(reason)]], and you can use it to emulate private fields in structs if you want, by going

    #ifndef MY_LIB
    #    define my_lib_private [[deprecated("private field")]]
    #endif
    

    defer is getting a proper technical specification soon, which means a published official spec and if implementation experience with the spec goes well, then it’ll be part of the next C standard – the latest clang release already implements defer (under -fdefer-ts), i did implement defer for gcc, though my patches are still only floating in the mailing list

    a few up-and-coming features past defer, there’s papers on an _Optional qualifier that marks pointers as nullable or not

    things like if-declarations (if (int err = some_func()) { return err; }), named loops, and switch ranges, were already accepted, iirc

    1: https://www.manning.com/books/modern-c-third-edition (you can read it for free on the bottom of the page)

  6. @kopper @nelson

    This is marvelous. I wasn't aware of your project, but now I am and added it to the #ActivityPub #C2S tracking list.

    I've also lined up #Outpost for inclusion on the delightful #fediverse curated lists at delightful.coding.social

  7. @kopper @nelson

    This is marvelous. I wasn't aware of your project, but now I am and added it to the #ActivityPub #C2S tracking list.

    I've also lined up #Outpost for inclusion on the delightful #fediverse curated lists at delightful.coding.social

  8. @kopper @nelson

    This is marvelous. I wasn't aware of your project, but now I am and added it to the #ActivityPub #C2S tracking list.

    I've also lined up #Outpost for inclusion on the delightful #fediverse curated lists at delightful.coding.social

  9. @kopper @nelson

    This is marvelous. I wasn't aware of your project, but now I am and added it to the #ActivityPub #C2S tracking list.

    I've also lined up #Outpost for inclusion on the delightful #fediverse curated lists at delightful.coding.social

  10. @kopper @nelson

    This is marvelous. I wasn't aware of your project, but now I am and added it to the #ActivityPub #C2S tracking list.

    I've also lined up #Outpost for inclusion on the delightful #fediverse curated lists at delightful.coding.social

  11. @kopper did we... have the same idea?

    so the other day i was talking with a friend about how we could #Fix the #Hashtags in the #Middle #Of #Sentences problem if we just removed all of the #'s at the body of the post and moved them all to the very bottom