Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c > #142584
| From | David Brown <david.brown@hesbynett.no> |
|---|---|
| Newsgroups | comp.lang.c |
| Subject | Re: C Translator |
| Date | 2019-03-29 14:57 +0100 |
| Organization | A noiseless patient Spider |
| Message-ID | <q7l87n$1vv$1@dont-email.me> (permalink) |
| References | (1 earlier) <xfdnE.427090$0_.110498@fx19.am4> <lnk1gia152.fsf@kst-u.example.com> <DufnE.1219230$OGY.973445@fx08.am4> <q7kq7h$j7u$1@dont-email.me> <FtonE.887048$Apg.569682@fx36.am4> |
On 29/03/2019 13:47, Bart wrote: > On 29/03/2019 09:58, David Brown wrote: >> On 29/03/2019 03:34, Bart wrote: > >>> I recently got pulled up for calling C a trumped-up assembler, that's >>> why I mentioned it. >> >> That's because C is in no way a "trumped-up assembler". And in terms of >> its structure and syntax, it doesn't bear the slightest resemblance to >> assembler - and thus the comparison makes no sense at all in this >> context. > > Yes it does. No, it doesn't. I'm not sure whether you think this because you have little experience and understanding of assembly, or because you have little experience and understanding of C. Or maybe it is because you write your assembly code in a very limited fashion - as you do for your C code - and thus the structures resemble each other vaguely. For other programmers, assembly and C are not remotely similar languages. > > I realised that some of problems I faced in translation in doing a full > translation of C to my language, are similar to those of trying to > translate ASM to HLL. > > Some are doable by looking at patterns or idioms that match one in the > target language (eg. a for-loop that does a simple A to B iteration), > others are just too chaotic (eg. 'switch' with jumbled-up case labels). I'll happily agree that mixed-up switch and loop statements is going to be a pain to translate. It is the kind of feature that was very nice in the old days of weaker C compilers, and could be used for some efficient implementations of certain kinds of code. But with modern compilers, you are better letting the compiler handle this kind of thing based on simple, clear code, and such mixes are going to be difficult for the compiler to optimise well. > > Another big one is to do with types; C plays fast and loose with arrays > and pointers; the target language doesn't. Again, this is like ASM which > doesn't have a type system at all. Repeating the same shite several hundred times does not make it true. C has arrays, and it has pointers. You might not like the way arrays are handled in C - the system has advantages and disadvantages compared to, say, Pascal's handling of arrays. But it works fine, and is not "fast and loose" - there are clear rules if only you could be bothered to learn them. > > Yet another is to do with macros (macros are very common in ASM): > > #define A 144 > #define B 144 > #define C 144 > > rather than have 144 all over the output code, and not know which 144 > it's referring to, I'd rather have A, B or C. But if I suppress macro > expansion, it causes other problems (mainly in things like '#if > A==144'). Actually, I would probably have fewer problems translating ASM > in this case! > What a shame - life is so hard for you. How nasty all these C people have been, designing a language without any consideration for poor Bart and his troubles. Back here in reality, translating between significantly different languages is an extremely difficult task, especially if you are aiming for efficiency, or aiming for an output that is clearly readable and keeps the structure of the original - and even worse if you want both. This is not a problem with C, or the way people write C - it is the nature of the problem. > The answer would have been to use something like 'enum' for such integer > constants, which have fewer such problems. But '#define' for named > constants is still used everywhere. > C has several ways of making constants, with different tradeoffs. I agree that enum can often be a neater method, but it is not always a suitable choice. And you don't get to choose how other people write their code.
Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
C Translator Bart <bc@freeuk.com> - 2019-03-28 16:16 +0000
Re: C Translator Bart <bc@freeuk.com> - 2019-03-29 00:01 +0000
Re: C Translator Robert Wessel <robertwessel2@yahoo.com> - 2019-03-28 20:31 -0500
Re: C Translator Keith Thompson <kst-u@mib.org> - 2019-03-28 19:02 -0700
Re: C Translator Bart <bc@freeuk.com> - 2019-03-29 02:34 +0000
Re: C Translator David Brown <david.brown@hesbynett.no> - 2019-03-29 10:58 +0100
Re: C Translator Bart <bc@freeuk.com> - 2019-03-29 12:47 +0000
Re: C Translator David Brown <david.brown@hesbynett.no> - 2019-03-29 14:57 +0100
Re: C Translator Bart <bc@freeuk.com> - 2019-03-29 14:57 +0000
Re: C Translator fir <profesor.fir@gmail.com> - 2019-03-29 15:08 -0700
Re: C Translator fir <profesor.fir@gmail.com> - 2019-03-29 15:42 -0700
Re: C Translator scott@slp53.sl.home (Scott Lurndal) - 2019-03-29 15:16 +0000
Re: C Translator Bart <bc@freeuk.com> - 2019-03-29 15:30 +0000
Re: C Translator fir <profesor.fir@gmail.com> - 2019-03-29 14:47 -0700
Re: C Translator Ben Bacarisse <ben.usenet@bsb.me.uk> - 2019-03-29 10:42 +0000
Re: C Translator Bart <bc@freeuk.com> - 2019-03-29 11:57 +0000
Re: C Translator Bart <bc@freeuk.com> - 2019-03-29 13:04 +0000
Re: C Translator David Brown <david.brown@hesbynett.no> - 2019-03-29 14:58 +0100
Re: C Translator Bart <bc@freeuk.com> - 2019-03-29 14:29 +0000
Re: C Translator Ben Bacarisse <ben.usenet@bsb.me.uk> - 2019-03-29 20:06 +0000
Re: C Translator Ben Bacarisse <ben.usenet@bsb.me.uk> - 2019-03-29 20:02 +0000
Re: C Translator Bart <bc@freeuk.com> - 2019-03-29 21:10 +0000
Re: C Translator nobody@example.org (Scott) - 2019-03-30 04:52 +0000
Re: C Translator Bart <bc@freeuk.com> - 2019-03-30 11:03 +0000
Re: C Translator nobody@example.org (Scott) - 2019-03-30 16:17 +0000
Re: C Translator Bart <bc@freeuk.com> - 2019-03-30 18:36 +0000
Re: C Translator Ben Bacarisse <ben.usenet@bsb.me.uk> - 2019-03-30 20:32 +0000
Re: C Translator Bart <bc@freeuk.com> - 2019-03-30 22:44 +0000
Re: C Translator Ben Bacarisse <ben.usenet@bsb.me.uk> - 2019-03-31 03:23 +0100
Re: C Translator Bart <bc@freeuk.com> - 2019-03-31 12:39 +0100
Re: C Translator Ben Bacarisse <ben.usenet@bsb.me.uk> - 2019-03-31 15:07 +0100
Re: C Translator Bart <bc@freeuk.com> - 2019-03-31 16:21 +0100
Re: C Translator David Brown <david.brown@hesbynett.no> - 2019-03-31 21:19 +0200
Re: C Translator Bart <bc@freeuk.com> - 2019-03-31 20:58 +0100
Re: C Translator Ike Naar <ike@iceland.freeshell.org> - 2019-03-31 20:33 +0000
Re: C Translator Bart <bc@freeuk.com> - 2019-03-31 22:06 +0100
Re: C Translator Ben Bacarisse <ben.usenet@bsb.me.uk> - 2019-03-31 22:37 +0100
Re: C Translator Bart <bc@freeuk.com> - 2019-03-31 23:33 +0100
Re: C Translator Ben Bacarisse <ben.usenet@bsb.me.uk> - 2019-04-01 02:35 +0100
Re: C Translator David Brown <david.brown@hesbynett.no> - 2019-04-01 11:33 +0200
Re: C Translator David Brown <david.brown@hesbynett.no> - 2019-03-31 23:54 +0200
Re: C Translator Bart <bc@freeuk.com> - 2019-04-01 02:16 +0100
Re: C Translator Ike Naar <ike@iceland.freeshell.org> - 2019-04-01 06:42 +0000
Re: C Translator David Brown <david.brown@hesbynett.no> - 2019-04-01 11:35 +0200
Re: C Translator Bart <bc@freeuk.com> - 2019-04-01 16:54 +0100
Re: C Translator Bart <bc@freeuk.com> - 2019-04-01 21:01 +0100
Re: C Translator Keith Thompson <kst-u@mib.org> - 2019-04-01 13:41 -0700
Re: C Translator Bart <bc@freeuk.com> - 2019-04-01 22:40 +0100
Re: C Translator Keith Thompson <kst-u@mib.org> - 2019-04-01 16:25 -0700
Re: C Translator Ben Bacarisse <ben.usenet@bsb.me.uk> - 2019-04-02 00:50 +0100
Re: C Translator Keith Thompson <kst-u@mib.org> - 2019-04-01 17:45 -0700
Re: C Translator Ben Bacarisse <ben.usenet@bsb.me.uk> - 2019-04-02 11:28 +0100
Re: C Translator David Brown <david.brown@hesbynett.no> - 2019-04-02 13:18 +0200
Re: C Translator Jorgen Grahn <grahn+nntp@snipabacken.se> - 2019-04-02 19:15 +0000
Re: C Translator Bart <bc@freeuk.com> - 2019-04-02 21:14 +0100
Re: C Translator Ben Bacarisse <ben.usenet@bsb.me.uk> - 2019-04-02 13:28 +0100
Re: C Translator David Brown <david.brown@hesbynett.no> - 2019-04-02 10:49 +0200
Re: C Translator Bart <bc@freeuk.com> - 2019-04-02 01:58 +0100
Re: C Translator Keith Thompson <kst-u@mib.org> - 2019-04-01 19:13 -0700
Re: C Translator Bart <bc@freeuk.com> - 2019-04-02 11:13 +0100
Re: C Translator David Brown <david.brown@hesbynett.no> - 2019-04-02 13:49 +0200
Re: C Translator Malcolm McLean <malcolm.arthur.mclean@gmail.com> - 2019-04-02 05:15 -0700
Re: C Translator Bart <bc@freeuk.com> - 2019-04-02 14:50 +0100
Re: C Translator David Brown <david.brown@hesbynett.no> - 2019-04-02 16:06 +0200
Re: C Translator David Brown <david.brown@hesbynett.no> - 2019-04-02 16:05 +0200
Re: C Translator Ben Bacarisse <ben.usenet@bsb.me.uk> - 2019-04-02 00:11 +0100
Re: C Translator David Brown <david.brown@hesbynett.no> - 2019-04-02 10:35 +0200
Re: C Translator Ben Bacarisse <ben.usenet@bsb.me.uk> - 2019-04-02 00:06 +0100
Re: C Translator Ben Bacarisse <ben.usenet@bsb.me.uk> - 2019-03-31 21:36 +0100
Re: C Translator Ben Bacarisse <ben.usenet@bsb.me.uk> - 2019-03-31 16:32 +0100
Re: C Translator Bart <bc@freeuk.com> - 2019-03-30 00:37 +0000
Re: C Translator Ben Bacarisse <ben.usenet@bsb.me.uk> - 2019-03-30 01:00 +0000
Re: C Translator fir <profesor.fir@gmail.com> - 2019-03-30 03:37 -0700
Re: C Translator fir <profesor.fir@gmail.com> - 2019-03-30 06:15 -0700
Re: C Translator James Kuyper <jameskuyper@alumni.caltech.edu> - 2019-03-29 07:49 -0700
csiph-web