Re:C/C++ Pointer Declaration Syntax – It makes sense
by dbattaglia on Tuesday February 21, 2012 @10:50PM
(#3619352)
does the language allow something like the following?:
yes, exactly. The problem is you see stuff like this: var obj = new SomeType();
obj = GetSomeType();
Basically creating 2 objects, the first of which is immediately garbage since it no longer has any roots. Anyone who understands pointers/references and memory allocation should understand that "new" is actually creating a new live object on the heap, rather than just initializing a pointer to null (or a stack-based value type to zero).These days C# is actually a decent language to code in, it has a nice functional aspect to it with linq/lambdas, and you can still go down to C style pointers/"unsafe" code if necessary (with lots of restrictions of course). It's really the Microsoft dependency that kills it more than anything else.
Re:C/C++ Pointer Declaration Syntax – It makes sense
by eru on Thursday February 23, 2012 @06:51AM
(#3624589)
var obj = new SomeType();
obj = GetSomeType();
You could almost be tempted to write an automatic converter to var obj = GetSomeType();
but you can't in general, because you don't know whether `new SomeType()' doesn't have side-effects. But if it has some that are relied on, that's probably a bug.I know that there's a free .net runtime called Mono. What about the compiler side of free C#?
If you want to learn pointers, you have to learn a language that provides them. So C, or like I said, Forth or Pascal. C is fine as a first language, if you don't mind the pain. C++ is a horrible language, no matter when you learn it. Never cripple the minds of beginners with it.
About your C# anecdote, does the language allow something like the following?:
Nowadays I usually program in Haskell for my day job. There lots and lots of nice concepts to be understood there. You could even use pointers, if you are desperate enough.