 |
 |
Apologies for the shouting but this is important.
When answering a question please:
- Read the question carefully
- Understand that English isn't everyone's first language so be lenient of bad spelling and grammar
- If a question is poorly phrased then either ask for clarification, ignore it, or mark it down. Insults are not welcome
- If the question is inappropriate then click the 'vote to remove message' button
Insults, slap-downs and sarcasm aren't welcome. Let's work to help developers, not make them feel stupid.
cheers,
Chris Maunder
The Code Project Co-founder
Microsoft C++ MVP
|
|
|
|
 |
For those new to message boards please try to follow a few simple rules when posting your question.- Choose the correct forum for your message. Posting a VB.NET question in the C++ forum will end in tears.
- Be specific! Don't ask "can someone send me the code to create an application that does 'X'. Pinpoint exactly what it is you need help with.
- Keep the subject line brief, but descriptive. eg "File Serialization problem"
- Keep the question as brief as possible. If you have to include code, include the smallest snippet of code you can.
- Be careful when including code that you haven't made a typo. Typing mistakes can become the focal point instead of the actual question you asked.
- Do not remove or empty a message if others have replied. Keep the thread intact and available for others to search and read. If your problem was answered then edit your message and add "[Solved]" to the subject line of the original post, and cast an approval vote to the one or several answers that really helped you.
- If you are posting source code with your question, place it inside <pre></pre> tags. We advise you also check the "Encode HTML tags when pasting" checkbox before pasting anything inside the PRE block, and make sure "Ignore HTML tags in this message" check box is unchecked.
- Be courteous and DON'T SHOUT. Everyone here helps because they enjoy helping others, not because it's their job.
- Please do not post links to your question in one forum from another, unrelated forum (such as the lounge). It will be deleted.
- Do not be abusive, offensive, inappropriate or harass anyone on the boards. Doing so will get you kicked off and banned. Play nice.
- If you have a school or university assignment, assume that your teacher or lecturer is also reading these forums.
- No advertising or soliciting.
- We reserve the right to move your posts to a more appropriate forum or to delete anything deemed inappropriate or illegal.
cheers,
Chris Maunder
The Code Project Co-founder
Microsoft C++ MVP
|
|
|
|
 |
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++.
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
|
|
|
|
 |
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.
|
|
|
|
 |
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: 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: The problem is that the accident has already happened and windows and linux are
already in C.
Which would be relevent except for the fact that windows has been re-written several times.
|
|
|
|
 |
The sources of win2k have been leaked. Download them and look at the code. It contains tons of legacy code even from win31. Not to mention the backward compatibility between windows versions. Windows has never been rewritten.
|
|
|
|
 |
I'm surprised no hackers from around the world has hacked into Microsoft(R) servers and steal every O.S. source codes or projects (or at least some of them), and them publish them on torrents. But Google, Bing, Yahoo and all those other people filter out those results and/or delete them. There probably has been private court orders of Microsoft vs. some hacker, stealing source. But I'm pretty sure Microsoft knows everything about security then any other security company out there combined, considering you have to send your driver to them to get it signed now. Basically Microsoft probably has there servers extremely hard to break through or breach, they probably have it to where if it detects a breach or unauthorized transfer of specific files, it disconnects the servers and computers and locks them down, terminating the hacking or suspicious signal. Who knows, they are probably smart and keep the internet cord unplugged, considering the fact that government leaks there "state of the art" F-35 blue prints on the internet, where everyone can see (technically, cause if there's internet, there's hackers), or maybe that's bogus that the government sent out to intentionally trick hackers into thinking they got the "real stuff", but who knows what crazy stuff tech companies do these days.
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
|
|
|
|
 |
Every OS contains tons of bugs, old bugs go, new ones come with the new features. Still the wast majority of security holes are caused by buggy networking applications and not by the OS itself. The more complex a networking application the more changes you have to have a security hole in your system. (For example a browser is quite a complex piece of software!!!) Anyway, several windows and internet explorer patches followed the windows source leaking, not without reason but because they had to fix a lot of discovered and (I suspect that) known but shelved (!!!) bugs that became obvious for the hackers from the sources!
|
|
|
|
 |
pasztorpisti wrote: like header files that terribly slow down the compile time Have you any proof supporting this sentence, regarding the C language?
pasztorpisti wrote: Again, the only reason for the existence of C/C++ is massive amount of legacy code This is an opinion (mine, for instance, is completely different).
Veni, vidi, vici.
|
|
|
|
 |
CPallini wrote: Have you any proof supporting this sentence, regarding the C language?
Yes, in the last years we had many times when we had to rearrange the header includes and optimize for compile times for our CI system. We compiled the codebase (~2millions loc) with a grid system (IncrediBuild) plus SSD drives in all machines in the grid and the compile time was still 20 minutes. By rearranging some header files we could decrease the build time to around 5 minutes. Thats what I'm talking about not some few file hobby projects that make no sense to measure such things.
CPallini wrote: This is an opinion (mine, for instance, is completely different).
And could you make a list of language features and compare that to some other languages that have better support for that? I see significant deficiencies in C++ comparred to some other languages, and its syntax because more-and-more complex with every new draft. A language that has redundant features and backward compatiblity with a thousand years old other language simply can't be "optimal".
|
|
|
|
 |
pasztorpisti wrote: Yes, in the last years we had many times when we had to rearrange the header includes and optimize for compile times for our CI system. We compiled the codebase (~2millions loc) with a grid system (IncrediBuild) plus SSD drives in all machines in the grid and the compile time was still 20 minutes. By rearranging some header files we could decrease the build time to around 5 minutes. Thats what I'm talking about not some few file hobby projects that make no sense to measure such things.
Still it is not a proof. You should compare it to the compilation time of a similar project written with your favourite language and achieving the same performance (if your favourite language could assist you on that).
pasztorpisti wrote: And could you make a list of language features and compare that to some other languages that have better support for that?
C and C++ are performant. No other language (other than assembly) compares with them. You should know that.
pasztorpisti wrote: I see significant deficiencies in C++ comparred to some other languages, and its syntax because more-and-more complex with every new draft.
While, for instance, C# syntax becoming simpler?
pasztorpisti wrote: A language that has redundant features and backward compatiblity with a thousand years old other language simply can't be "optimal"
Still is compatible.
I wouldn't call it 'optimal'. However I like it (this doesn't means I show apparent disgust for other languages - with the very exception of COBOL).
Veni, vidi, vici.
|
|
|
|
 |