Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.misc > #1012
| From | "Rod Pemberton" <do_not_have@noavailemail.cmm> |
|---|---|
| Newsgroups | comp.lang.misc, comp.lang.c++ |
| Subject | Re: Learning to code by reading code |
| Date | 2012-02-22 06:04 -0500 |
| Organization | Aioe.org NNTP Server |
| Message-ID | <ji2i6b$ac5$1@speranza.aioe.org> (permalink) |
| References | (6 earlier) <2bc2a617-e283-44c7-9fd3-63d2887b896e@y10g2000vbn.googlegroups.com> <jhuhvb$6sr$1@speranza.aioe.org> <4f43548d$0$3083$7b1e8fa0@news.nbl.fi> <jhvobn$ujr$1@speranza.aioe.org> <4f436c84$0$4364$7b1e8fa0@news.nbl.fi> |
Cross-posted to 2 groups.
"Juha Nieminen" <nospam@thanks.invalid> wrote in message news:4f436c84$0$4364$7b1e8fa0@news.nbl.fi... > In comp.lang.c++ Rod Pemberton <do_not_have@noavailemail.cmm> wrote: > >> Even then it would probably be hard to match the speed of an actual > >> compiler of the original language. > > > > I don't believe that. > > Why not? Well, I stated why. It's the part about the research into and implementation of optimizations. > It's not very hard to believe. If the language has no support > for a certain higher-level concept, then the compiler cannot use > that concept to perform optimizations. So, even though every "Turing complete" language can be expressed in terms of an OISC, none of them can optimize a higher-level concept that is not designed into in the high-level language? Do they actually do any optimization at all according to you? You do understand that no architecture executes the higher-level concept, yes? I.e., they all execute the optimized low-level assembly created for those high level concepts whether designed into the language or not ... In theory, any equivalent program, no matter what "Turing complete" language is used, when translated to an OISC and optimized, should produce the exact same program, entirely independent of whatever high-level concepts that language has or doesn't. Do you agree? OISC http://en.wikipedia.org/wiki/One_instruction_set_computer > You cannot express everything in C that can be expressed in asm. There is a sharp cutoff between what you can and can't express in C that is equivalent to assembly. C maps onto basic or generic assembly extremely well, especially on 8-bit byte, contiguous memory, generic integer, machines. The major impediment is some of the type checking introduced with ANSI C. C captures nearly all of the functionality present in early 8-bit microprocessors, except the carry flag, rotates, etc. However, using that functionality may require a few casts or having a chart of the type conversion rules so you can convert types legally. With x86, you generally can't generate the more specialized or modern assembly instructions, e.g., SMM, MMX, PM, etc without inline assembly. You may also some have issues with DSPs or RISC instruction sets fitting well with C. Of course, word-sized machines were known to be a problem for C from the start. > (You can probably achieve the same functionality, but > you cannot achieve the same efficiency in every single case.) It depends on what assembly functionality you're referring too. > > C has had some of the most intensive research into > > language optimizations. > > Yes, into *C* language optimizations, not other languages. > What C does not support as a concept the C compiler > cannot optimize. If it's expressed as C, it sure can! That's what C compiler optimization does. What you, perhaps, intended to say is that if C language does not support a certain concept, then the C compiler might not optimize it as effectively as a native language compiler with aggressive optimization for that concept. That could be true, but doesn't have to be. See OISC comments above. > >> Just take C++ exceptions, for instance. I don't see any easy way > >> to get the same effect in C without slowing down the code. > > > > Sorry, I'm not familiar with C++. However, if exceptions interrupt the > > normal program flow like signals do, then it'll slow down the code > > purely due to whatever save-restore state mechanism is used to handle > > the exception. That requires substantial overhead in assembly. > > Nope. That's the genius in C++ exceptions: Support for exceptions does > not slow down the program in any way (compared to compiling the program > without support for exceptions). (It was, AFAIK, in fact a requirement > by the standardization committee, that exceptions would be added to the > standard only if it's possible to support them without compromising the > speed of the program. It turns out that it's possible.) > > (Of course *throwing* an exception has overhead, but that's to be > expected. Exceptions are designed to be used to handle fatal errors, > not for normal operation. The main point is that when no exceptions > are thrown, the code is in no way slower than eg. the equivalent C > program would be, even though exceptions are supported and could > be thrown at any moment, at any point in the code.) So, if an exception is thrown, C++ is slows downs due to the overhead. How is that any different from a signal in C? How is that any different to me stating there is substantial overhead present in assembly due to save-restore state mechanism? So, your comments here seem fine to me, except I don't get the "Nope." Rod Pemberton
Back to comp.lang.misc | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Re: Learning to code by reading code (was: The way to read STL source code) "Rod Pemberton" <do_not_have@noavailemail.cmm> - 2012-02-18 19:00 -0500
Re: Learning to code by reading code "MikeWhy" <boat042-nospam@yahoo.com> - 2012-02-18 22:34 -0600
Re: Learning to code by reading code "Rod Pemberton" <do_not_have@noavailemail.cmm> - 2012-02-19 03:54 -0500
Re: Learning to code by reading code "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> - 2012-02-19 10:42 +0100
Re: Learning to code by reading code "BartC" <bc@freeuk.com> - 2012-02-19 22:34 +0000
Re: Learning to code by reading code "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> - 2012-02-20 12:22 +0100
Re: Learning to code by reading code "Rod Pemberton" <do_not_have@noavailemail.cmm> - 2012-02-20 03:39 -0500
Re: Learning to code by reading code "Rod Pemberton" <do_not_have@noavailemail.cmm> - 2012-02-19 03:54 -0500
Re: Learning to code by reading code Nick Keighley <nick_keighley_nospam@hotmail.com> - 2012-02-19 08:40 -0800
Re: Learning to code by reading code "MikeWhy" <boat042-nospam@yahoo.com> - 2012-02-19 13:17 -0600
Re: Learning to code by reading code Nick Keighley <nick_keighley_nospam@hotmail.com> - 2012-02-20 02:32 -0800
Re: Learning to code by reading code "io_x" <a@b.c.invalid> - 2012-02-20 13:02 +0100
Re: Learning to code by reading code Nick Keighley <nick_keighley_nospam@hotmail.com> - 2012-02-20 05:09 -0800
Re: Learning to code by reading code "io_x" <a@b.c.invalid> - 2012-02-20 15:11 +0100
Re: Learning to code by reading code Nick Keighley <nick_keighley_nospam@hotmail.com> - 2012-02-20 07:39 -0800
Re: Learning to code by reading code "Rod Pemberton" <do_not_have@noavailemail.cmm> - 2012-02-20 04:14 -0500
Re: Learning to code by reading code "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> - 2012-02-20 11:14 +0100
Re: Learning to code by reading code Nick Keighley <nick_keighley_nospam@hotmail.com> - 2012-02-20 05:13 -0800
Re: Learning to code by reading code Nick Keighley <nick_keighley_nospam@hotmail.com> - 2012-02-20 02:49 -0800
Re: Learning to code by reading code "io_x" <a@b.c.invalid> - 2012-02-20 13:02 +0100
Re: Learning to code by reading code Nick Keighley <nick_keighley_nospam@hotmail.com> - 2012-02-20 05:18 -0800
Re: Learning to code by reading code "BartC" <bc@freeuk.com> - 2012-02-20 13:53 +0000
Re: Learning to code by reading code Nick Keighley <nick_keighley_nospam@hotmail.com> - 2012-02-21 01:32 -0800
Re: Learning to code by reading code "io_x" <a@b.c.invalid> - 2012-02-21 16:16 +0100
Re: Learning to code by reading code Nick Keighley <nick_keighley_nospam@hotmail.com> - 2012-02-21 08:40 -0800
Re: Learning to code by reading code "Rod Pemberton" <do_not_have@noavailemail.cmm> - 2012-02-20 17:36 -0500
Re: Learning to code by reading code Dombo <dombo@disposable.invalid> - 2012-02-21 00:45 +0100
Re: Learning to code by reading code "Rod Pemberton" <do_not_have@noavailemail.cmm> - 2012-02-21 04:35 -0500
Re: Learning to code by reading code Nick Keighley <nick_keighley_nospam@hotmail.com> - 2012-02-21 08:48 -0800
Re: Learning to code by reading code Nick Keighley <nick_keighley_nospam@hotmail.com> - 2012-02-22 00:12 -0800
Re: Learning to code by reading code "Rod Pemberton" <do_not_have@noavailemail.cmm> - 2012-02-22 06:12 -0500
Re: Learning to code by reading code Nick Keighley <nick_keighley_nospam@hotmail.com> - 2012-02-22 04:30 -0800
Re: Learning to code by reading code Geoff <geoff@invalid.invalid> - 2012-02-22 10:45 -0800
Re: Learning to code by reading code Nick Keighley <nick_keighley_nospam@hotmail.com> - 2012-02-23 01:12 -0800
Re: Learning to code by reading code "Rod Pemberton" <do_not_have@noavailemail.cmm> - 2012-02-23 07:34 -0500
Re: Learning to code by reading code Nick Keighley <nick_keighley_nospam@hotmail.com> - 2012-02-23 05:46 -0800
Re: Learning to code by reading code "io_x" <a@b.c.invalid> - 2012-02-24 08:38 +0100
Re: Learning to code by reading code "io_x" <a@b.c.invalid> - 2012-02-24 08:40 +0100
Re: Learning to code by reading code "io_x" <a@b.c.invalid> - 2012-02-24 09:38 +0100
Re: Learning to code by reading code "Rod Pemberton" <do_not_have@noavailemail.cmm> - 2012-02-25 05:25 -0500
Re: Learning to code by reading code Dombo <dombo@disposable.invalid> - 2012-02-25 12:50 +0100
Re: Learning to code by reading code Nick Keighley <nick_keighley_nospam@hotmail.com> - 2012-02-25 06:13 -0800
Re: Learning to code by reading code Gareth Owen <gwowen@gmail.com> - 2012-02-26 07:20 +0000
Re: Learning to code by reading code Juha Nieminen <nospam@thanks.invalid> - 2012-02-21 08:23 +0000
Re: Learning to code by reading code Juha Nieminen <nospam@thanks.invalid> - 2012-02-21 08:43 +0000
Re: Learning to code by reading code "Rod Pemberton" <do_not_have@noavailemail.cmm> - 2012-02-21 04:47 -0500
Re: Learning to code by reading code Juha Nieminen <nospam@thanks.invalid> - 2012-02-21 10:09 +0000
Re: Learning to code by reading code "Rod Pemberton" <do_not_have@noavailemail.cmm> - 2012-02-22 05:38 -0500
Re: Learning to code by reading code "Rod Pemberton" <do_not_have@noavailemail.cmm> - 2012-02-21 04:31 -0500
Re: Learning to code by reading code Juha Nieminen <nospam@thanks.invalid> - 2012-02-21 10:05 +0000
Re: Learning to code by reading code "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> - 2012-02-21 12:21 +0100
Re: Learning to code by reading code "Rod Pemberton" <do_not_have@noavailemail.cmm> - 2012-02-22 06:04 -0500
Re: Learning to code by reading code "BartC" <bc@freeuk.com> - 2012-02-21 11:01 +0000
Re: Learning to code by reading code "Rod Pemberton" <do_not_have@noavailemail.cmm> - 2012-02-22 05:59 -0500
Re: Learning to code by reading code "BartC" <bc@freeuk.com> - 2012-02-22 12:59 +0000
Re: Learning to code by reading code "Rod Pemberton" <do_not_have@noavailemail.cmm> - 2012-02-23 07:03 -0500
Re: Learning to code by reading code "BartC" <bc@freeuk.com> - 2012-02-24 14:20 +0000
Re: Learning to code by reading code Nick Keighley <nick_keighley_nospam@hotmail.com> - 2012-02-21 01:27 -0800
Re: Learning to code by reading code Peter Remmers <p.remmers@expires-2011-04-30.arcornews.de> - 2012-02-20 22:25 +0100
Re: Learning to code by reading code Jorgen Grahn <grahn+nntp@snipabacken.se> - 2012-02-26 08:47 +0000
Re: Learning to code by reading code "BartC" <bc@freeuk.com> - 2012-02-26 10:55 +0000
Re: Learning to code by reading code Nomen Nescio <nobody@dizum.com> - 2012-02-22 08:59 +0100
Re: Learning to code by reading code "Rod Pemberton" <do_not_have@noavailemail.cmm> - 2012-02-22 05:59 -0500
Re: Learning to code by reading code Nomen Nescio <nobody@dizum.com> - 2012-02-22 13:47 +0100
Re: Learning to code by reading code "Rod Pemberton" <do_not_have@noavailemail.cmm> - 2012-02-23 06:21 -0500
Re: Learning to code by reading code Nick Keighley <nick_keighley_nospam@hotmail.com> - 2012-02-22 00:08 -0800
Re: Learning to code by reading code "Rod Pemberton" <do_not_have@noavailemail.cmm> - 2012-02-19 03:54 -0500
Re: Learning to code by reading code Marco van de Voort <marcov@toad.stack.nl> - 2012-02-19 11:27 +0000
csiph-web