Berkeley CSUA MOTD:Entry 28939
Berkeley CSUA MOTD
 
WIKI | FAQ | Tech FAQ
http://csua.com/feed/
2025/05/25 [General] UID:1000 Activity:popular
5/25    

2003/7/6-7 [Computer/SW/Languages/C_Cplusplus] UID:28939 Activity:high
7/5     Besides method lookup of non-virtual methods, how is C++ considered
        slower than pure C?  The follow-up question: why hasn't C++ or
        another OO language moved into usage in kernels and drivers?
        \_ Larger standard library + linkers which link everything =
        \_ You probably mean "Besides method lookup of virtual methods".
           large code = poor cache performance.
        \_ OO == Obscene Overhead.  Lack of Language Maturity vs featurebloat
        \_ Non-virtual methods are as fast to dispatch as c functions. OO
           languages have been used in driver implementation: NeXT drivers
           could be written in Objective-C. Mac OS X uses a subset of C++,
           Embedded C++, for driver implementation.
           \_ So are there other areas of serious speed decreases besides
              method lookup?
              \_ I don't think virtual methods cause serious speed decreases
                 (the cost of looking up a method in the vtable is pretty
                 small). Templates and Exceptions have their potential gotchas.
                 See:
                        http://www.caravan.net/ec2plus/rationale.html
                        http://www.caravan.net/ec2plus/question.html
        \_ Linux is writen in C so C must RULE!
        \_ Only in the last year or two have we had compilers that actually
           implement the full C++ standard (okay, only one does--Comeau C++ with
           the EDG front end).
           \_ Not really a valid point; plenty of software projects use /
              have used C++ in its present / previous incarnations.
              \_ True, but the standard was evolving pre-1997.  Hence people
                 tended to use C++ conservatively (which lost a lot of the
                 benefits of the languague).  Also, the comment below about C++
                 sucking is pretty much the same thing.
        \_ Wasn't BeOS kernel written in C++?
           \_ Where's BeOS now?
              \_ Isn't Windows all C++ now?
        \_ Because the major kernels in use are over a decade old, and
           C++ really sucked then.  Completely new kernels rarely happen.
           \_ There's only one kernel!  Or well, there's the odd numbered and
              even numbered and then there's the -AC branch and maybe you
              put the SMP and thread/locking patches in and oh no, now you've
              gone ahead and done it!
                \_ Serves you right for not using '1337 GN00 HURD!
                   \_ Actually, I did.  It was a bitch to scrape off the drive.
                        \_ That is the "viral nature" of GPL software. - BillG
        \_ From what I understand, it's easier to be a moron with C++, but
           the raw performance issue is negligible for an experienced
           development team.
2025/05/25 [General] UID:1000 Activity:popular
5/25    

You may also be interested in these entries...
2012/7/19-11/7 [Computer/SW/Languages/C_Cplusplus] UID:54439 Activity:nil
7/19    In C or C++, how do I write the code of a function with variable
        number of parameters in order to pass the variable parameters to
        another function that also has variable number of parameters?  Thanks.
        \_ The usual way (works on gcc 3.0+, Visual Studio 2005+):
               #define foo(fmt, ...) printf(fmt, ##__VA_ARGS__)
           The cool new way (works on gcc 4.3+):
	...
2005/1/21-22 [Computer/SW/Languages/C_Cplusplus, Computer/SW/Languages/Java] UID:35849 Activity:high
1/21   Thought this was an interesting read:
       http://paulgraham.com/noop.html
       I tend to agree with him, as I've seen relatively little gain
       from such languages as C++ and Java in terms of creating better
       software.
        \_ I thought it was pretty sophomoric, really.  OOP is a tool that is
	...
2004/10/29-30 [Computer/SW/Languages/C_Cplusplus] UID:34449 Activity:very high
10/29   C++ is so freaking BROKEN.  Augh!
        \_ Just use C.
           \_ Would if I could.
        \_ No, you are.  C++ works just fine, and far better than C for many
           purposes.
           \_ C vs. C++.  FIGHT!!!
	...
