Codegolf sounds fun... Unfortunately, C isn't a language where you can write that sort of thing compactly...

@vaporeon_ your golfed c program will never be shorter than my golfed python program because python has less boilerplate. but your golfed c program can easily be shorter than my golfed c program

if you're comparing java to J of course it seems lopsided, but that's just not a good comparison

@monorail @vaporeon_ compilers let you get away with omitting a distressing amount of the boilerplate

@aescling Which of the boilerplate can be omitted? As far as I know, C doesn't have stuff like regular expressions, so if you could've written a compact solution using regular expressions in e.g. Perl, you couldn't have done it that way in C...

@vaporeon_ notably, includes fur much of the standard library, and type definitions for main or variables

but yeah if you need a fast little regex parser, you’re out of luck

@aescling What's distressing about it? Like, of course you can omit the includes, and there's something called "implicit int", so that you can write:

f(n) {
/* n will be integer, return will be integer, too*/
}

Except that GCC 14 will refuse to compile it...

Follow

@vaporeon_ it contradicts how i learned that C works and i’m not over that i guess

@aescling How did you learn that C works?
Also, have you ever seen K&R C? Where instead of having the types next to the variable name, you would write something like, and anything not stated otherwise would be an integer:

f(s, n)
char *s;
{
/* Do something */
return n*123;
}

@vaporeon_ i learned C++ furst when very young and i think its stricter rules on typing heavily influenced my expectations about how i thought C should work. (also the only K&R i’ve ever read is the second edition, which has the ANSI C syntax. though i am vaguely aware of the Old Syntax)

@aescling Who teaches C++, but not C, to a very young Sprigatito?

@vaporeon_ i somehow got my pawbs on a C++ book at a very young age (from the library? maybe??) because i wanted to learn how to purrogram

Sign in to participate in the conversation
📟🐱 GlitchCat

A small, community‐oriented Mastodon‐compatible Fediverse (GlitchSoc) instance managed as a joint venture between the cat and KIBI families.