1. 52
  1.  

  2. 44

    Yeah, if you look at the implementation this is exactly the sort of neat technical content I like to see on Lobsters.

    Dare I say…based?

    Edit: it is variaidic string interpolation, but in C with macros. How is that not neat?

    1. 9

      It is neat, definitely some of the craziest C macro code I’ve seen. But it also makes me happy I have Rust.

      1. 6

        Agreed! Still, a neat contraption to have in your back pocket for party tricks. :)

        1. 5

          It makes me happy I have C++.

          Weird, that people will create abstruse hacks rather than make use of what’s already available to them. I mean, just by changing the suffix of the source file to “.cpp” they could pick and choose from strings, dynamic arrays, and all sorts of other functionality.

          I could make a strained analogy with male fragility of the sort implied by the “chad” meme, but I’m still too sleepy this morning :)

          1. 7

            I get all of this behavior from the standard String in Ada and it might not even allocate.

            1. 3

              There’s definitely a place for abstruse hacks, because they’re cool and they demonstrate the power of a language to do things. That’s e.g. the whole point of demoscene, as I understand.

              I only did a bit of C in university, so I didn’t even know there were things like cleanup attributes. I think this is pretty neat.

              1. 2

                The cleanup attribute seems pretty obscure — I’ve seen it in the Clang attribute list (yes, I have read all the way through that!) but never encountered any code using it. Maybe because it’s only supported by Clang and GCC.

                1. 3

                  I’ve used it in pretty much every C codebase I’ve written. The only way of using locks that I’ve found in C is to define macros that use __attribute__((cleanup)) to handle releasing the lock.

                  It’s also the only way of making C code exception safe. If you compile with -fexceptions, __attribute__((cleanup)) cleanup functions are run even during stack unwinding. For example, Objective-C has a magic +initialize method that has some quite interesting semantics: it is called the first time a message is sent to a class (or instance of that class if you allocate an instance without sending a message to the class) and execution of that method is guaranteed to complete before any other threads can send a message to that class. The code in the GNUstep Objective-C runtime to do this is written in C and has to handle the fun corner case where the +initialize method throws an exception. It uses __attribute__((cleanup)) to release locks and reset the class into the ‘initialize has completed’ state if an exception is thrown.

                  It’s also one of those features that eventually makes you realise that you’re implementing a fragile and less safe version of C++ in C and that you probably want to just write C++ code.

                  1. 2

                    Yeah, that would be very useful. Some of the code I own has C APIs, and I’ll look at using this.

                    I assume there’s no MSVC support, though? Since MS doesn’t even support C99.

                    1. 1

                      Not an exact equivalent, but I think the __finally keyword for SEH serves roughly the same purpose.

                  2. 2

                    It’s used extensively in systemd.

                    1. 1

                      It’s pushed by the documentation of recent versions of GLib, along with utility macros to define cleanup actions for your own data types.

              2. 2

                It reminds me of void.h.

              3. 21

                Please don’t bring this toxicity over to lobste.rs. Let it live and die on the orange site.

                1. 19

                  I’ve had a few interesting discussions about our tribal and memetic expectations as exemplified by this repository. Sometimes, when somebody does something unbearably cringy in the name of what they think is supremely excellent taste, it is an opportunity to delve deeper into their implicit beliefs.

                  Nowhere in this repository is it ever imagined that C is not an appropriate language for today’s coders. Rather, the machismo which is required to write fresh C code against an ever-steeper gradient of better toolchains for higher-level languages is also the same machismo which is stoked by the underlying family of memes used to theme and decorate the repository.

                  Sometimes a project’s only purpose is to serve as a warning to others. Even in those moments, let us learn something from the precise nature of the warning.

                  1. 22

                    Can you define what you mean by ‘toxicity’? I don’t see anything ‘toxic’ in this repository.

                    1. 5

                      I don’t like the way its naming and meming relies on using virgin man vs not as a shorthand for bad vs not, however ironically.

                      It’s a cool trick. Why couple it with a bad meme?

                      1. 19

                        The meme is incredibly funny, that’s why.

                    2. 21

                      Toxicity? Orange site? I didn’t get any of that.

                      I could agree that the theming is a little overboard, not because of bad taste, but because it detracts from the technical side, as speps said.

                      Code needs to market itself, and it seems “skullchap” had some fun in that department.

                      1. 11

                        It seems interesting from a technical perspective but I agree on the bad taste aspect, it detracts from the technical side.

                        1. 8

                          I think we need a new flag, because this isn’t really spam or off-topic: I suggest “bad taste” ;)

                          1. 27

                            The best way to deal with content that’s on-topic but otherwise not very valuable is simply to ignore it.

                            A comment, btw, counts as an upvote, at least as far as visibility on the front page is concerned.

                            1. 16

                              Or maybe some more tags. “based” and “redpilled” come to mind :-D

                              Alright, I’ll see myself out.

                              1. 5

                                Agreed. I marked it off-topic. Whatever your taste or politics, this repository was built simply “for the lulz”. It’s not tech, it’s a social experiment with code.

                                While there are many social topics in the tech world, that’s generally not what lobste.rs is good for.

                                1. 53

                                  It’s tech, you and others just seem to be distressed by the cultural shibboleths it touches.

                                  We have articles here that are dripping with furry stuff that are routinely defended from fursecution…a mainstream meme plus cool hack isn’t outside our Overton window for me.

                                  1. 10

                                    Labeling something “toxic” with the intent of banning it is as much of a cultural shibboleth as any of the memes in the article.

                                    1. 4

                                      The furry stuff is a positive expression of someone’s own personal identity, while the chad/virgin meme is a ridiculous objectification of others for being ingroup/outgroup. Do you see a difference?

                                      1. 4

                                        Yeah, what’s up with all the furry stuff?

                                      2. 13

                                        this repository was built simply “for the lulz”. It’s not tech,

                                        It’s not? I’m confused. I haven’t tried compiling it, but there’s a C file in there with a bunch of complex-looking code in it. Does that count as tech?

                                        I don’t know if anyone would use this library for reals (I sure hope not), but the same goes for stuff like Brainfuck or (IMHO) a 6502 assembler. There’s a lot of stuff posted here that is, at some level, done for teh lulz.

                                        1. 8

                                          this repository was built simply “for the lulz”. It’s not tech, it’s a social experiment with code.

                                          A lot of software is written “just because” or “for the lulz”. A lot of good software is even written for this express purpose— Linux started out as a hobby project, no?

                                          I also don’t see what makes this a social experiment. What’s the experiment? The readme being silly? Is that an experiment?

                                          1. 4

                                            Linus Torvalds biography is called “Just for fun”, because that is why he wrote Linux. That is how older people say “for the lulz”. Is Linux now also off-topic?

                                            There is some actual C macro (ab-)use in there, that is interesting to look at. It is def. tech.

                                            Why are you so triggered by this stupid meme?

                                        2. 6

                                          The shitposting C chad versus the virgin crustacean.

                                        3. 1

                                          After writing my own string handlers and slowly losing sanity, this looks super neat. Definitely gonna try it out.