Hot answers tagged

79 votes
Accepted

Why do C to Z80 compilers produce poor code?

Quite often people don't know how to use the compilers or don't understand fully the consequences of code they write. There is optimization going on in the z80 c compilers but it's not as complete as,...
  • 906
73 votes
Accepted

Why did C have the return type before function names?

Dennis Ritchie’s paper on The Development of the C Language gives some idea of the reasoning behind this: namely, the fundamental rule in C that declaration syntax should match expression syntax. For ...
  • 98.2k
69 votes

Why did C use the arrow (->) operator instead of reusing the dot (.) operator?

In the embryonic form of C described in the 1974 C Reference Manual, there was no requirement that the left operand of . actually be a structure, nor that the left operand of -> actually be a ...
  • 29.2k
69 votes
Accepted

Why did C use the arrow (->) operator instead of reusing the dot (.) operator?

Some of the first C code I saw was like this: 0x8040->output = 'A'; — its purpose was accessing memory mapped I/O locations.  Needless to say it took me a while to figure out what this ...
  • 3,097
69 votes

When was this C function definition style, with type declarations of parameters after the parameter list, invented?

It's the original C syntax as designed by Dennis Ritchie, so bite your tongue :-) As mentioned in another answer, the style was not unusual at the time. For an example of early art: FORTRAN II (1958) ...
  • 28.5k
61 votes

Why do C to Z80 compilers produce poor code?

If you try translating C into Z80, you'll see that Z80 index registers and stack don't behave quite as you expect. So, let us begin with Arrays Suppose you have a standard C construction int c[10]; ...
  • 3,842
59 votes

Have programming languages driven hardware development?

Simply yes. And not just a few instructions, but whole CPUs have been developed with languages in mind. Most prominent maybe Intel's 8086. Already the basic CPU was designed to support the way high ...
  • 177k
56 votes

Why do C to Z80 compilers produce poor code?

The main downside of "historic" CPU's (non?)-suitability for C programs is the lack of capability to form more than one register into an address without using the ALU. Most more modern CPUs can use ...
  • 28.6k
56 votes

Why weren't 80s arcade games programmed in C?

I think the question I would ask is why would you program arcade gamers in C back in the 80's. Firstly, C was not nearly as popular in the world of microprocessor programming as you might imagine back ...
  • 10.4k
55 votes

When if ever was the C language 'int' size altered from the host machine word (register) size into a literal 32 bit size?

The C standard of the language doesn't mandate a 32-bit int. It defines sizeof(char) = 1 and sizeof(long long) ≥ sizeof(long) ≥ sizeof(int) ≥ sizeof(short) ≥ sizeof(char) It also mandates that the ...
52 votes
Accepted

Have programming languages driven hardware development?

Interesting question with an interesting answer. First let me get one thing out of the way: One example from this answer mentions how C pointers were, at least in part, influenced by the design ...
  • 10.4k
50 votes
Accepted

Why were single quotes ('…') chosen for characters, and double quotes ("…") for strings?

For type system reasons, and for compatibility with B. B is a programming language that served as the immediate ancestor of C. The salient thing about B is that it had no type system: all values in B ...
  • 17.6k
46 votes
Accepted

Why (historically) include the number of arguments (argc) as a parameter of main?

K&R first edition (1978) does not mention the NULL terminator in the argv list at all. This was added later, in ANSI C. The relevant paragraph (section 5.11, p. 110) is: In environments that ...
  • 5,667
46 votes
Accepted

Which tools were used to create the C language?

C didn't spring into being suddenly, but was created by slowly modifying the B language--which was written in itself. Therefore you might say that C was always written in itself, but at first it was ...
  • 1,906
46 votes
Accepted

How did varargs in C develop?

It was a pointer arithmetic hack, later abstracted away into a more portable form in some version of Unix; even later, it was adapted into ANSI C. In many languages (like Pascal for example), variadic ...
  • 17.6k
45 votes

Have programming languages driven hardware development?

One interesting example of programming languages driving hardware development is the LISP machine. Since "normal" computers of the time period couldn't execute lisp code efficiently, and there was a ...
  • 551
45 votes

Why did C use the arrow (->) operator instead of reusing the dot (.) operator?

Despite your assertion, there would in fact be situations where it would be ambigious. First off, early C compilers were very simple. This was in fact the main appeal of the language, as compilers ...
  • 1,409
43 votes

How to get started writing C for the IBM PC in 1980-81

So you want to write a C program for the IBM PC before the first C compiler for the PC is released. How do you go about it? There are three options I can see: Write your own C compiler Use a cross ...
  • 10.4k
40 votes

Why do C to Z80 compilers produce poor code?

Simple answers one easily gets to this question are The Z80 Sucks and C Sucks - depending on the side someone is on. While they are of course, untrue (*1), there are real issues. A major argument for ...
  • 177k
39 votes
Accepted

Was Dennis Ritchie being too modest in this quote about C and Pascal?

Was Ritchie correct, or was he just being modest? I’m not sure modesty plays a part here; I don’t see any statement of value attached to the size of a language’s family. As of the date of the ...
  • 98.2k
38 votes

Why (historically) include the number of arguments (argc) as a parameter of main?

The requirement that argv[argc] be NULL was added in the ANSI C standard; it wasn’t a requirement before then, and some environments didn’t null-terminate the array (the strings themselves were of ...
  • 98.2k
38 votes
Accepted

Why is this gcd implementation from the 80s so complicated?

This is (or at least appears to be) the binary euclidean GCD. https://en.wikipedia.org/wiki/Binary_GCD_algorithm has a slighty different version (but the version you post has the nice feature that ...
  • 1,011
38 votes

Why couldn't early C compilers handle variable declarations between statements?

Some early compilers, such as the ones described in the 1974 C reference manual, required that all automatic object declarations within a function precede the first executable code therein. Imposing ...
  • 29.2k
37 votes

What was the first C compiler for the Mac?

The Early Days As you said, the most important languages on the Mac in its early days were Microsoft's BASIC, Pascal, and, of course, 68000 assembly. The Macintosh's System Software and ROMs were ...
  • 1,485
37 votes
Accepted

How did early x86 BIOS programmers manage to program full blown TUIs given very few bytes of ROM/EPROM?

The architecture of the original IBM PC (and its clones) let the BIOS access the video memory directly. So making nice text layouts did not require positioning the cursor or making a sequence of ...
35 votes
Accepted

How common was programming in C targeting 8-bit processors in 1983?

How often was C used to program firmware for 8-bit processors in the early 80s? It would have been a rather unusual choice in 1983. True, C was slowly creeping in, but only on 'big' machines and 16 ...
  • 177k

Only top scored, non community-wiki answers of a minimum length are eligible