|
How do you arrive at that conclusion? You do realize that comparing a framework with a programming language is quite illogical.
Perhaps you think that the code generated by a C++ compiler is less stable than that generated by a C# compiler? In what way? And why does that problem affect compilers across different releases and manufacturers?
Or you think that the libraries for C++ compilers are less stable than the .Net framework. Maybe, but how does that make C++ inferior? Let's just design a brand new framework for C++ and everything is well.
At least artificial intelligence already is superior to natural stupidity
|
|
|
|
|
1. C# gives better error messages. C++'s error messages are more often cryptic.
2. C# catches more errors at compile time than C++. At this point the error is clearer.
3. C#'s managed code has more context information (which may account for the better error messages.)
4. C#'s run-time checks give you an explicit error, as opposed to C++ where the reported error location (if a location is even given) is far from where the error occurred.
5. C#s code is more stable for reason 4; a C++ error (e.g. exceeding array bounds) may exist for years before it produces a crash or wrong results.
A better framework COULD be designed for C++; my comments were on the existing implementations.
"Microsoft -- Adding unnecessary complexity to your work since 1987!"
|
|
|
|
|
1. C++ really does not have a monopoly on stupid error messages. No matter where they turn up, I look them up in MSDN only twice: For the first and the last time. After that I know what they are about.
2. Really? What kind of errors are these? I can think of many cases where the compiler cannot distinguish between an error and intention and must assume that you know what you are doing. By design that's more the case for C++. You can't have both freedom and safeguards against unintentional mistakes at once, but that's a matter of preferences and not really a flaw.
3. I used to be quite capable to supply those myself quite easily with my own exception classes and error logging. It was not really hard to write an exception class, stuff it into a library and consequently use it.
4. Never had any problems with that. I came from assembly programming and was used to having no automatic checks at runtime. Instead of testing array bounds I usually preferred to ensure that the code to calculate the pointers to the item could not violate the bounds. Often by simple means like an assembly macro. Or by design, like using a byte as index for arrays with 256 items. Simple, safe, costs nothing Another way would be to code in a way that must lead to an exception unless everything is correct. 90% of all errors are avoidable, like forgetting to check for null pointers at the proper locations. If it is ensured that an exception will be raised, then those locations should be found during testing and then eliminated forever. This works very well for me. I have one recent web application that now has been running for 18 months without a single failed job.
5. By my experience thats true for every language and library, it's just the scenarios in which those errors occur that change. My best defense against that (also in managed languages) is to keep the code as simple and straightforward as possible. No design for design's sake. No heaping one framework upon another. And, of course, a layer where no error gets past without being recorded, preferranly with as much information as possible. In a way I have turned every operation of the application into a unit test. A transparent design, a few practices and monitoring your application is all that is needed.
At least artificial intelligence already is superior to natural stupidity
|
|
|
|
|
If you're not putting debug prints into your crashing code, you're not doing it right. XD
I think this is the OP's main problem. He's expecting his compiled exe to tell him what's wrong instead of figuring it out himself. It's really not that hard to log some basic info to a text file... or even to the console. You'll know exactly where the crash happens because debug statement X was never printed. *shrug* Just seems like bad programming IMO. I love C# personally, it's quick and easy for simple tools but it's by no means a replacement for C++.
|
|
|
|
|
Please, please, please stick to C# programming.
It sounds like you're not cut out for C++ development.
|
|
|
|
|
I have never had a problem haunt me for weeks.
Post your code here for review. I'm certain I could fix it in a few minutes.
I can write C# code that would haunt you for weeks.
As far a feeling alone. I'm certain that you are not alone. I work with other engineers who are stuck a Perl. When they try Python or C#, there are too many problems to solve. They will tell you that Perl is easy and doesn't have any problems.
Take an assembly language class. I think it will illuminate just what computers do.
|
|
|
|
|
I am an informatic engineer i do know how computers work, and I have made several programs in asm
|
|
|
|
|
I promise you that you surely don't know what you are talking about. The symptom you are describing is an operating system issue. You are:
step one - missing dlls. C++ Builder will alter the environment variables to account for any dlls you are dependent on.
step two - when your code is in the wild, it needs the dependent dlls. That includes any dlls that you have written and the C++ Builder C/C++ runtime dlls.
step three - if you were using Visual Studio, you would need to install vcredist when running wild.
step four - Java, C#, Python... all have their issue that correspond to this one.
step five - Don't post here and ask for help and then argue with the people who are trying to help you. You come off arrogant and based on your first post, you don't have the right to be that arrogant.
If you hate C++, try C#. If you know C#, stick with C#. Just know that you won't be able to do anything outside the sandbox.
|
|
|
|
|
I have seen a lot of guys here that doesnt have a clue of what they are talking about.
C# its not a sandbox, after passsing an enormous amount of time porting C lines to C#
(ak NEHE lessons to my game engine)
i realized that there are almost anything that c\c++ can do that c# doesnt
you can use pointers(althought not encouraged)
you can system make dll calls,
working with data streams is a wonder, if you havent tryed try it.
The only thing is that you lose control not in doing a task you lose control in how is done.
Just tell me one thing that c/c++ can do that c# dont(please dont tell me inline asm)
|
|
|
|
|
Vasily, by definition, C# is a sandbox. That is what managed code means. You run in a sandbox and don't have access to the process space. Sandbox. Got it?
So, you want one thing? Write me a device driver in C#.
Another? Write me an HTTP server that can handle 100,000+ simultaneous connections. I can do that in C++ using overlapped IO and completion ports. I hear the same arguments from the Java guys. My Grails on Groovy on Java framework can handle 200 simultaneous connections and it doesn't matter because I can throw more hardware at it. Do you have any idea how many machines you will need to replace the 1 C++ machine?
You talk about making system DLL calls. What do you think those DLLs are written in? And, BTW, if you don't have the C/C++ run-times installed, those DLLs will not load either. I gave you the solution to your problem.
I use QT. QT's streams are a wonder as well. And you know what, they are a lot faster too. QT and C# with WPF gives you declarative programming. Guess what, C++ and QT are much faster again. Both are equivalently trivial.
You allude to an idea that I don't have a clue. Go back and read what I wrote about insulting people when you make a bold statement and then try to argue the point. My guess is you are about 15 years old. You are learning to program and you still have holes in your knowledge. Me, I'm 50 years old. I've been doing this since the Apple II days. I've done mainframe. I can do assembly, PASCAL, PL1, C, C++, C#, Perl, Python, JavaScript, Java, HTML, device drivers, DLLs, servers, clients, OpenSSL, mobile devices, and much more. I can do all this stuff on Windows, Windows CE, MacOSx and Linux.
Oh, and BTW, you can't do inline ASM.
M
|
|
|
|
|
I stand corrected. You are older and not 15.
|
|
|
|
|
It is alwayas good a people that have a lot more knowledge and experience than you to shut your mouth.
I was not insulting you i just can see how superior is c++ because you can make device drivers on it in that case, i can argue than asm code is superior to c++ because you can make device drivers and its more flexible. and you will tell me that you are not productive with asm, the same thing i tell you with c++ and C#
c++ is to computer programming like php for web programming, they are OLD, misconceived, with a lot of patches, modified on the run, the syntax is awfull and yet eveyone says is wonderfull because everything is built on that. That is not an argument at least for me
You tell me that c++ code is a lot faster, and I recommend you to read some articles because in a lot of use cases c# is faster.
and BTW
Inline assembly was a technique that enabled C++ programmers to put I386
assembly language directives into the C++ code. It was a horrible hack that
made all kinds of assumptions about the processor (in a portable language?)
and was used quite often when something fast and low-level was needed.
|
|
|
|
|
Why don't you just once speak for yourself? Never mind what your Guru has to say about anything. How many years have you done all those things? On how many different systems? All what you say may apply to you. You may not be productive with something. You may be too lazy to learn and understand the fundamentals before relying on all kinds of mechanisms and gadgets. You may be helpless when those things fail because you don't have a clue what might be going on.
Don't be so arrogant to assume that everybody is like that. Many of us have forgotten more about those things than you have ever known and done those things when you still were a possibility in the gene pool. And you don't have to take our or any Guru's word for it. We can prove it.
At least artificial intelligence already is superior to natural stupidity
|
|
|
|
|
Inline asm allows a developer to access hardware that the c/c++ could not access. An example of this is the CPUID machine instructions. Before C#, if you wanted information about your hardware, you would write something like this.
unsigned long value;
_highestFunction = 0;
union VendorUnion
{
unsigned long vendorLong;
unsigned char vendorArray[4];
} vendorTail;
unsigned char temp;
__asm
{
mov eax, 0x00
cpuid
mov value, eax
mov vendorTail.vendorLong, ecx
}
_highestFunction = value;
temp = vendorTail.vendorArray[0];
vendorTail.vendorArray[0] = vendorTail.vendorArray[3];
vendorTail.vendorArray[3] = temp;
temp = vendorTail.vendorArray[2];
vendorTail.vendorArray[2] = vendorTail.vendorArray[1];
vendorTail.vendorArray[1] = temp;
switch (vendorTail.vendorLong)
{
case 'ter!': _vendorID = eAMDK5; break;
case 'cAMD': _vendorID = dAMD; break;
case 'auls': _vendorID = eCentaur; break;
case 'tead': _vendorID = eCyrix; break;
case 'ntel': _vendorID = eIntel; break;
case 'Mx86': _vendorID = eTransmeta; break;
case 'aCPU': _vendorID = eTransmeta; break;
case ' NSC': _vendorID = eNationalSemiconductor; break;
case 'iven': _vendorID = eNexGen; break;
case 'Rise': _vendorID = eRise; break;
case ' SIS': _vendorID = eSiS; break;
case ' UMC': _vendorID = eUMC; break;
case ' VIA': _vendorID = eVIA; break;
}
unsigned long _eax, _ebx, _ecx, _edx;
__asm
{
mov eax, 0x01
cpuid
mov _eax, eax
mov _ebx, ebx
mov _ecx, ecx
mov _edx, edx
}
if (_highestFunction >= 3)
{
__asm
{
mov eax, 0x03
cpuid
}
}
Writing that same code in pure ASM would be a pain but in this case, you can use the higher level language when appropriate but use the assembly to access the hardware. The ASM being platform dependent is irrelevant at this point because that is the point. The only time that C# or Java can outperform C++ is when a loop is being performed and the VM can rearrange the byte codes to predict execution. C++ is statically built so the speed is constant. Other than that, I am aware of no instances of C# or Java being faster than well written C++.
|
|
|
|
|
So, you're saying you can still "do" PL1? (Actually, it was PL/I; which I "did").
What you "did" and what you can "do" (expertly) today are two different things.
While I may have been an "expert" 1401/7010 Autocoder at one time, mentioning it today is meaningless.
|
|
|
|
|
I would not be be able to code PL/I at the level I was doing it in the 80's. Although I still remember segments of PL/I, JCL and ISPF. I wrote channel drivers. I wrote an implementation of Kermit in PL/I. Yeah, I think I had it wired. Today, I'd have to get reacquainted with it again. I was definitely an expert and was made the IBM mainframe advisor for General Dynamics Western Division.
As far as meaningless, I disagree. One of the strengths I bring to a job is the vast diversity of languages I've used. There is nothing new under the sun and I've reverted to ideas that I was exposed to, to implement "novel" things today. I am not familiar with Autocoder but I'm certain there were novel constructs that would be applicable to solving problems today.
I started C++ with CFront on MPW. I've been with it to the present. However, it isn't a one tool fits all. I use other tools when they make sense.
The aversion to the "I hate C++" post is due to the history of seeing this posted and then accepted as fact. I work for Qualcomm. I use C and C++ a lot. When I recruit at local technical colleges and the hardest thing they have had to develop with is Java, I find it hard to take the student's education seriously. I want to see students who know assembly. Not so that they can code in it, but to demonstrate they have some knowledge of what is going on underneath the covers. We want to know that the person has the ability to resolve issue not only at the software level, but at the hardware level as well.
But to answer your question, I do a lot of things expertly. I've worked on many projects that has personally affected you or those around you.
|
|
|
|
|
Vasily Tserekh wrote: please dont tell me inline asm Why not? The ability to take control of the generated code locally and without having cumbersome calling conventions or even Win32 Interop wrappers or any marshalling of data types allows very precise and effective optimizations. I know you think that processors are fast enough now, but that's a very strange thing to hear from somebody who wants to write game engines. Anyway, there are also far more limited devices, like microcontrollers, where you cannot afford to be wasteful or the comfort you are so much accustomed to.
What next? Oh, yes, C++ includes C. That allows to simply forget about OOP. I know, the Guru you have learned from now has a heart attack and you are probably about to faint, but that actually can be a good thing. It makes the generated code smaller and the additional performance overhead for objects is also eliminated. Again, this is a blessing when you are working on slower devices. If you must you can do that, C# will never allow you to go there. But that's ok, because those devices often would not be able to host the .Net framework anyway.
Has the Guru recovered yet? Ok, let's have some multiple inheritance in C++ then. I can inherit from several baseclasses? Oh yes, that can be problematic, but it's really helpful when you know what you are doing. And spare me a lecture about interfaces. An interface is nothing more than a purely abstract baseclass and I have to implement it separately when several classes inherit from it. And that very quickly leads to one of my oldest enemies called redundancy. Once again, C# will not allow you to do something because some guy at Microsoft considered all of us too dumb to use it correctly.
Now let's finish the poor Guru off, shall we? While it's not quite so bad as with those Java guys whose religion obviously forbids even thinking of managing memory, but what makes you guys think that entrusting the management of one of the most essential resources in the entire system to some dumb mechanism like a garbage collection is a good idea? That thing takes its share of both memory and the CPU just to find out what might now be freed up. C++ gives you both the privilege and the responsibility to take your object's lifecycle into your own hands. Memory is allocated precisely when you need it and released precisely when you want it to. So, what are you going to do when you have produced a memory leak? That's not quite as impossible as both the Java and .Net Gurus would like to have you believe. How do you find it? How does the great framework assist you? And what means do you have to take things into your own hands if that's the only solution? You probably will have to get stuck big time before you understand that a little comfort and some blissful ignorance are worth that trouble.
And last, good old C++ will allow me to allocate and access data in memory far more efficiently than in a managed environment. With real primitive data types (which are not classes) I can construct data structures that take not a byte more or less than intended. And then I will use pointer arithmetic to access the data and even optimize the calculations of those pointers by adjusting the structures' size so that I can use shift operations to calculate the pointers instead of far slower multiplications. In short, I will get more data into the same memory and access it faster than you ever will by stuffing it into collections. Have you ever heard of a game engine where that was no issue at all?
Let's stop here for now. I have torn down enough of your Guru's holy icons and don't want to have the poor man on my conscience
At least artificial intelligence already is superior to natural stupidity
modified 27-Apr-12 13:39pm.
|
|
|
|
|
http://fbe.am/5JO[^]
if you are so clever why dont you tell me whats wrong here!!!!
CDP1802 wrote: With real primitive data types (which are not classes) I can construct data structures that take not a byte more or less than intende
Have you ever studied .NET interop namespace and marshalling, read a little bit an then post a clever answer
|
|
|
|
|
I can barely restrain myself
What is it? Another one of your failures? And what does it have to do with our topic? Right now I have the impression that you are a very entertaining spambot
At least artificial intelligence already is superior to natural stupidity
|
|
|
|
|
(from the code in your link)
void TfrmMain::GetDir()
{
TFileListBox * ListBox = new TFileListBox(this);
frmMain->InsertControl(ListBox);
AnsiString way = ListBox->Directory;
way=way+" audio";
way[way.Length()-5]=92;
dir=way;
way=way.SubString(0,way.Length()-6);
ListBox->Directory=way;
frmMain->RemoveControl(ListBox);
}
If it's your code, I think you may want to learn a little more before complaining about C++. One thing you certainly should take into account is that C++ is not a managed language and constructing objects and never deleting them will lead to memory leaks.
|
|
|
|
|
Situations like those are when I usually pull down the OS symbols and install them. Break the app in the debugger while the errant error dialog is being displayed and look at the stack trace. One can't necessarily debug the OS code with the symbols, but they allow an accurate stack trace report to be generated by the debugger. NT's function names are remarkably informative. Between the function names and google, and I can often get a pretty good clue about what the OS is trying to do on my behalf. Occasionally, when I'm really lucky, I can even look at the parameter values being passed (when the deubgger deigns to report them) and start to figure out what's wrong.
Then, there's always printf's. Or the GUI equivalant, MessageBox() calls. Make them unique and try to bracket the line of your code that's causing the error. And the best part, no debugger is required -- you can even debug fully optimized production code if you have to (how else does one find an optimizer bug?).
Or you can do as suggested, comment out blocks of code in a sort of binary search for the troublesome line... although I find that a lot harder to do in practice than the above techniques.
We can program with only 1's, but if all you've got are zeros, you've got nothing.
|
|
|
|
|
The point the other two posters were making is that there are two exe files created. One in the debug folder and one in the release folder. Both are application folders. The one in the debug folder should work just like the IDE launch.(I'm not sure breakpoints are reccognized outside the IDE. I seem to remember not without linking to the mapping file. Don't remember the file type, but if you map to it and blow up, the IDE is brought up for you and your local environment at the time of blowing up is available for viewing. I read how to do this in 2005, very useful at the time, got away from programming for a while so don't remember how that is done)
So, you KNOW you are double-clicking the DEBUG folder's version of the code and it doesn't work? Do you know how to bring up the IDE from a double-click?
Earlier, you said the drive letter you started from is causing the problem. From that, I assumed you started the app from a cmd file. Since you are double-clicking, are you navigating to the drive causing the problem in the app? If not, how do you know it is a drive permission problem?
|
|
|
|
|
Your environment may be different when you run the debugger verses just launching the exe file. Check "PATH" when executing both. Also, as I use to do, kill the program with print statements. You can do a "binary search" with print statements. One at the beginning, one in the middle and one at the end of the program. See which one prints and move them around accordingly.
THE OLE HACK
|
|
|
|
|
Did you try compile your code with other IDE?
|
|
|
|
|
Vasily Tserekh wrote:
yes I know but at least in managed languages you
get a nice error message not a blank error messsage, thats why I hate c++
You "hate" C++ because you don't understand it.
To be clear, in .NET languages like C# and VB.NET (and similarly in Java), when there is a unhandled fault, the end user is presented with a exception that includes a stack trace. Generally you would never want a end-user to see a stack-trace.
You can get exactly the same thing in C++ if you choose to, but it requires additional work that is done for you in a managed environment. Generally stack traces are available in a debugger.
/* Charles Oppermann */
http://weblogs.asp.net/chuckop
|
|
|
|
|