0

Why you use C# if you can write C++?

I don't understand.

1st Mar 2018, 6:07 AM
Abilkasimov Kairat
3 Answers
+ 5
Because C# is more efficient in some cases. C# has LINQ. That alone makes working with data much more convenient. Also C# has a garbage collector and is, unlike C++, completely object oriented and you don't really have pointers. But you have Lists and Dictionaries. So both C++ and C# have different advantages and disadvantages and your choice depends on the project. C# is more modern and much easier to read as well.
1st Mar 2018, 6:40 AM
Kai Schlegel
Kai Schlegel - avatar
+ 3
C++ is also modern and you can make it easy to read. That is, if you're competent. And sometimes, a function can just be a function and mustn't be in a class, so I don't understand why you like the restrictions of fully object oriented languages. The C++ std library allows you also to work with data really well, especially since you can decide when it is deleted. Also, C# is almost never more efficient because the garbage collector causes overhead. C# is intended to create windows on Windows, C++ is used when you need much performance. But C# is not a modern, improved version of C++. It is closer to Java than to C++.
1st Mar 2018, 7:43 AM
Timon PaƟlick
+ 1
I like the restrictions of object oriented languages because object orientation should be strictly followed if you decide to work like that. As for the readability: Let's say you had a huge project, once written in C++ and once written in C++. Now compare those. In all of the bigger C++ projects I have seen, people use a ton of macros and header files, which both, in my oppinion, make code unnecessarily complex. Sure macros are a great thing, but it definetly makes big code harder to read since you have to constantly switch between all the files. By the way, by saying C# was more efficient in some cases, I wasn't talking about the performance. I was thinking about the amount of work required. Take LINQ to XML for example, personally, I don't know a better way of working with XML files. If you know one let me know please :)
1st Mar 2018, 8:10 AM
Kai Schlegel
Kai Schlegel - avatar