I thought this might be of interest to readers of comp.compilers.
I teach a high-performance computing course at Ulm University. For this course
I developed a small C-like language called ABC, which we use to teach some of the basics of programming and compiler construction.
In practice, we have seen the opposite. Since introducing ABC, students who >come to the course without previous programming experience have had a >noticeably easier time. They can first learn the programming concepts without >having to deal with some of C's syntactic peculiarities, and the later >transition to C or C++ has not been a problem.
The main motivation for A Better C is actually quite mundane. When teaching C, >I always found declarations unnecessarily difficult to explain. For example:
int *a[10]; // array of 10 pointers to int
int (*b)[10]; // pointer to an array of 10 ints
There is a perfectly consistent logic behind C declarations: you declare an >object in a form resembling how it is used. But for beginners this means that >they already need to understand operator precedence rCo in particular that >postfix operators bind more strongly than prefix operators rCo just to read a >declaration.
I learned Pascal before C myself, and always found Pascal declarations easier >to read because you can essentially read them from left to right.
That is almost the whole idea behind A Better C: it is basically C, but with >declarations following a Pascal-like logic. Since `^` already has a meaning in >C, I used `->` for pointers.
[Your moderator has only limited sympathy for arguments about the aesthetics of
declarations, noting a strong pattern of people liking what they learned first.
Personally, I think Fortran EQUIVALENCE and COMMON statements are totally >intuituitive, but then I would. -John]
While I agree with our esteemed moderator's point about aesthetics, it
is worth noting that Wirth intentionally made Pascal easy to parse.
Thus, the Pascal declaration notation was designed to be parsed with a
one pass compiler.
C's notation does
have the nice aspect that declaration syntax matches usage.
| Sysop: | Amessyroom |
|---|---|
| Location: | Fayetteville, NC |
| Users: | 76 |
| Nodes: | 6 (0 / 6) |
| Uptime: | 53:42:15 |
| Calls: | 1,265 |
| Calls today: | 1 |
| Files: | 1,362 |
| D/L today: |
3 files (2,684K bytes) |
| Messages: | 285,448 |