4 ms·
This kind of stuff is why I'm glad that the brogrammer fad of "ergonomic" c library interfaces with heavily variadic function signatures has died down a bit. Y
by monocasa 7y ago
This kind of stuff is why I'm glad that the brogrammer fad of "ergonomic" c library interfaces with heavily variadic function signatures has died down a bit.
You need either a static type system, or a runtime that'll catch weird accesses and throw immediately. A dynamic but happy to corrupt memory interface boundary is just crazy town.
- DoofusOfDeath 7y agoWhat does "brogrammer" mean, in this usage?
- monocasa 7y agoA pejorative for "I can't let any types or anything get in the way of my productivity as I crush some mad code, braugh" types.
- flafla2 7y ago> I can't let any types or anything get in the way of my productivity Okay, sure. > ...as I crush some mad code, braugh What? I've never run into this. How does this have anything to do with opinions on types again? It sounds like you have an axe to grind.
- optimuspaul 7y agolol, I'd say it is definitely an overgeneralization, but I've seen the culture they are referring to and it is very real and very irritating to deal with the messes they create. Don't read too much into it.
- daveFNbuck 7y agoThis is pretty close to what you'll see in the first paragraph of the Wikipedia article on brogrammer [1]. Klout posted an advertisement at the Stanford career fair saying "Want to bro down and crush some code? Klout is hiring." [1] https://en.wikipedia.org/wiki/Brogrammer https://en.wikipedia.org/wiki/Brogrammer
- monocasa 7y agoHahaha, omg. > The company later described it as a joke and as an unfortunate misstep. "It's just a joke, bro"
- anonova 7y agoI was looking for a small image processing library (as opposed to libMagickWand) and came across libvips [1]. I found it absolutely bizarre that the public API in a C library was full of variadic functions to support optional arguments. The last argument to most function calls is required to be NULL to denote the end of the argument list, e.g., https://libvips.github.io/libvips/API/current/using-from-c.html#using-C-example https://libvips.github.io/libvips/API/current/using-from-c.h... (vips_image_new_from_file, vips_invert, etc.). [1]: https://libvips.github.io/libvips/ https://libvips.github.io/libvips/
- zlynx 7y agoA fun one relating to 64-bit and NULL in varargs: If your system defines NULL as 0, which is legal in C++, then NULL in the vararg list only pushes an int-sized (4 bytes) zero, and the vararg reader pulls a pointer-sized (8 bytes) value, which may or may NOT equal zero because of the 4 extra bytes...
- liuliu 7y agoYeah, that is unfortunate. Even if you want to do that (in C, the correct way, of course, is to name them differently), should use macro to select correct function prototype to dispatch to, that still enables type checking and avoid the variadic function non-sense. Variadic function is pure evil (seriously, who can remember these random rules that in variadic function, a char will be promoted to int and a float will be promoted to double ...)
- malkia 7y agoWas it Motif, or some other UI system back in the day over-using this technique... There was time when I thought it was good idea, but rejected it for other reasons - no easy way to pass-through arguments (unless you've provided for va_list function beforehand, or use some trampoline hacks). But then the overall safeness... yet people to this day (me included) use "printf" - it's like beer & cigaretes - it's bad, but comfortable, and sexy :)
- alfalfasprout 7y agoI always cringe when I encounter this since there are often far better workarounds. Static analysis tools can't really catch issues with these variadic interfaces easily either.