Web Hosting Talk







View Full Version : Difference between C and C#


Sheikh Ahsan
07-14-2009, 11:18 AM
Hello everyone,

I have done C language and I am very good in it but currently I dont know where I can use it professionally most of people advice me to learn C#. So should I go for it, what is the scope of C# and how its better than C/C++ . I am very confused, you advice will be appreciated!

Thank you!

ghostweb
07-14-2009, 01:37 PM
There are plenty of practical applications for standard C/C++ and I would advise you to continue to learn them, especially C++ if you haven't done any OOP before. There is a world of jobs out there for c/c++ developers.

If you want to get into windows development specifically then I would encourage you to download the express editions of Visual studio for both Visual C++ and C# and play with both (these are free). I think the differences will jump right out at you when you start poking around.

MarkioE
07-14-2009, 01:43 PM
C# is probably the newest of the main programming languages, it was designed to be more simple and easier than the other languages to learn and uses the .net framework quite alot.

There are openings for jobs in all of the languages you listed, it depends entirely on the type of application.

As an example most modern games are made in C++ because the programs run quicker than C# applications do. I personally know C++ and C# and I find that I can do A LOT more with C++ than I can with C#, it's quite restricting but much easier to use.

DoktorW
07-14-2009, 02:02 PM
It depends a lot on what type of apps you want to create. What are you thinking of specifically?

As a general rule, you can do everything in C/C++ that you do in C# and far more. E.g. you can program on the .NET framework with C++ too if you want. The .NET framework is a bit similar to to the Java envirenment (I'm sure you came in contact with a Java Applet on the web or something or something like that). It makes some things easier (e.g. window programming). C# is a bit simpler though, as it's a bit like Visual Basic/Delphi, but it's not as fast and you can't do very complex/performance critical applications or applications that go deep into the OS core (as the .NET framework is also made for portability).

cselzer
07-14-2009, 02:17 PM
This is a quote for another forum, that i just browse, but puts it in a very good perspective. I didn't write this. Cypher - cypherjb.com/blog/ did.


C# is a 'managed' language, this means that code compiles to an intermediate form which then runs in a virtual machine. This particular VM is known as the "CLR" or Common Language Runtime. Java is a similar language though it differs from C# in its implementation of the VM. Typically C# uses 'JIT' or "Just In Time" compilation which means that it is compiled to an intermediate form by a compiler, then a VM compiles that intermediate form to the platform's native form when it is run. Java on the other hand has historically been "interpreted" though as far as I know it can also be JIT compiled (Note: I am not a Java programmer so please correct me if I'm wrong and do more research before taking the aforementioned as fact.).

C++ is an 'unmanaged' language. This means that code is compiled to its native form and runs independent of a VM and requires no additional compilation or 'help' to get started.

C# is great because it abstracts away a lot of the low level details the typical programmer is not interested in. It makes it easier to write more 'stable' and leak free software.

C++ on the other hand is great because it DOESN'T abstract away that stuff. What you say? I just said C# was great for the exact opposite reason? Correct. It all comes down to your needs.

C++ is low level, it's a loaded shotgun with the safety off, you're given full freedom to do what you want, but if you **** up you risk blowing off your leg. Writing good C++ code is harder than writing good C# code, but the extra power and portability that comes with it can certainly be worth it.

