When comparing C vs C#, the Slant community recommends C for most people. In the question“What is the best programming language to learn first?” C is ranked 8th while C# is ranked 17th. The most important reason people chose C is:
Learning C forces you to grapple with the low-level workings of your computer (memory management, pointers, etc.) in ways that the other languages abstract away. Without an understanding of these low-level aspects of computer programming you will be limited if you try to develop an application that needs to run in a memory or performance constrained environment. Other languages like Python can obscure a lot of details, so your foundation may be weaker.
Ranked in these QuestionsQuestion Ranking
Pro Understanding of computers
Learning C forces you to grapple with the low-level workings of your computer (memory management, pointers, etc.) in ways that the other languages abstract away. Without an understanding of these low-level aspects of computer programming you will be limited if you try to develop an application that needs to run in a memory or performance constrained environment.
Other languages like Python can obscure a lot of details, so your foundation may be weaker.
Pro Industry standard
C is the industry standard programming language, moreover, it is the most popular programming language to use. C is the language used for most Windows, UNIX and Mac operating systems.
Pro Helps with learning other languages later
Capability to program in C is greatly appreciated in developers, creates an image of competency, and many programmers will learn it at some point in their careers.
C is portable between most hardware. Generally a C compiler is made for any new architecture, and already exists for existing architectures.
C is portable between all operating systems (Windows, UNIX, Mac, etc.) and only needs a program to be recompiled to work. This allows anyone on any operating system to learn about the language and not be held back by intricacies of their operating system.
With this said, C's portability these days is not quite what it used to be. Much of said portability relies on the POSIX standard in particular, and as time passes, the compliance of a given system with that standard is becoming less certain; especially in the case of Linux. Most things will still be portable (or at least emulatable) between Windows, Linux, and FreeBSD for example; but you will at times need to make use of platform-specific support libraries and APIs as well.
Pro Low level of abstraction
While higher level languages languages like Java and Python provide possibilities to be "more expressive" per line of code, it's much more convenient to start with "less efficient" (get me right) language, in order to get initial concepts of how things behave at lower level.
Actually C is a good starting point moving to both higher and lower levels of abstraction, the good example here would be learning C before Assembler, as for general use the Assembler quite hard to understand due to low level of its abstraction (like getting the understanding on how loops work in C before trying to implement them on Assembler).
Pro Teaches good practices
Writing in C will require you to understand how things are done. C implies using and understanding the fundamentals. Learning a higher-level language after is much easier.
Pro If you can't grok C you should not be a professional programmer
It sets an early bar that if you can't hurdle you might as well do something other than programming and not waste any more of your time.
Pro The king of languages, imitated, extended but never equalled
Made of a small set of keywords and rules, only your imagination is the limit. Above all, when it comes to 'pro' programming, C is the only one to rely on.
Pro C is simple with lesser rules than any other language
C is standardized and it is the goto language when you have to speed things up
Pro Basic concepts can be applied to accelerate learning any other language
You can easily pivot knowledge learned here and apply it to almost every other language.
Pro Portable between CPU architectures
C was design to be independent of any particular machine architecture, and so with a little care it is easy to write "portable" programs. By design, C provides constructs that map efficiently to typical machine instructions, and therefore it has found lasting use in applications that had formerly been coded in assembly language like operating systems or small embedded systems.
for first edition of The C Programming Language by Brian Kernighan and Dennis Ritchie
Pro More control over the code
Pro Easy to drop down to assembly.
Sometimes you really need to program directly in assembly. C’s ABI and common compiler extensions make this a piece of cake.
Pro .NET is a great toolbox
C# runs on top of the .NET framework, which provides many libraries containing classes used for common tasks such as connecting to the Internet, displaying a window or editing files. Unlike many other languages, you don't have to pick between a handful of libraries for every small task you want to do.
Pro Awesome IDE for Windows
On Windows, Visual Studio is the recommended C# IDE. It provides a very flexible GUI that you can rearrange the way you want and many useful features such as refactorings (rename a variable, extract some code into a method, ...) and code formatting (you can pick exactly how you want the code to be formatted).
Visual Studio also highlights your errors when you compile, making your debug sessions more efficient since you don't have to run the code to see the mistakes. There's also a powerful debugger that allows you to execute the code step-by-step and even change what part of the code will be executed next. In addition to giving you all the line-by-line information you'll need in a hassle-free manner, Visual Studio has stuff you can click on in the errors window that will take you to the documentation for that error, saving you several minutes of web searching.
In addition to all of this, Visual Studio has an intuitive, intelligent, and helpful graphical user interface designer that generates code for you (the best of WYSIWYG, in my opinion), which is helpful for new programmers. Being able to create a fantastic-looking UI with one's mouse and then optionally tweak with code helps make programming fun for beginner developers.
Visual Studio also has the best code completion --Intellisense is every bit as intelligent as the name says it is. It, as well as VS's parameter hinting, is context-, type-, user-, and position-sensitive, and displays relevant completions in a perfectly convenient yet understandable order. This feature allows a new programmer to answer the questions "What does this do?" and "How do I use it?" right then and there rather than having to switch to a browser to read through extensive documentation. This allows the programmer to satisfy their curiosity before it is snuffed out by several minutes of struggling through exhaustive documentation.
And for the more adventurous and text-ready developer, Microsoft does the best job of ensuring that everything, from interfaces and wildcard types down to Console.WriteLine("") and the + operator, is well-documented and easy to understand, with relevant and well-explained usage examples that manage to be bite-size yet complete, simple yet truly helpful. The reference site is easy to navigate, well-organized, clean and uncluttered, up-to-date, and fresh and enjoyable to look at, and every page is well-written with consideration for readers who are not C# experts yet want to read about changing the console background color.
The best part? It's free! Visual C# Express contains all of the features described above, at zero cost. If you are a student, you can probably get Visual Studio Professional from your university, which also includes tools for unit testing and supports plugins.
Pro Incredibly Well-Engineered Language
Where other languages invoke the feeling of being a product of organic growth over time, C# just feels like an incredibly well-designed language where everything has its purpose and almost nothing is non-essential.
Pro Supports some functional features
C# is primarily object-oriented, but it also supports some features typically found in functional languages such as lambdas, delegates and anonymous classes. Methods can be treated like any other object, and the Linq query system operates on monads with lazy evaluation (though it hides this with a lot of syntactic sugar).
You don't need to use these features to code in C#, though, so you can start with OOP and then learn about them.
Pro Great introduction to object-oriented programming
Object-oriented programming is the most widely-used paradigm. C# offers support for common OOP features such as classes, methods and fields, plus some features not found in competing languages like properties, events and static classes.
C# code is much more readable thanks to the syntactic sugar it offers. You can truly concentrate on your code, not on the way it's implemented.
Pro Best language for Windows programs
C# is clearly the best choice for Windows programs. The .NET framework contains everything you need to build great-looking apps, without having to learn the confusing Win32 API or download a ton of external libraries. C# can also be used to build Windows 8's "modern" apps.
Pro Supported on many platforms
C# can be used for Windows apps, Linux apps, OS X apps, Windows 8 "modern" apps, websites, games, iPhone apps, Android apps, Windows Phone apps, and more.
If you want to create a cross-platform application, you can share most of the code and write one GUI for each platform.
Pro Can mix high and low level programming
You can code at the high level without worrying about pointers and memory management, but if you so choose you can switch to lower level programming with direct memory management and pointer manipulation (though you need to compile to specifically allow this).
Pro Very high demand in the industry.
Pro With ASP CORE a good language to learn
With CORE you are no longer just limited to Windows, so a language worth learning.
Pro .NET truly universal
With .NET core it is a truly universal programming language which support desktop apps (Windows), Mobile apps (Xamarin), Web Apps (ASP.Core MVC). Also is perfectly fit to serverless programming for micro services. Soon it will be also support Web assembly (Blazor).
Pro Great language for Unity game engine
Unity provides a selection of programming languages depending on preference or knowledge - C#, JS, Boo and UnityScript. C# is arguably the most powerful with better syntax and stronger language structure. It allows using script files without attaching them to any game object (classes, methods inside unattached scripts that can be used at any time). There are more tutorials and information for C# than UnityScript and Visual Studio can be used to code for unity in C#. Additionally, learning C# allows using it outside of Unity as well unlike UnityScript.
Con Languages is full of corner cases and undefined behaviors
Undefined behavior in a program can cause unexpected results, making it hard to debug. With UB, program behavior may vary wildly depending on optimization settings. There are many cases that invoke UB, such as signed overflow, invalid dereferences, large integer shifts, uninitialized variables, etc. These serve to frustrate novice programmers when they could be learning other concepts.
Con C will require you to learn concepts too advanced for most beginners
While other programmers will learn algorithms and structures and will do magic tricks and awesome applications, you will learn trash info that you should know maybe after 5-7 years experience in software development, not earlier. It's like going the first time as a seven year old kid to first school class, and your teacher tells you to learn you about Discrete Math, without basic math and how to do 2x2.
If you wish to be a really good programmer, C for sure will be in your portfolio, but not as a first language, and this programming language is used only for very hard and very limited tools which require a lot of professional skills from the programmer.
Con Requires memory management
Learning programming is already hard enough when you don't have to worry about memory leaks.
Con Does not support modules; header file annoyances
Header files are a poor man's implementation of modules. Modern programming languages make use of modules which eliminate the need for C includes and header files and the many issues caused by them, such as the complete lack of dependency checking. Header files often contain even more include statements that point to other header files which also point to even more which drastically increases compile time. Modules only have to be compiled once, and when importing those modules into your software project, you only have to pull in the module that you are using, which is often times already precompiled. This way, the compiler knows exactly what it needs before beginning to compile your project and can automatically compile the few dependencies it needs in advance rather than recursively compiling every header file it runs across as in C.
Con Completely lacks type safety
The C standard library is not type safe, and the language itself does not promote type safety built into the language, which leads to error-proneness of the language. If anything, it would be recommended that those interested in C to instead put their time in D, which actually includes a complete copy of the C standard library rewritten to be fully type safe.
Con Long learning curve
While the language compliments knowledge of computer components very well, and gives a deeper understanding, it is also quite difficult to learn, and to use correctly, especially without aforementioned knowledge.
Depending on the purpose this can be either a pro or a con. If the task is to learn how to program, low-level of C will impend learning important concepts. Furthermore, C is rather limited in ways of building abstractions.
"Low-levelness" of C can be a pro feature in learning system programming.
Con Lack of support for first class strings
C does not support the string type, nor does it support UTF-8 strings that modern languages are employing today. Instead of strings, C makes use of the *char type which is a pointer to a character array.
Con Arrays are not first class objects
When an array is passed to a function, it is converted to a pointer, even though the prototype confusingly says it's an array. When this conversion happens, all array type information gets lost. C arrays also cannot not be resized, which means that even simple aggregates like a stack are complicated to implement. C arrays also cannot be bounds checked, because they don't know what the array bounds are.
Con Isn't truly portable or cross platform
The C programming language is not portable to other operating systems, and even different compilers, because the C language does not provide any reference cross platform libraries or compilers. Different platforms and compilers provide their own implementation of the C standard library which may not be compatible with the implementation in another compiler or platform. Without cross platform libraries and tools, one cannot state that C is portable. This is in stark contrast to modern programming languages that provide their own cross platform libraries and compilers, such as D, Go and Rust.
Con Compiles procedurally rather than intelligently
In the same manner that C recursively compiles header files ad infinitum without any sort of dependency checking, C source code is also compiled in the same manner. If you attempt to call a function before it is declared, the compiler will fail because the function was not compiled before it was caled.
Con C structs are very weak and outdated
C structs lack a lot of modern capabilities that are vital in programming languages of today, such as assigning member functions to structs to give them object-oriented capabilities, constructs, deconstructors and RAII. Great care must be used when using structs in C to prevent memory leaks and ridiculously slow structs.
Con The need for C developers in the current market is very low, and trending downward
Older languages, like C, are no longer in their hay day. Even if you do learn it as your first language, you are only setting yourself up to need to learn another language in the long run. If you want a skill that you can not only learn from, but also potentially build a career on, C should not be your first choice.
Con Undefined behaviors and weak limited type safety
Subtle errors can render the entire program "undefined" by the complicated C standard. The standard imposes no requirements in such cases. Thus C compiler is free to ignore the existence of such cases and Bad Things are prone to happen instead. Even experts can't reliably avoid undefined cases in C, so how can beginners be expected to do so? C allows for non-type safe operations such as logic errors, wild pointers, buffer overflow, etc. UB and type safety issues create a large number of bugs and security vulnerabilities.
Con Only offers basic support for source code split into multiple files
Modern programming languages are capable of compiling split source code files by concatenating them together efficiently at compile time before compiling them. However, C requires the developer to resort to messing with header files and makefiles to get similar functionality.
Con Includes require obscene resources to compile
All the modern languages have resulted in ditching the ancient deprecated model of #include statements and have instead adopted the superior model of modules. When compiling software written in C, the programmer is forced to also compile X headers which contain Y headers which contain Z headers and so forth -- drastically increasing the number of lines that need to be compiled. In order to compile something as simple as "Hello, World", for example, 18K lines of code needs to be compiled. This can be very taxing on RAM and CPU resources, causing compile times to quickly absorb a large portion of the programming process.
Con Heavily outdated programming concepts
C lacks a large majority of programming concepts that modern languages make use of today. The existing functionality of C makes use of outdated and deprecated methodologies which can be of great annoyance to the modern day programmer.
Con Dependecy on IDE
Most people learn and depend on VisualStudio to write C#. The result is people learn how to use an IDE and not the concepts or fundamentals of good programming. This isn't necessarily a knock on the language itself, but it is frustratingly difficult to do things in C# when not using VS.
Con Too easy to write multithreading apps that are buggy
Many web frameworks or GUI libraries will push novice users to writing multithreaded code, which leads to frustrating race condition bugs.
Other languages with multithreading push users towards safe constructs, like passing messages and immutable or synchronized containers. But in C# the data structures aren't synchronized by default, and it's too easy to just set a field and observe the result from another thread (until you compile with Release, and now you have a heisenbug).
Con Often-used products in most C# development environments get expensive
The majority of the C# development community uses Microsoft products which are not all free and open-source. As you get into the enterprise level of some of these products and subscriptions, the expense is multiple factors of 10 greater.
While you can use a fully open-source and free C# environment, the community around that is much smaller. While this can be said for other languages as well, the majority of C# falls into the for-pay Microsoft realm.
Con Complex syntax
Too many syntactic constructs to learn before it becomes usable.