2004/8/30-31 [Computer/SW/Languages/C_Cplusplus] UID:33228 Activity:high
8/30    Ok this is pretty basic but... is there a way to "escape" text to
        avoid it being substituted by C preprocessor macro expansion?
        \_ Wouldn't that functionality make C preprocessing as powerful as
           lisp's quasiquote/escape? -- ilyas
           \_ Squish!  Isn't it illegal to talk about lisp on the motd?!
        \_ In general no.
	...
2004/8/18-19 [Computer/SW/Languages/C_Cplusplus] UID:32995 Activity:very high
8/18    Doesn't math.h define min() and max() functions?  What should I include
        to get them?  I'd rather not do the (a < b) ? a : b thing.  Thx
        \_ No.  Many programmers define it as a new macro.  Don't know what
           gcc people do, offhand.
        \_ OS X has fmin(3)/fmax(3) which conform to ISO/IEC 9899:1999(E).
           Linux might have these too.
	...
2004/7/5 [Computer/SW/Languages/Perl] UID:31164 Activity:high
7/4     Is there something like a macro in Perl?  Couldn't find any in
        the Camel book.
        \_ If you truly need macros in Perl, you probably want AUTOLOAD.
           Of course, if you truly need macros, Perl is the wrong language for
           what you are doing.  -- ilyas
        \_ I don't know perl, but don't almost all interpreted languages have
	...
2004/4/13-14 [Computer/SW/Languages/C_Cplusplus] UID:13175 Activity:high
4/13    How much C++/C knowledge do recent Berkeley CS/EECS grad have?
        \_ Class CSGrad inherits FromDaddy and does not implement C++Knowledge
           very well.
           \_ funny.  just the rich and poor as always.  the middle class can't
              afford education.
        \_ They know how to deal with pointers and addresses, malloc and free.
	...
2004/3/30-31 [Computer/SW/Languages/Perl] UID:12925 Activity:kinda low
3/17    In Perl, how do I make variables have static types and type check
        for valid parameter/actuals? I realize that variables are untyped
        in Perl ($var can be 0.001 or "hello") but I'd like to have more
        strict checking so that errors would be caught ahead of run-time,
        Thanks,                                                 -java guy
        \_ use java.  Seriously.  You don't use perl if you want strong
	...
2003/4/22-23 [Computer/SW/Languages/C_Cplusplus] UID:28189 Activity:insanely high
4/22    Anyone know a good link that explains all of C++'s use of the
        keyword mconst?
        \_ http://www.parashift.com/c++-faq-lite
           Search for const in the text box.
           Search for mconst in the text box.
           \- perfection
	...
2002/11/5 [Computer/SW/Languages/C_Cplusplus] UID:26409 Activity:high
11/4    I'm having a problem formatting inline elements in xsl-- I have to
        handle the situation where
        <school>I graduated from
          <link href="<DEAD>www.berkeley.edu"<DEAD>Cal</link> in 1998.
        </school>
        My current template is like this:
	...
2001/4/26-27 [Computer/SW/Languages/C_Cplusplus] UID:21109 Activity:high
4/26    What are some good reasons to use C fptr over regular method calls?
        \_ Data directed programming allows you to do function calls
           in constant time. Of course, many modern compilers will
           take switch/case statements and implement them in constant
           time.  Look at examples of C function pointers and you can
           see why they're used.
	...
2001/3/17-18 [Computer/SW/Languages/C_Cplusplus] UID:20827 Activity:high
3/16    Why does so much C sample code use #define instead of const?
        \_ because any good C code will use a bunch of preprocessor
           anyways. you can't be a good C programmer and eschew the
           preprocessor. For that, you need a language which fills those
           gaps with other constructs (c++ templates go a long way to
           obviate the need for preprocessor for example). you
	...