C++ can be used on embedded devices where Java and .NET typically can not. C++ code can also be 'injected' into another process (a process which is utilized to then in-turn load the CLR remotely and run a C# app in the context of a remote process -- a topic for another day). Furthermore, C++ gives you full access to the underlying hardware. You can use inline asm, freely read and write memory, etc.

C# allows you to do some of these things, but you have to go through what can only be described as a "mess" of an abstraction layer.

So, a low level language like C/C++/ASM is your only choice for certain things (dll injection, operating system development, device drivers, embedded programming, more portable programming, etc), but unless you are really serious about C++ as a language and are willing to invest a much larger chunk of time to learn it properly, I'd go with C#, with a tiny bit of C++ on the side for when you need to do stuff to 'compliment' your .NET code.

IMPORTANT NOTE: I am talking about STANDARD C++ not C++/CLI. C++/CLI can only be described as the "bastard child" of the programming world. I would avoid using it unless you are in one of the VERY rare situations where it can be useful.

jt2377
07-14-2009, 10:06 PM
it's not as fast and you can't do very complex/performance critical applications or applications that go deep into the OS core (as the .NET framework is also made for portability).

Wrong. You can write "un-manage" code with C# if you need to work with Windows. You're also wrong on complex/performance critical application. There are many apps out there written in C# that is mission critical. At my previous job, we wrote mortgage software with C#. that is very mission critical to bank and lender.

Nex7
07-15-2009, 03:15 AM
Any language can write mission-critical applications. That's less a function of the language than of what any given business or entity considers 'mission-critical'.

The military probably considers the software on a guided missile mission critical. It is most likely NOT written in Python, or C#, but instead in C or assembly (then again knowing the US military and how they get things done sometimes technologically from a few friends of mine, it could just as easily have been built in QBASIC, [sigh] but I digress).

However a gigantic banking institution's production processing systems for say, credit checks and loan offers, is also a mission-critical system, both for them and all the entities involved in those loans and such.. and as I understand it there's apparently one out there running on ruby on Rails, handling tons of requests a day.

C# is a reasonable language. So is C. They are not generally used for the same tasks. C# is going to typically be used for larger applications and systems, because often the same code in C# can be done in less lines than C, especially given the easy and common tie-in with the .NET framework that C# enjoys.. it makes writing big and small applications on Windows a breeze, for instance.

But you're not going to typically write a driver for your video card in C#.. that's going to be C and some assembly. If you write device drivers and the like in C#, frankly, you're doing it wrong.

inspiron
07-15-2009, 09:12 AM
C is structed language whereas C# is object oriented.

Doh004
07-15-2009, 10:17 PM
I've been working with C# this summer (for the first time) and I'm very impressed with it. It's definitely solidified my understanding and appreciation of OOP.

plumsauce
07-16-2009, 02:09 AM
Any language can write mission-critical applications. That's less a function of the language than of what any given business or entity considers 'mission-critical'.

The military probably considers the software on a guided missile mission critical. It is most likely NOT written in Python, or C#, but instead in C or assembly (then again knowing the US military and how they get things done sometimes technologically from a few friends of mine, it could just as easily have been built in QBASIC, [sigh] but I digress).

However a gigantic banking institution's production processing systems for say, credit checks and loan offers, is also a mission-critical system, both for them and all the entities involved in those loans and such.. and as I understand it there's apparently one out there running on ruby on Rails, handling tons of requests a day.

C# is a reasonable language. So is C. They are not generally used for the same tasks. C# is going to typically be used for larger applications and systems, because often the same code in C# can be done in less lines than C, especially given the easy and common tie-in with the .NET framework that C# enjoys.. it makes writing big and small applications on Windows a breeze, for instance.

But you're not going to typically write a driver for your video card in C#.. that's going to be C and some assembly. If you write device drivers and the like in C#, frankly, you're doing it wrong.

C# may do a job in fewer lines of source code. But, wait until you see how many assemblies it drags into memory.

Case in point, somehow ATI got conned into using C# for their control panel. Takes up 50MB+ and 5% cpu just to idle in the background just in case you might want to alter a setting. And the release packaging is atrocious. They can't decide what language you want, and won't let you set it. So, they drop *every* language version on your drive. Multiple copies of the same dll in multiple directories, and on and on.

The older C based control panel was a 7MB download. Now its 70MB+. Even 7MB is huge for the job at hand. 70MB is ridiculous. Drag and drop programming does funny things to software. None of it good.

Sheikh Ahsan
07-16-2009, 11:38 AM
Thank you every one, you guys guided me a lot!!!
Just one more question, I dont know C# well but I am quite good at C++ what are the practical implication, where I can implement practically as I havent got any job related to it yet. I am also starting java from this coming monday and will be applying it to various of stuff.

Anyways thanks a lot!

ghostweb
07-17-2009, 01:18 PM
I've seen C# used in ASP.NET web services, client server applications, as well as end user applications. There are many practical uses for C#. If developing on the Windows platform I would say it is almost always a viable choice unless you are specifically dealing with a lot of un-managed code in which case it can become cumbersome, but still not all together unwieldy.

Check out http://msdn.microsoft.com/en-us/vcsharp/default.aspx

Lot of good information there about C#

paddyvats
07-17-2009, 06:27 PM
c# is better for mass software production and c is more fast but takes time to develop software.

Sheikh Ahsan
07-21-2009, 11:05 AM
ghostweb, I have heard that java too helps in web service and client server applications?? Can we use java in ASP.NET, I just know that Java is very portable and can be used in any platform! Thanks!