Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

The C Paradox

Name: Anonymous 2011-08-06 14:30

If gets() is so dangerous and should never be used,

Why was it created in first place and kept in the C standard until now?

Name: Anonymous 2011-08-10 16:58

>>80
Type qualifiers are to programming languages as genital herpes are to sex. Itches, scratches and overall low-quality results.
When performance matters, they are invaluable.  Performance always matters.

uint32_t min:0 max:100 noboundschecks optimization_priority:4.9 align:best written_from:1 read_from:4 loop_index;

Name: Anonymous 2011-08-10 17:03

>>81
Seems like you want dependent types.

Name: Anonymous 2011-08-10 17:08

>>81

When performance matters on that level, you should be doing straight machine-code instead of trying to tweak the compiler guesses. And obviously after a decent profiling session. No amount of keywords will ever evaluate to any sensible, objective measurement of performance gain.

That's a reason why no one uses individual '-foptimize-whatever-fuck-trees' flags and instead use '-O3' flags, without ever profiling anything. People just say they care, but they don't really care; they're satisfied in _believing_ the compiler will get things any better in terms of performance. Keywords give them an extra self-delusional power.

For what is worth, the only keyword that matters in C is 'restrict'. 'restrict' is a C99 keyword; the vast majority of the programs are still written in C89, thus not getting 'restrict' or getting them as an extension. And often getting them wrong.

Name: Anonymous 2011-08-10 17:18

typedef const int * restrict fast_t;

int main(void) {
  register fast_t vroooooooooooooooooooom;

  return 0;
}

Name: Anonymous 2011-08-10 17:23

>>83
Hardware optimization is always a suckers game, even ace asm coders like Michael Abrash say its impossible to to guess how all the factors interrelate in the CPU pipeline

Name: Anonymous 2011-08-10 17:25

>>84

Look, Batman! Non-compliant code! The '_t' suffix is actually reserved for standardization, and usage likewise yields undefined behavior!

How come such an innocent snippet fall within the clutches of Mighty Portable C!

Name: Anonymous 2011-08-10 17:37

>>85

There's a difference between handwiring a very limited hotspot in machine language and attempting to optimize the entire code branch through arcane microfusion knowledge. No doubt, anyway, that a compiler does it worse -- specially if the 'register const int array[const static restrict 0x10]' declaration of a function parameter was your best attempt at 'optimizing access to an array' through language keywords.

One doesn't need to know everything about optimization to produce better-than-average code in assembly, specially because, indeed, knowing every possible correlation is impossible. By design, assembly code is much tighter, which by itself is a great advantage -- higher cache hit ratios, reduced number of overall instructions due to non-redundant calculations, etc. Good assembly programmers know how to healthily produce maintainable, optimized code, when they really need to. They only do if it can be proved it's worth the effort.

Name: Anonymous 2011-08-10 18:26

>>86
IIRC ANSI and ISO C don't prohibit the use of the `_t' suffix for types, only POSIX does. So as long as you don't include any POSIX headers, you can use such type names.

Name: Anonymous 2011-08-11 9:24

>>88
only POSIX does.
That's why it sucks. "Hey, guys, look! C89 uses cool style for typedefing types! Let's steal it awesomess and telly anyone to not use it". Fuck this bullshit.

Name: Anonymous 2011-08-11 10:58

>>88

You're correct, albeit no need to include POSIX headers to 'be' in POSIX. Just by choosing a POSIX environment (#define _POSIX_C_SOURCE) you're already limited to their namespace.


>>89

It does suck steel balls, though much better as a standard than ANSI/ISO is.

Name: Anonymous 2011-08-11 13:57

>>90
Except POSIX doesn't work everywhere.

NOT STANDARD!

Name: Anonymous 2011-08-12 18:50

And then, assembler drove up alongside C and shot C in the head.

Name: Anonymous 2011-08-14 9:01

>>88
wtf, but... time_t and all are POSIXLY defined!

Name: TRUE TRUTH EXPERT 2011-08-14 10:31

>>92
S/SHOT/SUCK'D

Name: Anonymous 2011-08-14 13:49

>>92
With that kind of irresponsible road rage, I don't get why people still use assemblers for drivers.

Name: Anonymous 2011-08-18 0:49

C is just a fast procedural language. Go with C# and save yourself the road rash.

Name: alien 2011-09-20 12:22

i dont think so.

Name: Anonymous 2011-09-20 12:49

>>96
GC is shit.

Name: Anonymous 2011-09-20 12:49

Preventing doubles hijack.

Name: Anonymous 2011-09-20 12:49

Preventing doubles hijack.

Name: Anonymous 2011-09-20 13:18

>>99
nice dubz bro

Name: Anonymous 2011-09-20 14:22

Thread was over when >>3 posted. He's basically 100% right.

Name: Anonymous 2011-09-20 14:29

>>102
Yeah.

Name: Anonymous 2011-09-23 23:14

>>1
Quoting from Rationale for International Standard—Programming Languages—C, revision 5.10:
[quote]7.19.7.7 The gets function
Because gets does not check for buffer overrun, it is generally unsafe to use when its input is
not under the programmer’s control. This has caused some to question whether it should appear
in the Standard at all. The Committee decided that gets was useful and convenient in those
special circumstances when the programmer does have adequate control over the input, and as
longstanding existing practice, it needed a standard specification. In general, however, the
preferred function is fgets (see §7.19.7.2).[/quote]

Name: Anonymous 2011-09-24 1:14

>>99,101
Fuck off, spammer.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List