Question C#?

AFAIK, C++ can be also used for writing a managed code (.NET, Mono), like what C# is used for, but there are some constraints if it's used for it. I've never tried it, and I don't know if it produces byte-code in that case.

You can use [ame="http://en.wikipedia.org/wiki/Auto_ptr"]auto pointers[/ame] in C++ which can make your code "managed" if you want.


Conditional compilation:
Balance is the key for conditional compilation. For example I can use the same code for both OpenGL and SDL_gfx based versions of my game. There's actually no other option if I want to make the game portable for some platforms having no OpenGL libraries.
Conditional compilation and macros also let me maintain both versions of Launch MFD - 2006 and 2010 in one code base until we get the 201x release.
These are the only moments when I find it justified to use the CC in My code though. It also helps in translations, but they could be done using other methods as well (gettext for example).
 
Last edited:
You can use auto pointers in C++ which can make your code "managed" if you want.

Hm. Isn't that just reference-counting? References in .NET are far more than that. The garbage collector even takes care of "lost islands" in the memory-pool, something you can't say about simple systems with reference-counting.
But I may be wrong here and auto pointers are a full-fledged system like .NET's - I just don't think so...

Conditional compilation:
Balance is the key for conditional compilation. For example I can use the same code for both OpenGL and SDL_gfx based versions of my game. There's actually no other option if I want to make the game portable for some platforms without OpenGL libraries.
Conditional compilation and macros also lets me maintain both versions of Launch MFD - 2006 and 2010 in one code base until we get the 201x release.
These are the only moments when I find it justified to use the CC in My code though. It also helps in translations, but they could be done using other methods as well (gettext for example).

You are right with this. In later years, though, I've gravitated towards using a proper version control system for that kind of task. It is much more scalable and secure than cluttering up the source with huge portions of code never compiled due to one #define-setting mistakenly set/unset.

regards,
Face
 
The auto pointers are indeed something different and simpler than .NET thing, because of the destructor difference in C# and C++. As you know, the C++ destructor is called simply when a created object leaves the scope. Then everything in that class that was constructed using the auto_ptr is destroyed automatically. There's just no need for garbage collection in this case.
At least this is how I understand it, because I've actually never used auto_ptrs, because I just didn't need them :)

Face said:
You are right with this. In later years, though, I've gravitated towards using a proper version control system for that kind of task. It is much more scalable and secure than cluttering up the source with huge portions of code never compiled due to one #define-setting mistakenly set/unset.

Hmmm. Seems reasonable.
 
You can use auto pointers in C++ which can make your code "managed" if you want.
I don't want to. I like managing memory allocations and deallocations myself (but sometimes I use also vectors) in C++. Sometimes I'd like to deallocate C# objects too, before garbage collector. I was referring to something like this in C++:
PHP:
#using <mscorlib.dll>
using namespace System;
// etc.
 
i it find a good analogy to think of C# and C++ and automatic and stick-shift cars...


automatics are easier to handle, you don't have to worry about the clutch or anything like that... while sticks have the "difficulty" of balancing the gas and the clutch as you drive off, and the risk of an extremely unskilled driver severely damaging the gearbox and the engine...

yet... i wouldn't trade my stick-shifter for an auto even if it came with free beer and puppies


it's a matter of how much control you wanna have... but as spiderman's uncle said, "with great power, comes... ", ah you know it...


preprocessing macros are indeed a two-sided deal... it can make a programmer's life easier (for himself) - but abusing it on things like libraries and other projects that may involve other programmers is considered very foul practice

i take it as a rule-of-thumb to only abuse allow myself such controverse practices in projects that "end with me"... if others should be involved, coding elegance becomes a matter of not causing a major hassle for them :hmm:


and still, i agree immensely with whoever said it, C++ IS the best programming language i've used... even with it's apparent pitfalls, i actually prefer having the choice to make my code a mess if i feel like it :P

also, its worth noting that i have seen the opposite effects of overdone OOP - it can be just as hard to read and use as it's counter-offender, the big ball of messy code...



