C# vs C++/CLI : Is there any reason not to use C# for Windows applications?

Page 2 - Seeking answers? Join the AnandTech community: where nearly half-a-million members share solutions and discuss the latest tech.

DaveSimmons

Elite Member
Aug 12, 2001
40,730
670
126
I write C/C++ almost every day, but that's for unmanaged desktop apps.

For .NET, the most-used language for professional development is C#, so you'll find the best support for it at sites like CodeProject and when doing a Google search to try to figure something out.
 

Broheim

Diamond Member
Feb 17, 2011
4,587
3
81
I think id used C up to Quake 3, but my question was more about general Windows apps as opposed to video games. Forget the OpenGL thing, my question isn't really about OpenGL as much as Windows programming in general. Let's say a web browser, or a map viewer, or a word processor.

honestly I'd use a combination for those kinds of big apps, C/C++ for the speed sensitive stuff (or where you truly can't use C#) and C# for the rest. C# is a great language and there are a number of ways to call C and C++ code through it so unless you're a game developer it's my opinion that you should use C# as your goto (pun intended) language for windows development.
 

Graze

Senior member
Nov 27, 2012
468
1
0
Yes, I would. VB.net is perfectly fine. Maybe you don't like it, but there are many programmers who prefer it. Just as you prefer to use C#.


I don't think I could take anything you say seriously anymore :hmm:
 

exdeath

Lifer
Jan 29, 2004
13,679
10
81
OP specifically stated Windows.
Perhaps you two had a private conversation about the DS that the rest of this thread was not made aware of :p

Right. But I was responding to your specific post that no modern games use C/assembly.

Forgot to mention GPU shaders are often written in an assembly language along with Cg and HLSL.

Point being, knowledge of C/assembly constructs are just as much in demand as they ever were. Its just that "easy" high level languages are so prolific and accessible today to high numbers of novices and business layer developers that it's easy to overlook the existence and need for low level expertise.
 

Red Squirrel

No Lifer
May 24, 2003
70,157
13,567
126
www.anyf.ca
VB.net is fine, if you just want to throw something quickly together, and if you don't care about whoever may need to fix it in the future. :awe:

The worse is people who use Office as a programming platform. It grows into some complex program that is near impossible to manage and breaks every time there's an update.

