C++
@wallhackio don’t worry, no matter how much C++ you understand and enjoy, there will always be other C++ you don’t understand and hate
re: baldur's gate 3, minor spoilers
@wallhackio @alyssa oh i missed the word “also”, you can only get one
re: baldur's gate 3, minor spoilers
@wallhackio @alyssa bg3 wiki says “This statue costs 5,000 gold, and depicts whichever character is speaking to Boney when the purchase is made.” is the conversation locked to the protag or???
@jamey regarding using [0] and not &: this is a stylistic quirk i’ve picked up from Modern C, which takes the opinion that you should always use arrays when you know the pointer is not nullptr, and avoid & whenever possible. this definitely goes against existing practice but at this point i’m kind of inclined to agree? what you conceptually are doing with getline is passing in arrays with one slot each and it’s overwriting that slot. that’s just not how people usually write it.
regarding hardcoding, agreed. honestly i forgot about C23 constexpr while writing this code, and i think it could be cleaned up a fair bit by using it. i may try taking a stab at this.
regarding the indentation, i think that’s actually a bug in gitweb’s syntax highlighting :P
do you have any advice on naming global constants or struct members? this is probably one of the stylistic things i’m least certain about haha
@jamey the short version is i am trying to write a replacement for Gitweb (which i use, written in Perl) and Cgit (which i find aesthetically displeasing, written in C), which is to say, a CGI frontend for a directory of Git repositories. i’m doing this because i want something more configurable and don’t want to learn Perl, and i’m doing it in C because i want to get better at C and Cgit has already proven it’s possible.
so this commit is adding some code to process a path, provided to the CGI script, into a struct which represents its semantics. there aren’t any standards for this, but there is broad consensus on a format of `project/verb/base..target/subpath`. i’ve chosen some verbs that i’m planning to implement, like “log” and “show”.
because there is some flexibility in syntax, and to test the implementation, i’ve also written a serializer to get the canonical form of a path given the struct. the test code reads in a path from stdin, process it to a struct, and then serializes it back out. (it actually does this twice to confirm it is idempotent.) there is existing test infrastructure (in `sh/test.sh`) to compare the output of this program against the expected outputs and report errors.
so this is a very early step to enable me to start receiving and responding to requests over CGI, none of which is implemented yet.
in terms of code review, this is the first significant piece of C i’ve written in a long while, and i haven’t read that much C code either, so it’s kind of a shot in the dark. i’d be interested if there is anything significantly stylistically off, or if i am shirking best practices without good reason.
anybody good at C want to review this implementation <https://git.ladys.computer/CGirls>
@aescling “maybe ten kilobytes” might be wrong; i think i got this somehow but now i’m not reproducing it??
@aescling (i’m using git’s Makefiles as a base and apparently they do not believe in LTO by default)
@aescling *maybe ten kilobytes if you do -flto while building git as well
@aescling for the record this was without link‐time optimization; if you add -flto the size drops to just under one megabyte
@monorail @aescling @wallhackio this is definitely showing the areas where i spend my time but to me, i write a lot of HTML and XML and Makefile and parsers for various other formats. and like, HTML parsing is a mess. Makefile parsing is full of weird quirks. XML is better than the other two but still nontrivial in a lot of ways. and obviously all of these are very different. but i think the general lesson is “computers have a certain methodology for processing what you write, and you have to understand that methodology in order to communicate meaningfully with them”.
i think with a lot of programming languages, people never learn this lesson. 99% of javascript programmers have no idea how the computer processes a javascript program, because they learn a few rules of thumb on how to write it, and assume that if they follow those rules, the computer can read it the same as a human can.
with shell, this is not the case. you absolutely have to learn the lesson that computers do not know how to read, at least not the way humans approach reading. and yes, the particularities of that are very specific. but i think learning how to learn the very specific particularities of a language and apply them consistently is the lesson here, and a good thing to teach. and shell scripts are a simple enough language that the entire format could conceivably be taught in the context of a single course.
@aescling @monorail @wallhackio if you are in a class size of greater than 40 you are probably better off learning from the internet
@aescling @monorail @wallhackio i am assuming an education system where professors have manageable class sizes otherwise the question is meaningless
@monorail @aescling @wallhackio i don't see footguns like this as a bad thing in a teaching language tho, where you are having a professor review every line you write. in fact, having an expert review every line you write is probably one of the easier ways to learn shell
is shell knowledge transferrable to other languages? i agree that the answer there is mostly no, but i think it’s an open question whether the goal of an introductory programming course is to teach transferable programming skills, or just to teach the social aspect of thinking about and writing programs.
@aescling @wallhackio i’m not sure teaching “computers have to tokenize your code before they can read it” is a bad thing necessarily
@aescling @wallhackio hmmm
@wallhackio @aescling the nspire had a full word processor in it tho so i spent a ton of time writing fanfic
@wallhackio @aescling i had an nspire eventually and spent a lot of time programming text based adventures into it but it was less good than the TI-84 where i made Space Invaders
Administrator / Public Relations for GlitchCat. Not actually glitchy, nor a cat. I wrote the rules for this instance.
“Constitutionally incapable of not going hard” — @aescling
“Fedi Cassandra” – @Satsuma
I HAVE EXPERIENCE IN THINGS. YOU CAN JUST @ ME.
I work for a library but I post about Zelda fanfiction.