|
I think Java has this ( final not this )
"I didn't mention the bats - he'd see them soon enough" - Hunter S Thompson - RIP
|
|
|
|
|
honey the codewitch wrote: What is the purpose of writing new code in C for targeting, well ... anything?
For products that you want to put on market, you have to comply to a lot of standards (like MISRA) that are much easier to implement in C, which is the state-of-the-art language. Given the amount of legacy code, this will probably not change in the next decade, so C remains the language if choice because, well, it was the language of choice.
Of course, footprint & co also play a role, but not that much with modern compilers.
Honestly, I am working in the automotive industry, and when I see what people are able to do with C, I am glad they are not given more powerful tools to work with ; I have my personal blacklist of vehicles I will never put a foot in, unless their code gets rewritten and their hardware redesigned.
|
|
|
|
|
That is the easily the most compelling argument I've heard from anyone on the subject.
Real programmers use butterflies
|
|
|
|
|
I remember badly or in 2008 they issued the specifications for Misra C ++?
|
|
|
|
|
I've only ever dabbled in C++ and I had little use for it. From the early 90s until 2002 I used ANSI C (on OpenVMS).
On my PC I have a few C/C++ compilers, but on three of my OpenVMS systems I've installed C (not C++) to play with on occasion.
DEC C V6.0-001 on OpenVMS Alpha V7.2
Compaq C V6.4-005 on OpenVMS VAX V7.3
HP C V7.3-009 on OpenVMS Alpha V8.3
(I don't have C on my Itanium server. I may need to address that)
The only thing I currently use C (not C++) for on my PC is an experiment in using ODBC (using a book from 1999).
Oh, and of course, I use the "C pre-processor" for various manipulations of my C# code.
modified 2-Mar-21 11:50am.
|
|
|
|
|
PIEBALDconsult wrote: Oh, and of course, I use the "C pre-processor" for various manipulations of my C# code.
The only reason I don't do that myself is for me intellisense and all that is too big of a productivity win. I respect you that in your case it's not. I can't remember what half the classes and functions are without VS prompting me with them every time I hit ( or .
Real programmers use butterflies
|
|
|
|
|
No such tools on OpenVMS .
I never learned the Language Sensitive Editor (LSE).
|
|
|
|
|
I ran into this problem with the small footprint Arduinos, folks where asking mw why I wanted to use C++ when C was so efficient, faster and used less memory. But I found there really wasn't much difference in size or speed...no response from the peanut gallery.
Now with devices with more memory I think that people still use C because that is what they are comfortable with.
In the late 80s early 90s I worked for the railroad in the cyber division and I tried to get people to cross over to C++ but not one person could I get to change. I taught classes in using the development tools, debuggers and worked with them one on one...nope!
|
|
|
|
|
Mike Hankey wrote: C was so efficient, faster and used less memory.
The last time someone told me that I challenged them to write code in C I couldn't write in C++.
I never got a response.
Real programmers use butterflies
|
|
|
|
|
Exactly, it's like going from B&W to Color. Yeah I'm old enough to remember.
|
|
|
|
|
i like this - "The less you need, the more you have"
|
|
|
|
|
Using a limited set of C++ means almost the same as C but more convenience and a simpler code syntax.
You could say you are writing in "C+"!
- I would love to change the world, but they won’t give me the source code.
|
|
|
|
|
I like that C/C++ is "multi-paradigm" and I wish C# were too.
|
|
|
|
|
C++ is anyway. I wouldn't say C is. It's got one mode - "the hard way"
Real programmers use butterflies
|
|
|
|
|
Part of it is historical reasons, part the perceived overhead of C++ vs C, and part requirements of various Standards (as others have mentioned).
For example, neither Linux nor Windows use C in the kernel, because C++ RTL support for the kernel code does not exist. I did see an article about using C++ in Windows kernel drivers. It worked, assuming that (a) you didn't use things like exceptions, virtual function, etc., and (b) you don't use any RTL function that is not defined in the driver library.
One place I would probably use C in preference to C++ is hard real-time code. Because of the polymorphism support in C++, it is easier to write code with ill-defined latency in C++ than it is in C, but programmers with sufficient talent can do it in both languages.
Freedom is the freedom to say that two plus two make four. If that is granted, all else follows.
-- 6079 Smith W.
|
|
|
|
|
I for one have written C code in C++ compilers from Day One of proper programming just saved them as C files, I have never seen or felt the need to do C++, from the day I wrote a program in Assembler, same in C and again in C++, C & Assembler can't really remember around the same size, C++ three times the size. Okay today better optimisation but still I always get the feeling with C++ theres more going on than I know about. (I do mostly embedded programming)
|
|
|
|
|
A recurring misconception I see about C++ appears to be the notion that it will write code that you didn't tell it to write, or use memory you didn't tell it to use.
It's simply not the case.
More the issue is, knowing what you're telling the C++ compiler to generate in terms of code.
To wit, there is no code that can be written in C that I cannot write in C++ and generate the equivalent machine instructions - even if doing so means giving up certain niceties like virtual inheritance, exceptions or run time type information.
RAII is reason alone to consider minimalistic C++ as an alternative to straight C. It generates no extra code, and it reduces lots of bugs.
Real programmers use butterflies
|
|
|
|
|
honey the codewitch wrote: RAII is reason alone to consider minimalistic C++ as an alternative to straight C. It generates no extra code, and it reduces lots of bugs.
Exactly
|
|
|
|
|
If you work in a team with young and eager programmers that completed their degree less than five years ago, there is one good reason:
These young geniuses usually love to play around with every single feature of the tools they are given. They like to experiment, and they love to prove that they truly master even the most obscure little detail of the language, the library, the VCS or whatever. So they strive to use all of it, in the most intricate ways that "impresses" even the old coding gurus.
C++ is not the language you would want to put in the hands of a young genius for proving that he can do something that no one else can do. You certainly can do dirty tricks in C as well, yet it is far more transparent than the "advanced" C++ features. (Besides, dirty C tricks often require that the programmer is very familiar with hardware and compiler operations, which is not as common with young programmers today, compared to thirty years ago).
So C is a better way to discipline young geniuses, by depriving them of tools to create incomprehensive code.
(Similar arguments can be used for staying away from git, or Docker orchestration, or CMake, or...)
|
|
|
|
|
Yeah. Though I might argue that an appropriate LINTing adjusted for dev-house practices upon check-in solves this and numerous other issues. Some developer education is necessary, but unless you can convincingly argue to me that a C developer is cheaper than a C++ developer, I'd just as soon hire the C++ developer, give them the set of practices, and LINT their code.
YMMV
Real programmers use butterflies
|
|
|
|
|
honey the codewitch wrote: What is the purpose of writing new code in C for targeting, well ... anything? You should use C because you are a witch, and love casting.
|
|
|
|
|
I use Cisms like casting in C++ because I am a witch and use C++ in places that weren't really meant for full fidelity C++.
Real programmers use butterflies
|
|
|
|
|
I was being facetious, because in C I believe you are often forced to cast where you don't in C++. IE, from one of my articles...
SwcTabCtrl* tabControl = (SwcTabCtrl*) tabsC[selectedTabC]; in C, whereas C++ is:
SwcTabCtrl * tabControl = tabsC[selectedTabC]; I don't remember the reason for the forcing of the cast, but I believe it is some C-ism. Anyway, I detest the first code with great detestation. You shouldn't, though, because you are a witch!
|
|
|
|
|
This has been more-or-less a peeve of mine between C++ and C#, but when it comes to casting, or for that matter, having to use (and know the difference between!) '->' '::' and '.', if find the effective dumbing down of C# unfortunate. So - if forced to cast, perhaps it's a way to keep all the ducks in order and also letting you know there are ducks.
Behind the scenes "promotions" make life easier (and in certain SQL I depend upon them) but understanding being built into the code is (in my opinion) a plus.
Ravings en masse^ |
---|
"The difference between genius and stupidity is that genius has its limits." - Albert Einstein | "If you are searching for perfection in others, then you seek disappointment. If you seek perfection in yourself, then you will find failure." - Balboos HaGadol Mar 2010 |
|
|
|
|
|
Yes. I agree. To not mention that with the "placement new" operator is possible to create objects on existing memory blocks. Turning off the exception mechanism C++ is very good for the development of real-time embedded applications. Recreating the polymorfism in C, at best, has the same speed as in C++. But most of the time, C++ beats C in many areas, as the latter does not have templates. It's only possible to emulate them with macros, but macros, most of the time, are ugly and dangerous. Templates help with performances: for example, qsort has to do a callback to compare items; so, it spends CPU cycles, fools the CPU branch predictor, and possibly invalidates the level-1 instruction cache. With std::sort (or std::stable_sort) it's possible "to inject" the comparison into the algorithm. Yes, templates could make code bloating, but judicious use of non-template base classes could mitigate it.
|
|
|
|
|