Cache (7977 bytes)
www.caravan.net/ec2plus/rationale.html
Objective The ultimate goal of Embedded C++ is to provide embedded systems programmers with a subset of C++ that is easy for the average C programmer to understand and use. The subset should offer upward compatibility with the full version of Standard C++ and retain the major advantages of C++. Meanwhile, the subset should fulfill the particular requirements of embedded systems designs. To achieve these goals, the committee has established guidelines for creating the subset as follows: 1. Make the specification as small as possible while retaining the object-oriented features. Avoid those features and specifications that do not fulfill the requirements of embedded system design. The three major requirements of embedded system designs are: + Avoiding excessive memory consumption + Taking care not to produce unpredictable responses + Making code ROMable 3. We must eliminate any specification not authorized by ANSI/ISO. We mainly target 32-bit RISC MCU applications as embedded systems. Though there are many applications using 4 or 8-bit MCUs, we cannot address them. We feel that the basic features of C, or even assembly language, are sufficient for these processors. On the other hand, those systems that are expandable using standard buses, such as VME or PCI, are similar to those of PCs or workstations. We recognize that a full version of Standard C++ is better than Embedded C++ for those application designs. Embedded C++ is not a new language specification that will compete with existing Standard C++. Rather, it is a pure subset for the practical user of C++. It supports the establishment of a new methodology in embedded system designs, where a large number of programmers are currently involved. Although some of the above criteria may lose their relevance when new compilers using advanced technologies are available, we will not consider these possibilities for now. We should focus on the future without forgetting about the present. Regarding Embedded C++ library, the set, which conforms to Embedded C++ syntax and semantics and does not depend on OS or environment, is supported. And the set is limited to the minimum set for the embedded application. The compatibility with C++ is reserved except two cases: First the rules for matching exception specifications across multiple declarations are subtle, and it is better that programmers use macros or preprocessor conditional in user's defining 'new'/'delete' functions. Secondly, float_complex' and 'double_complex' peculiar to Embedded C++ cannot have the compatibility with C++. Programmers have to use macros or preprocessor conditional to reserve the compatibility with C++. However, any class members declared 'mutable' can be modified, even if the object itself has been declared 'const'. Therefore, objects that belong to a class that have a 'mutable' member cannot be put into ROM. This means that if one looks only at the declaration, judgement concerning whether or not it is really 'const' is impossible. Thus, a 'mutable' specifier might bewilder the average embedded systems programmer. Therefore, the technical committee decided not to include the 'mutable' specifier in the Embedded C++ specifications. However, there are some drawbacks for embedded systems programmers. It is difficult to estimate the time between when an exception has occurred and control has passed to a corresponding exception handler. It is difficult to estimate memory consumption for exception handling. As control passes from a throw point to a handler, destructors are invoked for all automatic objects constructed since the try block was entered. If an object has a destructor, then it must be destroyed by calling its appropriate destructor. It is difficult to estimate the total time spent on destroying automatic objects. In general, the exception mechanism requires compiler-generated data structures and runtime support. This sometimes adds unexpectedly to the size of the program. In embedded systems it is important for a programmer to be able to easily estimate processing time. Therefore, the two drawbacks mentioned previously cannot be ignored for embedded systems programming. For these reasons, the technical committee decided not to include exception handling in the Embedded C++ specifications. The compiler automatically generates the information, and it would be included in programs that do not use the RTTI facility. For a program that uses polymorphism heavily, the RTTI facility can provide an advantage. But in the case of programs that make little use of polymorphism and do not need the RTTI facility, it has no merit. Program size is critical for embedded systems applications. Also, programs such as the previously mentioned ones are advanced and out of the range of the Embedded C++ specifications, which aim at easy understandability and predictability of generated object code by average C programmers. Therefore, the technical committee decided not to include the RTTI facility in the Embedded C++ specifications. Therefore, the size of application programs cannot be very large. If name conflict becomes a serious problem, we can avoid it by using static member of a class. Namespace facility is not essential for the Embedded C++ specifications. Therefore, the technical committee decided not to include it in the Embedded C++ specifications. However if used carelessly, templates might cause unexpected code explosion. We reiterate that program size is critical for embedded systems applications. Lastly, efficient use of templates depends on programmers having a high level of experience, which means that they will have to invest a great deal of time to learn them well. Therefore, the technical committee decided not to include template in the the Embedded C++ specifications. Programs that do not use multiple inheritance appropriately tend to be less readable, less re- usable, and more difficult to maintain. The Embedded C++ aims at providing specifications that are easy to learn and are used in actual embedded systems programming. Therefore, the technical committee decided not to include multiple inheritance in the Embedded C++ specifications. Virtual inheritance makes sense only if multiple inheritance is used, so virtual inheritance is also absent from the Embedded C++ specifications. However 'new' with exception specification is supported. The reason is that the dynamic memory allocation is necessary. The specification of 'new' is referred by the amendment in detail. Therefore, the technical committee decided not to include libraries with exception in the Embedded C++ specification. Therefore, the technical committee decided not to include the standard template class libraries in the Embedded C++ specification. Some classes are partly supported as non-template class libraries. Regarding string libraries, 'string' class which is equivalent to typedef basic_string<char> string; The reason is that string libraries is used generally, useful for the embedded application and necessary for the support in Embedded C++. Regarding complex libraries, 'float_complex' and 'double_complex' which are equivalent to typedef complex<float> float_complex; The reason is that the importance of the complex libraries is increasing for the embedded application and necessary for the support in Embedded C++. Regarding stream libraries, 'istream' and 'ostream' which are equivalent to typedef basic_istream<char> istream; The reason is that the minimum stream library for input/output is necessary for debugging. Therefore, the technical committee decided not to include libraries for type of wchar_t or long double in the Embedded C++ specification. For example, 'wstream', 'long_double_complex' are not supported. Therefore, the technical committee decided not to include libraries for file-operations in the Embedded C++ specification. Therefore, the technical committee decided not to include localization libraries in the Embedded C++ specification.
Cache (1960 bytes)
www.caravan.net/ec2plus/question.html
This specification is in the style of amendment for ISO/ANSI C++ Draft Standard which is registered as SC22/WG21/N1037. Is there any features added specially for embedded program? Though 'namespace' has no runtime overhead, it is too new to be used widely. Though 'using' has no runtime overhead, it is too new to be used widely. Why are 'static_cast', 'reinterpret_cast', 'const_cast' eliminated? Though such casts have no runtime overhead, it is too new to be used widely. Currently 'template' implementation requires large memory and causes runtime overhaed. RTTI features causes runtime overhead even if it is not actually used. It is very difficult to estimate machine cycles for exception handling. Miscellaneous questions When will commercial level products be available? We would say the following companies are working with Embedded C++ development: Toshiba, Hitachi, Fujitsu, NEC, Cygnus, Green Hills, Edison, 10 IAR and several European companies. If your have any announcement on your EC++ product or development, please inform us of it. We are happy to list it in our web and link to your web site. Is there any official system to certificate EC++ implementation ? How is the Embedded C++ Technical Committee organized (membership)? The Embedded C++ Technical Committee is organized by 'member', 'advisor' and 'observer'. The 'member' is to do voluntary work and have to attend regular meeting in JAPAN. The 'advisor' is to technically advise the Embedded C++ Technical Committee as so requested by the committee. Anyone who has an interrest in and supports EC++ activities can be 'observer'. Public mailing reflector for observers will be managed by the committee. How much can I expect improvement of performance when I use EC++? The performance (efficiency) is heavily varied depending on actual application and compiler/library implementation. There is no way other than compiling your application by actual implementation to know performance.