Really frustrated when moving from C# to C++
-
And even worse, pointers do exist in C# and work very much the same way.
"I just exchanged opinions with my boss. I went in with mine and came out with his." - me, 2011 ---
I am endeavoring, Madam, to construct a mnemonic memory circuit using stone knives and bearskins - Mr. Spock 1935 and me 2011CDP1802 wrote:
And even worse, pointers do exist in C# and work very much the same way.
That depends on a specific definition of some of the terms in the statement however. The following comes from the C# Language Specification in the Unsafe Code section. "The core C# language, as defined in the preceding chapters, differs notably from C and C++ in its omission of pointers as a data type. Instead, C# provides references and the ability to create objects that are managed by a garbage collector."
-
You're really gonna miss the String class. :)
- S 50 cups of coffee and you know it's on! Code, follow, or get out of the way.
Steve Echols wrote:
You're really gonna miss the String class
Why? STL has a perfectly good implementation of string handling.
Forgive your enemies - it messes with their heads
My blog | My articles | MoXAML PowerToys | Mole 2010 - debugging made easier - my favourite utility
-
Real programmers don't use
CString
s. In fact real programmers don't use strings at all. :-\If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
[My articles]CPallini wrote:
In fact real programmers don't use strings at all
Real programmers just use really thin ropes?
Forgive your enemies - it messes with their heads
My blog | My articles | MoXAML PowerToys | Mole 2010 - debugging made easier - my favourite utility
-
Steve Echols wrote:
You're really gonna miss the String class
Why? STL has a perfectly good implementation of string handling.
Forgive your enemies - it messes with their heads
My blog | My articles | MoXAML PowerToys | Mole 2010 - debugging made easier - my favourite utility
So does ATL/WTL/MFC/Boost. My point was that String is not built into the language, so when you're bouncing between different project types, you're always have to adjust, because they're all a little bit different.
- S 50 cups of coffee and you know it's on! Code, follow, or get out of the way.
-
CPallini wrote:
In fact real programmers don't use strings at all
Real programmers just use really thin ropes?
Forgive your enemies - it messes with their heads
My blog | My articles | MoXAML PowerToys | Mole 2010 - debugging made easier - my favourite utility
:laugh:
- S 50 cups of coffee and you know it's on! Code, follow, or get out of the way.
-
There are two ways to look at this, either: a) once you have figured out how pointers and referencing works (in which case you'll be a "man") --or-- b) you just give up as it is too complicated There is a very real difference between groups a & b. The people who write .net understand this stuff, they handle it for you (for the most part). If you have any interest in your craft, it will be good to get to grips with this stuff. When the penny dropped for me (back when I was at uni) it was like a moment of zen enlightenment, it tied together several parts of disparate courses: it bridged the gap between chip design & assembler and the higher level stuff we'd been doing elswhere. Although I found it interesting for its own sake, I still find this stuff useful ten years on. It makes learning new langauages easier for one thing.
Sort of a cross between Lawrence of Arabia and Dilbert.[^]
-Or-
A Dead ringer for Kate Winslett[^]Like learning to drive with a stick. If you can drive a stick you can drive anything!
Semper Fi http://www.hq4thmarinescomm.com[^]
www.jaxcoder.com[^] WinHeist -
Yes... and your point is?
-
You shouldn't reveal we C programmers are not friendly with intruders.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
[My articles]Just giving him a little heads up. :)
"Real men drive manual transmission" - Rajesh.
-
Mostly because of how pointers and references work, and also function definition seems very different. :((
I recommend Data Structures and Algorithms Using C++ (Second Edition) (one is available in new condition for $25). Pages 3-4 and 15-30 cover pointers and reference variables very well (I was just reminiscing yesterday about my C++ days and read a few pages from this book :-O ).
-
CPallini wrote:
In fact real programmers don't use strings at all
Real programmers just use really thin ropes?
Forgive your enemies - it messes with their heads
My blog | My articles | MoXAML PowerToys | Mole 2010 - debugging made easier - my favourite utility
Nope: they use topological defects of the Universe.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
[My articles] -
bob16972 wrote:
and instead ended up trying to "fix" what was wrong with copy Java.
FFY.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
[My articles] -
Trollslayer wrote:
Python
we're talking about programming languages, aren't we? :rolleyes:
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
[My articles] -
Trollslayer wrote:
I've just moved to Python
*Danger* Euphemism alert *Danger*
Forgive your enemies - it messes with their heads
My blog | My articles | MoXAML PowerToys | Mole 2010 - debugging made easier - my favourite utility
-
Mostly because of how pointers and references work, and also function definition seems very different. :((
And you haven't even scratched the surface... The frustration will last for another five years aftetr which, if you make it through, you might get addicted.
FILETIME to time_t
| FoldWithUs! | sighist | WhoIncludes - Analyzing C++ include file hierarchy -
And you haven't even scratched the surface... The frustration will last for another five years aftetr which, if you make it through, you might get addicted.
FILETIME to time_t
| FoldWithUs! | sighist | WhoIncludes - Analyzing C++ include file hierarchyWait until the OP finds out you can't put two greater than signs next to each other when using templates without the compiler barfing. :)
-
My observation is that people who discount the importance of knowing how things really work (i.e. how things work in the absence of an unseen, out-of-thread garbage collector) tend to be people who look at everything from a very PC-centered perspective. On a PC, or anything resembling a PC, it probably does not make sense for application code to need to do anything special just to effect proper garbage collection. But a real computer scientist, or even a reasonably good (i.e. versatile) programmer, should realize that not everything is a PC, and that there is value to being able to run things on devices that are not PCs (e.g. microcontrollers retailing for $2). This is just one of a whole family of spurious, PC-centric arguments I see on the Internet, which has, after all, become a network largely comprised of PCs. Statements like "every application should have logging" or "every application should be OO" fall into the same category. Such assertions really seem nonsensical if one considers the code that runs inside of digital wristwatches, DVD drive controllers, and such.
Can you really blame them? That's what everybody keeps teaching them. And they are used to having a comfortable IDE, a big fat framework, strong mulitcore processors with a strong GPU to help out, a few gigabytes RAM and a few terabytes mass storage at their disposal. This also means that they are used to clubbing down many problems simply with brute force and getting away with it. And when they don't get away with it, they usually are at a total loss to explain why, since they have done everything the right way.
"I just exchanged opinions with my boss. I went in with mine and came out with his." - me, 2011 ---
I am endeavoring, Madam, to construct a mnemonic memory circuit using stone knives and bearskins - Mr. Spock 1935 and me 2011 -
Wait until the OP finds out you can't put two greater than signs next to each other when using templates without the compiler barfing. :)
But of course you can[^]! I've once stumbled over some guru discussion about the different ways to solve that, make it compatible with the existing C++ standard, figuring out side effects and code that might break silently etc. It's downright scary-amazing to see how complicated it is to fgit such a fix in.
FILETIME to time_t
| FoldWithUs! | sighist | WhoIncludes - Analyzing C++ include file hierarchy -
You're really gonna miss the String class. :)
- S 50 cups of coffee and you know it's on! Code, follow, or get out of the way.
What's so bad about CString? ducks
FILETIME to time_t
| FoldWithUs! | sighist | WhoIncludes - Analyzing C++ include file hierarchy -
Interesting, I hadn't considered the problem it that way, and I think for your points are valid. That said, I've only really developed for PC and I've only really been a .net developer professionally, I enjoy tinkering with other languages and I miss c++, which I use to write my dissertation. I think the deepest separation is between those who like programming and computing for its own sake, and those who do it solely as their day job. I think a large proportion of the latter group fall into your PC-centric category as this is what pays and what is easiest to get work in. Got my 5 anyway!
Sort of a cross between Lawrence of Arabia and Dilbert.[^]
-Or-
A Dead ringer for Kate Winslett[^]Just immagine you had a C64 from 1983. A small 8 bit CPU at less than one MHz and about 50k RAM which you can use. None of the brute force methods you are used to would get you anywhere. Multitasking / multithreading? From the hardware side that would have been no problem. All you need is a hardware timer and an interrupt. But then the interrupt routine, which would have to handle the scheduling of the threads and also the bookkeeping, would nibble away at your little memory. And the effectiveness of having a CPU, which with luck executes 100000 - 200000 instructions per second, do this is more than questionable. Just-in-time-compiler? Or any compiler at all? An IDE which goes beyond a simple text editor? How? CPU, memory and available mass storage (two flopy drives with about 160k disk space each, if you are lucky) are simply not enough. A framework? How many libraries do you think you can load into your memory? And, with only very slow floppies available, some kind of swapping mechanism is also out of the question. Good code? That means wrapping everything up in functions and/or objects. Now and back then, calling a function or method was the same procedure: Push parameters onto the stack, call the function (which then cleans up the stack by removing the parameters), the function then does its job, pushes the return value onto the stack, returns and finally leaves it to the calling code to remove the return value from the stack again. Very quickly the little CPU is working more on the stack than on the actual program. Obviously, good code back then was defined a little differently than today. Those were only a few examples where the brute force approach has become the normal way to go. The more limited your system gets, the less useful the 'normal' approaches become. And I have enough things which were considered obsolete come back.
"I just exchanged opinions with my boss. I went in with mine and came out with his." - me, 2011 ---
I am endeavoring, Madam, to construct a mnemonic memory circuit using stone knives and bearskins - Mr. Spock 1935 and me 2011 -
Mostly because of how pointers and references work, and also function definition seems very different. :((
Once you formally understand data types, memory addresses and l-values, getting pointers should not be that difficult. A pointer is a data type whose admissible values are memory addresses, and whose operations are referencing (input: an l-value, output: the l-value's memory address) and dereferencing (input: a memory address, output: whatever data is in that memory address as an l-value, exception thrown if the original memory address is null). Once you formally understand pointers, getting references is very easy: A reference is a pseudo-data type that is implemented a hidden non-null pointer. When you declare a reference, it must be passed an l-value, which will be referenced. As we have already seen, the referencing operation yields a memory address, which will be used to initialize the hidden pointer (hence, the pointer will be non-null). When you use an already declared reference, the hidden pointer is automatically dereferenced, so you do not have to do it explicitly. As a result, no pointer stuff is explicitly coded. So the message is: If you want to understand pointers in C++, learn what an l-value is. --- Myself, I migrated the other way (C++ to C# 2.0), and had a hard time understanding delegates, because some idiot said that delegates were, deep inside, nothing but function pointers, and I even more stupidly believed him. (Or her. I still do not know the gender of whoever wrote that article.) But that is not true: a delegate contains two pointers: a (member) function pointer, and a this pointer, which may be null (if you pass a static method).
Eduardo León