Why use C#?

M

Mythran

Scirious said:
People, what are the advantages of C# over C++?

Thanks,
Scirious.

Couple of advantages:

Managed code. Manages memory consumption/pointers so you don't have to...in
turn eliminating (for the most part) errors due to invalid handles, et
cetera.

Faster application development (based on developer of course, and
his/her/it's knowledge of the language(s) used).

HTH,
Mythran
 
N

Nicholas Paldino [.NET/C# MVP]

Scirious,

Are you referring to C++ in a managed or unmanaged context?

If you are talking about an unmanaged context, then C# is worlds apart
from C++, in the sense that the code you compile in C# runs in an execution
environment which provides services such as verification, security, memory
management, etc, etc, all things in C++ you would have to roll on your own.
 
S

Scirious

Are you referring to C++ in a managed or unmanaged context?
If you are talking about an unmanaged context, then C# is worlds
apart
from C++, in the sense that the code you compile in C# runs in an
execution environment which provides services such as verification,
security, memory management, etc, etc, all things in C++ you would
have to roll on your own.

Actually, I don't know what managed C++ is. What is the difference of C++
with managed C++ and the managed C++ with C#, apart from the fact that C++
can be compiled into executable code?

Thanks,
Scirious.
 
N

Nicholas Paldino [.NET/C# MVP]

Scirious,

You can compile C++ code into code that is able to be run in the CLR
(like C#). You have to use a set of extensions to the language to enable
this, so in reality, it gives you two options for the output.
 
S

Scirious

You can compile C++ code into code that is able to be run in the
CLR
(like C#). You have to use a set of extensions to the language to
enable this, so in reality, it gives you two options for the output.


I know this, but I can also compile C++ to run outside the CLR, which is
not possible to do with C# according to my understanding.
 
N

Nicholas Paldino [.NET/C# MVP]

Scirious,

Right, but you asked what the difference between managed and unmanaged
C++ is. That's it, code that runs in the CLR is managed, and you can write
C++ code that compiles to a managed assembly.

You can also use C++ to produce unmanaged code, which is what you would
consider C++ normally.
 
S

Scirious

Ok, now from a personal point of view. I know only Java and a little of C.
If I will start sutding a new language like C++ or C# waht would you
recommend?
 
N

Nicholas Paldino [.NET/C# MVP]

Scirious,

If you know Java already, then I would recommend C#, you will get up to
speed the quickest using that.

However, I think that knowing C++ does have some benefits, as really
being good in it forces you to understand concepts which are applicable to
software development in general.
 
A

andrew queisser

Scirious said:
Ok, now from a personal point of view. I know only Java and a little of C.
If I will start sutding a new language like C++ or C# waht would you
recommend?

What's your goal in learning a new language? C# and C++ are very different
beasts. They are both good languages and there are reasons for learning
either one.

Andrew
 
A

Andrew Faust

Scirious said:
Ok, now from a personal point of view. I know only Java and a little of C.
If I will start sutding a new language like C++ or C# waht would you
recommend?

It really depends on what you are planning to build. If it's just
general purpose GUI applications, I'd say go with C#. If you are working
on stuff where the primary concerns are memory footprint and speed
optimizations then C++ may be a better choice.

My real recommendation is to learn both, and maybe a few more languages
as well. The more you learn the quicker you will be able to pick up new
languages, plus it will open your eyes to multiple ways to solve problems.

Andrew Faust
 
S

Scirious

What's your goal in learning a new language? C# and C++ are very
different beasts. They are both good languages and there are reasons
for learning either one.

Andrew

I want to switch from Java for two reasons:

1. I think Java's GUI is too ugly. Too square.
2. Also, Java doesn't support unsigned numbers.

And I want to implement a NNTP client and a mail analyzer at the moment,
but I don't want to do it with Java. So I thought about C# or C++, but
I'm not sure.

It seems that C# would be easier to learn and easier to develop. But
with C++ I can use QT for GUI what would allow me to port my code to
Linux easyly. It will be very useful to have a plethora of libraies and
collections and an easy system to create threads.

What do you say about it?
 
J

Jon Skeet [C# MVP]

It seems that C# would be easier to learn and easier to develop. But
with C++ I can use QT for GUI what would allow me to port my code to
Linux easyly. It will be very useful to have a plethora of libraies and
collections and an easy system to create threads.

What do you say about it?

With C#, you can use GTK# to get a cross-platform UI. Threading is much
more straightforward under the CLI than in C++, in my experience - and
you can code to a single threading model, rather than worrying about
what the native threading models are on each platform.

See http://www.mono-project.com for how you'd run your code on Linux.

(Btw - Java UIs don't have to look rubbish at all. There are some
lovely Swing UIs around, and there's SWT as well.)
 
H

Harold Howe

Scirious said:
Ok, now from a personal point of view. I know only Java and a little of C.
If I will start sutding a new language like C++ or C# waht would you
recommend?

Are you learning for the sake of learning? Or does your new language
have to put food on the table?

Both C# and C++ can put food on the table. If windows is your primary
platform, and you want to develop GUI applications, then C# is a pretty
solid choice.

Personally, I think C++ is a better language overall. However, on
windows, your choice of C+++ GUI frameworks is limited. You would be
using one of these most likely:

- MFC
- Managed C++ on .NET
- Borland C++Builder and the VCL
- wxWidgets
- QT
- Direct API access
- GTK+
- ????

Since you already know java, I don't think managed C++ on .NET makes any
sense for you if the goal is to feed your family. You would be more
productive with C#. Among the rest, Borland C++Builder is probably the
most productive and enjoyable framework to use. But there are
consequences to using a tool from a small vendor whose management has
shown a lack of prudence over the years. I would avoid MFC like a bad
disease.

QT is an excellent framework, but the commercial version is not cheap.
wxWidgets is a good framework, and totally free. I don't know much about
gtk+, but it is also free. Each of these three would allow you to target
platforms other than windows. You could also consider C# on mono with
the GTK mono binding.

If you are learning for the sake of learning, and you think that you
have mastered java, I would consider learning something totally
different. Something like Ruby or Python.

H^2
remove .bounce from my email address.
 
A

andrew queisser

Scirious said:
I want to switch from Java for two reasons:

1. I think Java's GUI is too ugly. Too square.
2. Also, Java doesn't support unsigned numbers.

And I want to implement a NNTP client and a mail analyzer at the moment,
but I don't want to do it with Java. So I thought about C# or C++, but
I'm not sure.

It seems that C# would be easier to learn and easier to develop. But
with C++ I can use QT for GUI what would allow me to port my code to
Linux easyly. It will be very useful to have a plethora of libraies and
collections and an easy system to create threads.

What do you say about it?

There is a lot of overlap between C++ and C# and for your purposes both seem
like valid choices. If you already know Java there's one big advantage going
to C# which is that you (generally) don't have to worry about memory
deallocation.

Qt is cool but as Jon points out there's a way to interface to it via C#.

If cross-platform is a real concern then C++ is the way to go, not just
between Linux and Windows but pretty much any other OS, e.g. in the embedded
arena.

If you're mainly developing for Windows and your apps have a mix of GUI,
networking and DB stuff there's no better choice than C#.

One area where C++ clearly has an edge over C# (and pretty much any other
language) is developing performance-optimized applications. C# generics and
OO constructs are at a performance disadvantage compared to C++.

So in summary I'd say: cross-platform and performance concerns would push me
toward C++, ease of development and GUI/Web/DB would push me toward C#

Hope that helps,
Andrew
 
A

andrew queisser

If you are learning for the sake of learning, and you think that you have
mastered java, I would consider learning something totally different.
Something like Ruby or Python.
^^^^

+1
 
S

Scirious

I would say that being able to earn money pretty fast would also be
something to consider.
 
H

Helge Jensen

Scirious said:
I want to switch from Java for two reasons:

1. I think Java's GUI is too ugly. Too square.

There are other GUI's than SWING for JAVA, but really -- is the gui
appearance worth the effort?
2. Also, Java doesn't support unsigned numbers.

And you can't use the signed numbers?

I wouldn't choose language based on those grievances, you are going to
skip from language to language every week if things like these drive you
to a language-change.
It seems that C# would be easier to learn and easier to develop. But
with C++ I can use QT for GUI what would allow me to port my code to
Linux easyly. It will be very useful to have a plethora of libraies and
collections and an easy system to create threads.

Picking up C++ as a programming-language is *not* easy, especially if
you wan't to do threading and GUIs. It's gonna take you years to learn
and decades to debug -- only go there if it's worth the trouble.

If you like a plethora of libs, try some of the scripting-languages out
there, python is a good choice and the default install comes with an
NNTP library. Ruby is a good option too.

There are bindings for QT, GTK, and several other toolkits for almost
any language you can think of (including JAVA, atleast for GTK).
What do you say about it?

Perhaps you are focusing on the wrong issues?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top