in the end... i don't think it's a matter of which language makes for "better" code - in the end it comes down to that little component between the seat and the keyboard :rolleyes:
 
i it find a good analogy to think of C# and C++ and automatic and stick-shift cars...

automatics are easier to handle, you don't have to worry about the clutch or anything like that... while sticks have the "difficulty" of balancing the gas and the clutch as you drive off, and the risk of an extremely unskilled driver severely damaging the gearbox and the engine...

yet... i wouldn't trade my stick-shifter for an auto even if it came with free beer and puppies

Interesting analogy. If we go with it, we can also say that those who want to drive a car because they want to drive that car prefer the stick. Those who have to go from A to B regulary (and have to drive a car) prefer auto.
In this case, C++ is for programmers who wants to program something for the sake of programming, while C# is for programmers who want to earn a living. I even think this was played in the Java vs. C++ battle, too ;)

But with all analogies, this one will fail and only plays with emotions...

and still, i agree immensely with whoever said it, C++ IS the best programming language i've used... even with it's apparent pitfalls, i actually prefer having the choice to make my code a mess if i feel like it :P

"Only a sith deals in absolutes", if we want to go with movie citations...

in the end... i don't think it's a matter of which language makes for "better" code - in the end it comes down to that little component between the seat and the keyboard

IMHO, it all comes down to the use-case. If you do embedded development, C# (or Java) is a bad choice. If you do enterprise-size application development, C++ is a bad choice. For fast web development, some of the scripting languages (Python, Perl, etc.) may even be a better match than Java.

regards,
Face
 
Interesting analogy. If we go with it, we can also say that those who want to drive a car because they want to drive that car prefer the stick. Those who have to go from A to B regulary (and have to drive a car) prefer auto.

Nah, I need the clutch sometimes to quickly overtake those gramps driving less than 50 km/h :lol:

But the same thing more seriously:

IMHO, it all comes down to the use-case. If you do embedded development, C# (or Java) is a bad choice. If you do enterprise-size application development, C++ is a bad choice. For fast web development, some of the scripting languages (Python, Perl, etc.) may even be a better match than Java.

Yes, it depends what you do. But what if you do enterprise-size image processing applications or games where speed does matter? Would you be linking C++ code containing algorithms with C# code responsible for UI?
 
Last edited:
Yes, it depends what you do. But what if you do enterprise-size image processing applications or games where speed does matter? Would you be linking C++ code containing algorithms with C# code responsible for UI?

The examples are only that... examples. If execution-speed is what matters, you have to weight it against development-speed. It depends on the use-case...

The linking-solution is what makes me liking .NET better than Java in this regards: it is easier to create a "best-of-both-worlds" mix with it.

regards,
Face
 
These examples are my bread, but alright. Everything was already spoken.
 
In this case, C++ is for programmers who wants to program something for the sake of programming, while C# is for programmers who want to earn a living. I even think this was played in the Java vs. C++ battle, too ;)

No, C++ is for the people who want to leave the prepared roads, while C# programmers are driving big fat SUVs with a mud allergy.
 
No, C++ is for the people who want to leave the prepared roads, while C# programmers are driving big fat SUVs with a mud allergy.

But they have this. :rofl:
 
yeah! good point, urwumpe!

C++ can be thought of as the Humvee of programming! it is not pretty, it's not comfortable, but you don't care if there's a road where to you're going :rofl:

the only part of where this analogy fails, is that, unlike road-bound cars and 4x4's... in this case, the hummer is FASTER than a Saleen S-7 :blink::uhh::lol:
 
would that make JavaScript a tricycle? :rofl:
 
Where does "Brainmessedup" fall in here? (you know the one that is completely pointer manipulation based?) :P

You mean this? I think it is a [ame="http://en.wikipedia.org/wiki/Unicycle"]unicycle[/ame].
Absolutely useless for the topic, hard to master, and so much fun to see the faces of people watching you doing it.

regards,
Face
 
:rofl:

OMG thats harder to read than actual machine code! :lol:

it's definitely a unicycle:10sign::LOL!:
 
You can't have the proper name in a URL either, it censors it out.
Which is of course hilarious.
 
Back
Top