We have a few of these "programs" at work and they updated us to Outlook 2010 (what a bloated piece of shit btw - don't do it!) and it broke most of em. I'll be rewriting them using php and making them all web based. vB/.net makes it easy to interact with MS products such as send email through Outlook, so I see why it is attractive to some. With php I will probably have to write a mapi wrapper to interface with exchange and have the user enter their username and password. So it's more work, but in the end, will be more solid and is less likely to break unless the mapi protocol changes.
 

tfinch2

Lifer
Feb 3, 2004
22,114
1
0
Done any VU1 or Cell SPU or any kind of SoC code lately?

Love people who say C/assembly is dead. Must be nice to use ready made drivers, libraries, SDKs, operating systems, etc with no idea where they came from...

Are smart phone firmware images built in Java, VB, C#? Lol

Its just that "easy" high level languages are so prolific and accessible today to high numbers of novices and business layer developers that it's easy to overlook the existence and need for low level expertise.

Ugh, more of this drivel? You consistently act like anyone using a high level language is a shit programmer. Just like how you think gamers who don't play JRPGs are lame.

Use the right tool for the job and move on.
 
Last edited:

exdeath

Lifer
Jan 29, 2004
13,679
10
81
Did I say build your enterprise apps in assembly? No. Hell no I'd rather kill myself.

Only providing counterpoints to the myth that C/asm knowledge is outdated or worthless in "modern times". Its just as necessary now as its ever been and more, its just easy to over look when the next popular new fangled copy paste OOP language is all the rave and the newest fad.

Who's writing those JIT compilers and VMs and SoC firmware again? Guarantee you they are making more than the person writing customer data entry forms in C#/Java. To say its old and irrelevant is an injustice.

I see people repeatedly saying C is outdated and not a desirable skill and its just plain wrong.
 
Last edited:

Obsoleet

Platinum Member
Oct 2, 2007
2,181
1
0
From what I know and have seen, C# is one of the best programming languages out there IMO. It's a real shame it's only really viable on MS platforms. I wouldn't mind knowing it, but I wouldn't go out and learn it today at this point.

I agree to an extent with what exdeath is saying. But I'm a fan of both new-fangled copy paste OOP languages and low-level at the same time.

Python, C, JS are all that I tinker with- for different purposes. I'm definitely by far strongest in Python, because it's the most practical for what I do. And it just gets the job done, quickly. Ties into a large system with varying parts extremely well, great glue code.

What I'm keeping my eye out for is the next wave of languages that make multithreaded programming no different to the developer than single threaded (traditional) programming. Something along the lines of Haskell, Erlang. For me that's the real next step.

My advice OP? Stick with C++ for whatever you're working on. The next wave of webapps are going to be based on a subset of lowlevel Javascript that requires compilation from C/C++. Hone those C(++) skills, they're going to be coming in handy soon.
 

Ancalagon44

Diamond Member
Feb 17, 2010
3,274
202
106
Right. But I was responding to your specific post that no modern games use C/assembly.

Forgot to mention GPU shaders are often written in an assembly language along with Cg and HLSL.

Point being, knowledge of C/assembly constructs are just as much in demand as they ever were. Its just that "easy" high level languages are so prolific and accessible today to high numbers of novices and business layer developers that it's easy to overlook the existence and need for low level expertise.

Even if I could write assembler for graphics cards, I would deliberately avoid it, because the graphics card driver's shader compiler knows the architecture better than I do. Plus, there are so many different architectures - how could I possibly write assembler for all of them?

We have a piece of business software that a prima donna who used to work for us wrote in assembler. Absolutely nobody can maintain it and now we need to start the entire thing from scratch. This is why 99.9% of applications should not be written in assembler - maintenance is impossible.

Yes, some select applications just require the speed and small code size. Goody for them. For the rest, there is literally no reason to use it unless you want to brag that you can use it.
 

Pia

Golden Member
Feb 28, 2008
1,563
0
0
Only providing counterpoints to the myth that C/asm knowledge is outdated or worthless in "modern times".
Indeed, it's not outdated or worthless. But you are hurting your argument with this exaggeration that is just plain false:
Its just as necessary now as its ever been and more,
The proportion of programmers who actually need hands-on experience with asm is ever decreasing. Even for most people working with performance, algorithm tuning and looking for parallelization opportunities is a more sensible use of their time than trying to outsmart compilers that have hundreds of man-years of thought put into them, can be trained with representative data, or even adapt to the data on the fly as it comes in. You can literally have never seen a line of asm and still be a productive developer of a high performance system. For the average programmer wanting to deepen their skills, learning asm shouldn't even be on the map.
 

Chaotic42

Lifer
Jun 15, 2001
34,545
1,707
126
My advice OP? Stick with C++ for whatever you're working on. The next wave of webapps are going to be based on a subset of lowlevel Javascript that requires compilation from C/C++. Hone those C(++) skills, they're going to be coming in handy soon.

I really do appreciate the advice. It sucks being a luddite, though. The very word webapps makes me want to go dig ditches for a living. :p

Hopefully I can ride the paper maps train until the wheels come off. ;)
 

Ken g6

Programming Moderator, Elite Member
Moderator
Dec 11, 1999
16,621
4,539
75
Done any VU1 or Cell SPU or any kind of SoC code lately?
No. Unless you count CUDA, which is SIMD.

Although Cell isn't SIMD, I'd argue that it's often programmed in a SIMD-like manner. ("Same Instructions Multiple Data"? :whiste:)

But that's why I said "likely": Most people aren't doing that kind of coding. Multiprecision integer math on x86 generally requires either some assembly code or a library containing some assembly code to be fast. But I don't know many people besides myself who do that frequently.
 

sao123

Lifer
May 27, 2002
12,653
205
106
If you need to write mnaged code... Use C#...
however dont fall into thinking if you use C++ you must use managed C++/CLI...
Unmanaged C++ still works for native x86/64 applications, and is very useful for embedded apps, and Operating Systems and such.
 

BrightCandle

Diamond Member
Mar 15, 2007
4,762
0
76
Wait. WHAT?

