I'm a big fan of my keyboard
post
I'm going to count vim, or any other IDE as a tool. You don't just will your thoughts into the computer (at least most people don't, that I know).
Relevant xkcd: https://xkcd.com/378/
Did someone say emacs? https://youtu.be/urcL86UpqZc
You could count the fucking chair as a tool. This post is dumb, lol.
Or even better, libraries of functions you've built up over time from visiting stack overflow
A really good way to evaluate an ecosystem is looking if people look into documentation or stack overflow first.
When it's stack overflow, the ecosystem always suck.
May I suggest avoiding recursive functions where possible? They are usually the ones overflowing your stack, duh.
Goto is evil.
Unless you're programming in assembly
I mean, in C too.
I used it when I wrote some throwaway C++ code working with SQLite. Since it had no RAII (and I had no intention of writing my own wrapper), I had to manually cleanup multiple resources somehow. If at least one resource failed to initialize, I had to deinitialize the ones that didn't fail. It was either goto or a bunch of flags to track what is initialized. goto looked more elegant.
I misremembered the whole thing. It was still related to cleaning up after a failure, but there was only one resource I had to deal with. That's how it looks like:
sqlite3 *db;
int r;
r = sqlite3_open("./data.db", &db);
if (r) {
std::cerr << "Can't open the database: " << sqlite3_errmsg(db) << std::endl;
return r;
}
r = sqlite3_exec(db, "CREATE TABLE IF NOT EXISTS foo(...);", nullptr, nullptr, nullptr);
if (r != SQLITE_OK) {
std::cerr << "Can't create a table called foo: " << sqlite3_errmsg(db) << std::endl;
goto out;
}
// a few more sqlite3_exec calls;
// some sqlite3_prepare_v2 calls combined with sqlite3_bind_* and sqlite3_step calls
// for repeated queries.
out:
sqlite3_close(db);
return r;
goto in assembly? nah, might as well JMP
all 31 comments