Welcome Guest! To access all forums & features, please register an account or sign-in. → Why register?



is c# better then c++?


53 replies to this topic - - - - -

#16 firey

    Neowinian UNSTOPPABLE

  • 5,370 posts
  • Joined: 30-October 05
  • Location: Ontario, Canada
  • OS: Windows 7
  • Phone: Android (4.1.2)

Posted 08 May 2012 - 12:01

My vote goes to C#. It's still a C Based language so it feels very close to C++ albeit cleaner. The .NET Framework provides most everything you need, anything else can be made using the framework and piecing parts together. I spend 90% of my work day in C# and it is a great experience.


#17 psreloaded

    Resident Fanatic

  • 741 posts
  • Joined: 10-January 09
  • Location: India

Posted 08 May 2012 - 12:09

I will side with C# It is easy and powerful. But if you want to learn about pointers, you have to go with C++.

Other that that Visual Studio makes programming is C# very pleasant.

#18 +Asik

  • 6,021 posts
  • Joined: 26-October 05

Posted 08 May 2012 - 13:21

Quote

What is easier to learn?
C# and by far.

Quote

does it work on linux?
C++ has gcc and clang for compilers, as well as a few different IDEs, while C# has mono and the monodevelop IDE. Contrarily to some resilient myths, mono is not "unpolished" or "dangerous" or such. It's every bit as polished and alive as any C++ compiler on Linux, and a quality solution used by professionals.

Quote

there is MONO, but it's a port, it's not pure C#.
Mono is an implementation of open standards just like gcc or clang. I don't know what you mean by "pure C#", as Microsoft's .NET itself is written in C++.

Quote

In the process is being so, it is also far slower. Where as C++ runs code that is compiled directly for the CPU, C# runs as a managed language
C# is also compiled to machine code, it just does so usually "Just-in-time" rather than always ahead of time like C++. While C# does make compromises on performance where C++ makes none, it still offers comparable level of performance in most cases, and saying it's "far slower" is an exaggeration. I'd even say that it's easier to write fast code in C# than C++, leading to faster programs given the same time constraints.

Of course if what you're writing is scientific high-performance computing code, then C# isn't what you should be using, but I'm talking about the general case.

Quote

Another big advantage is that the whole library is developed under strict control in terms of runtime complexity - a feature you'll never be able to find under C♯
I've heard that from Herb Sutter and it's quite amusing. Yes, most of C++'s library has its complexities documented, but maybe because there isn't much more than containers and algorithms in the C++SL... Containers and algorithms in .NET also have their algorithmic complexities documented, but there is no point documenting the algorithmic complexity of a Printer or Socket class.

Quote

But if you want to learn about pointers, you have to go with C++.
There are pointers in C#. And reference vs value types is basically the same idea as pointers vs values in C/C++.

#19 aberg

    Neowinian²

  • 100 posts
  • Joined: 20-March 08
  • Location: EU
  • OS: Windows 8 Pro
  • Phone: Windows Phone

Posted 08 May 2012 - 13:46

C#, the easy way into WPF and Windows Phone.

#20 LaP

    Forget about it

  • 3,207 posts
  • Joined: 10-July 06
  • Location: Quebec City, Canada
  • OS: Windows 8 Pro

Posted 08 May 2012 - 13:47

It's not like C++ is "hard" like assembly.

IMO if someone finds c++ hard to learn then maybe a job in computer tech is not for him/her. Or maybe it explains why so many apps are slow as hell these days.

This said c++ is kinda "dead". Last time i saw a job requiring c++ knowledge was a long time ago. Most jobs theses days require .net, java, php, mobile frameworks, etc or old languages like cobol or sas for jobs in banking and inssurance (anyway where i live might be different for california ;).

c++ is mostly used for video game engines and by scientist for simulation and such (or in old programs made with it). Basically it's used for things that can stress a computer. And for such jobs usually c++ may be not enough as you need to understand assembly too and need to have a very good knowledge in algorithmic and mathematic (anyway last time i checked there was still some assembly used).

