Recent comments in /f/programming

flabberghaster wrote

The one thing i find hard about rust is that most of the programs I write for my day to day use are things that basically just call linux system calls, or use popular C libraries, things that C++ is extremely good at. Or they're things that are trivial to do in python.

So as much as I like Rust, I don't actually know how to perform a sha256sum on a file and then set an xattr for it (without shelling out or downloading a random crate).

It's little things like that that keep it from being my go-to, but it's really good and I want to use it more.

6

emma wrote

i will put down the pitchfork, for now

to reiterate what i said on the worst chat app in existence, you gotta do the TRUSTED_PROXIES=172.16.0.0/12 thing. this will make postmill accept caddy's x-forwarded-proto: https header that i'm pretty sure it sends to the backend. there is no need to edit the templates, as someone else suggested.

4

twovests wrote

I also share these feelings!

It has that same magical "power" that functional languages have. I can put expressions in places that shouldn't be possible.

Working on a toy language, I threw an expression in curly braces, i.e. for x in {...}, which returned a different iterator depending on a condition. It really helped me cut down on code re-use (which was really good for my dev experience). That "clicked" in an extremely satisfying way.

5

musou OP wrote

thanks for the helpful comments everybody. i'm writing Elixir instead of C in this case, but that just goes to show that you can have this problem in any language with macros. i remember feeling this way about some lisp code in the past, too.

1

flabberghaster wrote

OK so this is kind of a pain in the neck to do a lot of times but sometimes you can get the output if the C preprocessor.

Then through careful editing, you can kind of figure out what it's turning in to.

int main(...) {
   WEIRD_MACRO(1, 2);
}

Then you could just put comments above and below it, and run cpp -I/all/include/directories main.c

It will tell you the final output and also have debugging garbage about where each thing expanded from.

Not ideal, and also in a big project that uses a complex build tool it can be incredibly hard to get the cpp args, but it can help.

2