Highly likely. The Firefox subset of Javascript is extremely difficult to write in as a developer but it brings dramatic performance improvements that many people will indeed be using the cross compilers to it for high performance clients.
 

Train

Lifer
Jun 22, 2000
13,583
80
91
www.bing.com
Highly likely. The Firefox subset of Javascript is extremely difficult to write in as a developer but it brings dramatic performance improvements that many people will indeed be using the cross compilers to it for high performance clients.

By subset of JavaScript you mean JavaScript.

Are you seriously trying to tell me people will compile C++ to JavaScript?

I mean, I can totally understand Coffee script, and Type Script and the other langs that compile to JS, but C++? Someone seems misinformed.
 

DaveSimmons

Elite Member
Aug 12, 2001
40,730
670
126
By subset of JavaScript you mean JavaScript.

Are you seriously trying to tell me people will compile C++ to JavaScript?

I mean, I can totally understand Coffee script, and Type Script and the other langs that compile to JS, but C++? Someone seems misinformed.

Asm.js:
http://arstechnica.com/information-...nce-on-the-web-a-brief-examination-of-asm-js/

another article, Epic's Citadel demo:
http://arstechnica.com/gaming/2013/...emo-shows-the-power-of-opengl-in-the-browser/
 

hooflung

Golden Member
Dec 31, 2004
1,190
1
0
@tfinch2

I think you are being too much of a knee-jerk reactionist here. What Exdeath said was pretty valid.

@brandonb

Thinking VB.Net is relevant is pretty awkward of a thing to say. We still maintain VB6 apps in our Java centric work but it is like getting an STD when you are asked to go into it and do something. No one at the local universities (5 of them in our metro area) teach a lick of it. I could write it all day long but I'll do my best to deflect that request and stick to Java. VB.net isn't much better...

If it is all you got then whatever, but if there are other options no VB.net is at the bottom of a long list. It is not the same as writing IronPython or IronRuby on .Net or like Scala or Groovy on the JVM. Not because of implementation... because of relevance. VB.net is legacy.

@Train
There will be several languages that run through a converter. It is essentially the same idea of the languages you mentioned but also the idea behind high performance serializers like protobuff and its ilk. Hell GWT compiles Java to Javascript... why would it not be the same for someone to do a C++ to JS?
 

Train

Lifer
Jun 22, 2000
13,583
80
91
www.bing.com
@Train
There will be several languages that run through a converter. It is essentially the same idea of the languages you mentioned but also the idea behind high performance serializers like protobuff and its ilk. Hell GWT compiles Java to Javascript... why would it not be the same for someone to do a C++ to JS?

That's a pretty big leap from "requires C/C++"

If asm.js does see widespread use, it will likely be created from already mainstream web app languages, Java/Ruby/.Net/Python

The asm.js demo accomplished a whopping 10 frame per second improvement on a first person shooter running in the browser. About as niche an application as you can get. To take that and say "the next wave of web apps will be written in C++" is a bit of a stretch.

The speed at which regular old JS can do things on a canvas or a DOM in a modern browser is more than enough performance for 99.99% of the web apps out there. Yes I went to four nines.
 

Cogman

Lifer
Sep 19, 2000
10,284
138
106
That's a pretty big leap from "requires C/C++"

If asm.js does see widespread use, it will likely be created from already mainstream web app languages, Java/Ruby/.Net/Python

The asm.js demo accomplished a whopping 10 frame per second improvement on a first person shooter running in the browser. About as niche an application as you can get. To take that and say "the next wave of web apps will be written in C++" is a bit of a stretch.

The speed at which regular old JS can do things on a canvas or a DOM in a modern browser is more than enough performance for 99.99% of the web apps out there. Yes I went to four nines.

Which browser were you using? Currently only Firefox 22 and up has any optimizations for ASM.js. Chrome 30 looks to have some in the pipeline and IE has almost none.

As for the performance increases

http://j15r.com/blog/2013/07/05/Box2d_Addendum

There you can see that it is ~3x->6x faster than hand written javascript with MUCH more deterministic performance. (the band is short). Thats nothing to sneeze at.

