|
Can someone tell me why C++ and C programming languages are used than any other programming languages, what can these languages do that others can't. I do know that C can create drivers or system files, which is very important when you become serious about your projects. But why is the industry still use it? And will C or C++ ever die, even though it's a non-stop updating language everyday, and what other languages update just like C/C++.
EDIT:
While also asking this question, will C++/CLI take over or kill out Standard/Win32 C++?
Cause I'm on a website called Codejock Software, looking for a ribbon control to work for Standard/Win32 C++ only, and I can't find it. Most of the controls are only made for C++/CLI.
Simple Thanks and Regards,
Brandon T. H.
Programming in C and C++ now, now developing applications, services and drivers (and maybe some kernel modules...psst kernel-mode drivers...psst).
Many of life's failures are people who did not realize how close they were to success when they gave up. - Thomas Edison
modified 3-Oct-12 14:46pm.
|
|
|
|
|
Brandon T. H. wrote: what can these languages do that others can't.
Directly access the hardware, directly manage memory, and create high performance code.
(As opposed to managed languages)
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
Brandon T. H. wrote: But why is the industry still use it?
because it still works.
Brandon T. H. wrote: even though it's a non-stop updating language everyday, and what other languages update just like C/C++
C++ has had all of four official standard changes since 1998.
|
|
|
|
|
Stop worrying about mortality, it's of little use.
Steve
|
|
|
|
|
If you know them then you know the reason why.
On the other hand, if you don't know them, it's time to learn.
Veni, vidi, vici.
|
|
|
|
|
The C and C++ languages are disastrous. They leave so many doors open for bugs and programming mistakes and they have other design failures (like header files that terribly slow down the compile time). The only valid reason for their existence is that most of today's libraries and operating systems are written using these languages. The interface of the majority of libraries and operating system APIs are still C based. Even if you try to replace these languages I think you need 3 different languages to build a whole operating system up on top of bare hardware. A minimal amount of assembly to communicate with hardware, a thin layer of relatively high level but unsafe language that allows for manual memory management in the low-level part of the operating system, and a high level safe language that can be used to write the top level of the operating system and the user programs. C/C++ could be something like the middle from these 3 languages but it would be easier to design a much better language than C/C++ with the same capabilities. Again, the only reason for the existence of C/C++ is massive amount of legacy code.
EDIT: This post of mine became quite 'popular', for this reason I would like to link one of my other posts that contains a more comprehensive (but not full) list of my reasonings at the end of this quite long debate: http://www.codeproject.com/Messages/4377527/Re-What-makes-C-and-Cplusplus-a-good-language.aspx[^]
Also would like to mention that I have extensive background in low level programming including assembly, C, and C++, reverse engineering and I'm not a 'just because'-type of hater of C/C++ who used only scripts and managed languages - I don't hate C/C++ at all. I respect these languages because they have been fun for me to program in, they helped the world to become better, but we have to see their obvious defects as well. Thanks for reading.
modified 25-Sep-12 8:47am.
|
|
|
|
|
pasztorpisti wrote: The C and C++ languages are disastrous. I think this is rather unfair. C was created to make the writing of operating system code much easier; C++ was an improvement but still based around the same design goals. The fact that people wrote other programs using those languages is the fault of the developers rather than the languages. Yes, there are shortcomings compared with some modern languages, but neither C nor C++ were designed to do some of the work that people expect of it these days.
One of these days I'm going to think of a really clever signature.
|
|
|
|
|
If we speak of a massive codebase like one that an operating system has then the build time and header hell are alone enough to say that C/C++ is a bad choice. The problem is that the accident has already happened and windows and linux are already in C. The difficulties in parsing and translating C++ just add to compile times and project complexities. In theory it would be easy to design a language that is suitable for writing operating system code without several defects that accumulated in C/C++ over the decades (because of its backward compatibility) so I think my statement isn't unfair at all. Not to mention the different C/C++ languages per compiler, this language isn't compatible even with itself in practice!
|
|
|
|
|
pasztorpisti wrote: enough to say that C/C++ is a bad choice. When it was chosen, it was the only choice.
pasztorpisti wrote: In theory it would be easy to design a language that is suitable for writing operating system code without several defects I worked for a company (Sperry) that did just that. They spent thousands developing a language that had no practical use except for writing their operating system, which was fast reaching the end of its useful life.
pasztorpisti wrote: I think my statement isn't unfair at all. I meant it was unfair in that you were judging a language developed in the 80s by the standards of today's knowledge and technology.
One of these days I'm going to think of a really clever signature.
|
|
|
|
|
Richard MacCutchan wrote: When it was chosen, it was the only choice.
Today its not the only choice. Some people choose it because they don't know its defects, or they don't have other choices to develop low level code, and because of the big masses of legacy code.
Richard MacCutchan wrote: I worked for a company (Sperry) that did just that. They spent thousands developing a language that had no practical use except for writing their operating system, which was fast reaching the end of its useful life.
We don't know how good that language was. Its not sure that the language was good. Even if something is good, it doesn't mean it becomes widespread. "The rich gets richer." as the C/C++ becomes more and more widespread.
Richard MacCutchan wrote: I meant it was unfair in that you were judging a language developed in the 80s by the standards of today's knowledge and technology.
If we were speaking about its application in the 80s then it would be unfair. Since we are speaking about its application today its not unfair to say that the only thing that keeps it alive is legacy code. Its just telling the cruel truth.
|
|
|
|
|
pasztorpisti wrote: Today its not the only choice. Quite true, and I never disputed this.
pasztorpisti wrote: We don't know how good that language was. I do, It was OK and somewhat similar to C, but so specialised it had no chance of being used on any hardware other than the 1100/2200 range.
pasztorpisti wrote: its not unfair to say that the only thing that keeps it alive is legacy code. There are still lots of new developments being done with C and/or C++ because people think they are the right language for the job, despite their many shortcomings, so in that respect it probably is unfair.
One of these days I'm going to think of a really clever signature.
|
|
|
|
|
Richard MacCutchan wrote: I do, It was OK and somewhat similar to C, but so specialised it had no chance of being used on any hardware other than the 1100/2200 range.
The low level language I was dreaming about is general purpose like C. If that language was hardware specific then its death is natural when the hardware goes out of production because its not a general purpose lang, its rather a high level assembly for the target hardware.
C is quite general purpose to be able to translate to any processors. By fixing some things in C++ and removing the header hell (by using units like in pascal) it could be a very nice low level language.
Richard MacCutchan wrote: There are still lots of new developments being done with C and/or C++ because people think they are the right language for the job, despite their many shortcomings, so in that respect it probably is unfair.
One of these days I'm going to think of a really clever signature.
Many people choose this language because today this knowledge is quite useful because of the legacy codebases and because it is recommended by their friends. Because of this C/C++ is still the "native language" of many and they use this because they know this, not because they think that it is a better choice than x and y because they simple don't know about x and y as an alternative. The ugly truth is that because of the legacy codebase often C/C++ is the best choice, but this doesnt mean that its a best choice because its a nice language.
|
|
|
|
|
pasztorpisti wrote: Today its not the only choice
So what language would you choose today to write a new OS in ?
...cmk
The idea that I can be presented with a problem, set out to logically solve it with the tools at hand, and wind up with a program that could not be legally used because someone else followed the same logical steps some years ago and filed for a patent on it is horrifying.
- John Carmack
|
|
|
|
|
Today there are sh*t loads of OSes, why would you want to write a new one? Anyway, 99% of the ongoing projects is not an operating system so you can pick from lots of other popular languages. In one of my previous posts I mentioned that there is no other similar low level language however by fixing some issues with C could result in a good one to write driver level stuff.
|
|
|
|
|
pasztorpisti wrote: Today there are sh*t loads of OSes,...
None of which answered the question.
|
|
|
|
|
I answered the question, you just forget to quote the end of my post. My posts are not advertising that we have true alternatives in every areas where C/C++ is used. I just mentioned that even in the areas where C/C++ has monopoly better alternatives could be forged with todays knowledge.
|
|
|
|
|
No I don't see that answered.
Again if you were writing a OS today which language would you pick to write it in?
|
|
|
|
|
If I had to keep source and/or binary level compatibility then probably C. If I had total freedom then assembly and a new C-like language that has the unambiguous problems of C fixed.
|
|
|
|
|
So you would create a new language to create your new OS.
Have you created a language like C before? And written the support libraries for that new language?
|
|
|
|
|
Yes I created a compiled and a dynamic languages as hobby projects but that time without much focus on design and safety. Havent created a full fledged runtime support though. Anyway, if you are about to create a new OS then its not a big deal to put together a C like low level language with the base libraries as a first step. The complexity of the compiler+lib and the OS are not comparable especially if we make use of a tool like gcc or llvm.
|
|
|
|
|
pasztorpisti wrote: Even if something is good, it doesn't mean it becomes widespread
However the reality is that something that is in fact substantially better will become widely used.
And something that isn't will be tossed away.
There are all sorts of failed technology choices. And just a few winners.
If C/C++ were that bad then they would not have continued to retain the market share that they do.
|
|
|
|
|
I think I already answered this in a previous post. C/C++ simply can't be purged because of the huge legacy codebases. Better alternatives exist, the nearest to C++ is the D language. Its simple isn't used because it doesn't have library support that could compare to the legacy codebases for C++.
|
|
|
|
|
pasztorpisti wrote: think I already answered this in a previous post. C/C++ simply can't be purged
because of the huge legacy codebases.
And as I already said history is SPECIFICALLY full of cases where exactly that has happened.
So obviously it can happen.
pasztorpisti wrote: Its simple isn't used because it doesn't have library support that could compare
to the legacy codebases for C++.
Wrong. It isn't used because developers have not found an advantage to using it.
You do understand that there are many C++ developers and yet C (not C++) continues to be used significantly? Do you understand how C++ was adopted over time to take over much of the work previously done by C++ and yet C by itself continues to be used? The first part of that puts lie to your contention that legacy code preclude new adoptions and the second to your assertion that something that is better in some way must always universally replace the older because there no longer is any value.
|
|
|
|
|
jschell wrote: And as I already said history is SPECIFICALLY full of cases where exactly that has happened.
So obviously it can happen.
There is something in your statement. I guess languages are gone when they roots die. C/C++ have currently strong roots (at least Windows/*nix systems).
jschell wrote: Wrong. It isn't used because developers have not found an advantage to using it.
I still think this is partly because of library support and development environment support. Its also a high risk to start a commercial project with something new that can blow. Lets imagine a fatal D compiler crash (without the support of the authors) in the middle of your project! Startups are very slow for these simple reasons.
jschell wrote: You do understand that there are many C++ developers and yet C (not C++) continues to be used significantly? Do you understand how C++ was adopted over time to take over much of the work previously done by C++ and yet C by itself continues to be used? The first part of that puts lie to your contention that legacy code preclude new adoptions and the second to your assertion that something that is better in some way must always universally replace the older because there no longer is any value.
I guess you wanted to write C# when you were talking about the language that took over some of the work of C++. C# can became widespread (relatively quickly) because its supported by a huge rich company. Its library support is good, its IDE is superb. These give the base of one of your reasonings in a previous post: This language gave something. It made development easier and less risky because of the MS support. Noone makes you so nice IDE for D like the one you have for C#, same is true about support. Its not only the "coolness" and efficiency of the language that makes it widespread, money and/or time is also needed.
As I mentioned previously I like the simplicity of C, by modifying it a bit (without keeping the ugly backward compatibility) I think it could be a very nice language for low level coding where C++ and its friends were too high.
|
|
|
|
|
pasztorpisti wrote: C/C++ have currently strong roots (at least Windows/*nix systems).
Based on that then C/C++ will never cease to exist because there is no expectation that either or both of those OSes will cease to exist.
pasztorpisti wrote: I still think this is partly because of library support and development environment support.
Nope. If that was the case then Java/C# would have taken over.
pasztorpisti wrote: Lets imagine a fatal D compiler crash
I can't speak specifically about D but these days any marginally significant new language will not "crash" when it is released into the public in such a way that it would endanger a product. If it crashes at all then it is probably due to a language construct which can be worked around.
pasztorpisti wrote: I guess you wanted to write C# when you were talking about the language that took over some of the work of C++.
No. I was specifically using the example of when C++ became widely known and C (not C++) was the predominant language. C++ rapidly gained market share. Yet C did then and still does retain a significant market share.
This demonstrates that there is a shift when the market sees a better language come along DESPITE the extensive code base. It also demonstrates that C still finds and audience because it is still used. Thus it STILL provides a benefit that developers can appreciate.
|
|
|
|