If your goal is to learn and become a computer eng then you should start with c++. I would even go as far as to say you should start with assembly. In fact you should start with mathematic as it's the basis of being a computer eng. It's more important to learn the concepts first. Starting with the language is not a good idea. You can learn mathematic and algorithmic and oop concepts without even using a computer.

If you goal is to write a simple linux app and you don't care about being a good dev then c# if mono is good (can't say never used mono). It's definately easier.

#21 psreloaded

    Resident Fanatic

  • 741 posts
  • Joined: 10-January 09
  • Location: India

Posted 08 May 2012 - 16:31

View Postarticuno1au, on 08 May 2012 - 11:46, said:

C# is far FAR faster to deploy in. It is also far more forgiving of mistakes. In the process is being so, it is also far slower. Where as C++ runs code that is compiled directly for the CPU, C# runs as a managed language. You don't have to worry about assigning memory as the CLI handles that for you. You can make small mistakes in your code and have it continue to run. You can't do as much (but it's fairly negligible a difference for the average coder).

Even C# is compiled to native code. But that is done by the JIT compiler on first run. This is a common myth.

#22 simplezz

    Neowinian Senior

  • 1,830 posts
  • Joined: 01-February 12

Posted 08 May 2012 - 16:54

View Posttogerland, on 08 May 2012 - 08:36, said:

What is easier to learn
It depends how you look at it. If you already know how to use the OS facilities and third party libraries, then I'd say C++ is generally quicker to learn. By generally, I mean the common stuff, basic OO, commonly used STL classes, etc. And if you already know C, learning C++ is made that much easier.

With C# you'll need to learn both the language and the dotnet library. In terms of difficulty, it's probably on about the same level as Java. After all C# was Microsoft's answer to growing Java use.

View Posttogerland, on 08 May 2012 - 08:36, said:

and does it work on linux?
I wouldn't recommend using C# or dotnet outside of Windows. Its support is sketchy at best, and most Linux distributions are blacklisting it (Mono) due to precarious licensing issues. Furthermore, the proprietary Windows Forms also won't be available outside of Windows, so if you intend on writing a GUI application, you will have to use something else.

If you want to run your code on GNU/Linux or support multiple platforms, C++ is the better option. It's well supported across every major platform, and there are free open source tools aplenty to aid in development. You can even write a Windows C++ application inside of Linux with GCC cross-compilation and Wine for testing.

#23 zombieChan

    Zombie User

  • 209 posts
  • Joined: 03-November 10
  • Location: MN

Posted 08 May 2012 - 16:58

I will side with C#, it's easier and cleaner(Though I'm also biased because I really hate C++.). Even though .Net itself isn't on Linux(though MS should really think about making .Net multi-platform) mono works fine as well as dotGNU.

#24 simplezz

    Neowinian Senior

  • 1,830 posts
  • Joined: 01-February 12

Posted 08 May 2012 - 16:59

View PostStephen, on 08 May 2012 - 10:06, said:

c# is an open standard, mono is an implementation of that standard as it the .net framework. afaik
Actually it's not an open standard because Microsoft controls it and nobody else has input on it. It's a registered standard with EMCA, but that's as far as it goes. It's also patent encumbered, so there's a risk in the future that other implementations could get shutdown. It's best to avoid those headaches. At least C++ is a true open standard.

#25 Ambroos

    Neowinian UNSTOPPABLE

  • 5,334 posts
  • Joined: 16-January 06
  • Location: Belgium

Posted 08 May 2012 - 17:13

I'm surprised nobody has said Java yet. Eclipse is a great free Java IDE, Java and C# are almost the same language, and Java is perfectly cross-platform, including GUI's.

I'm studying Applied IT and have been writing Java since september now. I've always used Eclipse with it, but I feel right at home in Visual Studio using C#. No reason to limit yourself to Microsoft with C# right from the beginning.