However, it won't be used for languages like Java or C# any time soon. The issue with asm.js is that it is very low level. It provides no access to the GC at all, which means that, currently, for a managed language to compile to ASM.js, it would also have to include a GC in asm.js.

The interesting thing about asm.js is that code compiled to it can be faster than hand written code even in browsers that don't support any ASM.js optimizations.
 

hooflung

Golden Member
Dec 31, 2004
1,190
1
0
I am not talking about Asm.js I am talking about using a language and running it through a compiler to output js like gwt already does.
 

Cogman

Lifer
Sep 19, 2000
10,284
138
106
I am not talking about Asm.js I am talking about using a language and running it through a compiler to output js like gwt already does.

asm.js is a subset of javascript. It IS javascript. Anything that compiles to asm.js compiles to javascript.
 

Obsoleet

Platinum Member
Oct 2, 2007
2,181
1
0
That's a pretty big leap from "requires C/C++"

It does require C/C++, as Cogman said, asm.js requiring type declaration and memory management. At some point cross compiling C#, Java and Python to it might be possible but not until at least ES6's final spec which should be the end of the year, and it will be quite a while until after that when everything is implemented for everyone's favorite flavor. Probably a couple years later at minimum.
If you have an idea that could use the speed and you're competing in the marketplace, it's an understatement to stay that a couple years can be too late.

If asm.js does see widespread use, it will likely be created from already mainstream web app languages, Java/Ruby/.Net/Python

Little Bobby's Geocities site won't require it. But if it gives you an advantage over your competition, then I wouldn't bother waiting to get started.
Because you'll be waiting a long time and there's plenty of people who can program in C or C++ today and don't need all that hand holding.

Mozilla will introduce GC and structured data based on ECMAScript6, at which point it will be possible.. but we're looking down the road quite a ways. There's enough C and C++ programmers out there that if you have a serious product I wouldn't bother waiting that one out. Use Emscripten https://github.com/kripken/emscripten and get to it.

The asm.js demo accomplished a whopping 10 frame per second improvement on a first person shooter running in the browser. About as niche an application as you can get. To take that and say "the next wave of web apps will be written in C++" is a bit of a stretch.

I guess if you aren't looking down the road this might be true. But the video game market is simply one market, it isn't niche, it's a 25+ billion dollar industry. And there's many other concepts that haven't been implemented yet online because of limitations imposed by the webstack. asm.js is in my opinion, targets one area that's been lacking as providing the best way to eliminate any client-side processing barriers.

If you don't think asm.js will allow new types of web applications and the next generation, then I don't really have anything to say on that (IMO) conservative stance.
Your vote is nay against asm.js, my vote is yea. Because it works on asm.js enabled browsers and those which are not. It's a no brainer for anything doing processor intensive tasks.

The speed at which regular old JS can do things on a canvas or a DOM in a modern browser is more than enough performance for 99.99% of the web apps out there. Yes I went to four nines.

If your web application is data heavy rather than processing limited, then the database is doing all the work, sure. But there's a lot of concepts that have not even been implemented, the web isn't done advancing as a software medium.
Right now asm.js generated by emscripten is 4-5x slower than native code, but this is all in progress, the final target is 2x slower than native code. Which in my book will easily be fast enough for anything, with today's hardware.
If you're using a modern browser like Firefox 22+ (I don't think any others support asm.js at the moment), the JS engine immediately recognizes asm.js code at compile time and compiles it to assembly instead. It's never ran through an interpreter.

Mozilla is truly pushing the web forward yet again in a non-proprietary way with this one- asm.js runs whether the browser knows anything about asm.js or not. It's not the right technology for an Angelfire or Geocities site though. Maybe the performance gains will trickle down to Python/C#/Java crosscompilers in time, for anyone needing performance today for a cutting edge web application you're looking at what will usher in the next generation of webapps that matter.
 
Last edited:

hooflung

Golden Member
Dec 31, 2004
1,190
1
0
asm.js is a subset of javascript. It IS javascript. Anything that compiles to asm.js compiles to javascript.

All I am saying... is that there are plenty of 'insert your own language here' compilers to javascript. So you can write in one language for code maintenance, and then run it in a javascript engine.

That is all. I don't care about, nor am I ignorant of, ASM.js.