(in fact, C# is strongly 'inspired' on Java. But Java sort of forces you to write cleaner code (in my opinion), which will help you later on)

#26 simplezz

    Neowinian Senior

  • 1,830 posts
  • Joined: 01-February 12

Posted 08 May 2012 - 17:29

View PostAmbroos, on 08 May 2012 - 17:13, said:

I'm surprised nobody has said Java yet. Eclipse is a great free Java IDE, Java and C# are almost the same language, and Java is perfectly cross-platform, including GUI's.
Given the choice, Java is a better option than C# for cross-platform support.

#27 +Xinok

    Resident Reresident

  • 3,426 posts
  • Joined: 28-May 04
  • Location: Shikaka
  • OS: Windows 7 x64
  • Phone: Galaxy S3 (Wicked ROM)

Posted 08 May 2012 - 17:55

I would argue that only professionals have any true reason to use C++. Newbies have no need for pointers, assembly, or manual memory management.

I would suggest learning C# with C (not C++) on the side. C will teach you low-level programming so you understand what's happening under the hood, while C# will teach you everything else and is the language you're more likely to use day to day.

The problem with C++ is a matter of poor design. It has so many hurdles and traps that it's a language that takes years to master.

#28 psreloaded

    Resident Fanatic

  • 741 posts
  • Joined: 10-January 09
  • Location: India

Posted 08 May 2012 - 18:21

View Postsimplezz, on 08 May 2012 - 17:29, said:

Given the choice, Java is a better option than C# for cross-platform support.

I agree, for cross-platform support, java is better. But otherwise I find C# better. Visual Studio is a superb IDE and I find it far more polished than eclipse. Another thing to note is that Java is interpreted as far as I know while C# is not. So if you are counting on performance then Java is perhaps not the way to go.

Syntax wise, C# and Java are almost twins... libraries are obviously different though.

#29 +GreenMartian

    Neowinian Senior

  • 1,688 posts
  • Joined: 28-August 04
  • Location: adelaide, au

Posted 08 May 2012 - 18:42

View PostXinok, on 08 May 2012 - 17:55, said:

I would argue that only professionals have any true reason to use C++. Newbies have no need for pointers, assembly, or manual memory management.

I would suggest learning C# with C (not C++) on the side. C will teach you low-level programming so you understand what's happening under the hood, while C# will teach you everything else and is the language you're more likely to use day to day.

The problem with C++ is a matter of poor design. It has so many hurdles and traps that it's a language that takes years to master.

I absolutely agree with this. I have seen enough horrible code in my lifetime made by coders that don't understand the underlying processes, thinking that the framework would "just do it" for them (which, most of the time it does, just not in an efficient way if you don't really know what's happening).

#30 MFH

    RAII fanatic

  • 1,978 posts
  • Joined: 24-June 10

Posted 08 May 2012 - 21:01

View PostDr_Asik, on 08 May 2012 - 13:21, said:

I've heard that from Herb Sutter and it's quite amusing. Yes, most of C++'s library has its complexities documented, but maybe because there isn't much more than containers and algorithms in the C++SL... Containers and algorithms in .NET also have their algorithmic complexities documented, but there is no point documenting the algorithmic complexity of a Printer or Socket class.
I think you got it wrong. Due to the fact, that .NET and Java use OO and a whole lot of interface cruft for their containers' interfaces (opposed to C++'s container definition) you actually can't rely on the complexity of the containers in them - especially if you're using collections that are returned from foreign code. For example what does the List<XYZ> guarantee in terms of complexity in Java? Well nothing really, as it's an interface, List<XYZ> may actually be an array (class ArrayList) or it may be a linked list -> totally different complexities (and memory layouts -> access patterns) are involved here! You have no way of telling which one it is based on List<XYZ>. A similar thing happens in .NET…

Let's compare that to std::list<XYZ>: what does it guarantee? Well quite a bit:
1. The elements are stored in a double-linked list - there is no way around that bit!
2. Every operation on this list has a well defined complexity that no standard conforming implementation is allowed to break
2a. Insertion at front and back: O(1)
[3. Compared to Java: this list is really type safe (opposed to Java's type erasure "hack") - at least that one Microsoft got right…]