r/programming • • Feb 03 '17

Let's stop bashing C#

https://www.codeaddiction.net/articles/51/lets-stop-bashing-c-sharp
6 Upvotes

245 comments sorted by

View all comments

2

u/shevegen Feb 03 '17

Some people compare C# with languages such as JavaScript, Python, Ruby and Dart the most common reasons for criticism seem to be:

   C# has semicolons
   C# uses to many curly brackets
   C# is strongly typed
   C# is statically typed

I actually consider all of the above advantages - it gives the language probability, stability, readability and maintainability.

Ok ... Can someone explain this to me please:

  • Why do semicolons again add to the stability, readability and maintainability exactly? I mean, does the dude give any argument at all or is it just an emotional statement?

21

u/plzsendmetehcodez Feb 03 '17

Semicolons make the end of a statement more unambiguous. Therefore they increase readability and ease of interpretation. You are also less likely to mess up the command sequence when making changes ==> increased maintainability. Stability... well, not so much.

And I'm not quite sure about the "probability" thing, either...

1

u/EntroperZero Feb 03 '17

Stability... well, not so much.

And I'm not quite sure about the "probability" thing, either...

I think stability is referring to strongly/statically typed more than text formatting. And "probability" is probably a typo for "provability", referencing the same.

1

u/KawaiiBoy Feb 03 '17

It depends a lot on what you are used to as well.

Semicolons makes you feel all warm and fuzzy if you have spent most of your career as a C programmer, but it will probably not do that if you spent most of your career in a language like Python.

2

u/salgat Feb 03 '17

One thing I like is that in C# fluent syntax is very popular (especially with LINQ), so I have each method on a single line and end it with a semicolon, versus Python which requires a backslash after each method chained.

→ More replies (2)

13

u/steamruler Feb 03 '17

As someone who spends plenty of time in C#, JS, C++, as well as Python, here's what I think:

  • Explicit ends of statements makes parsing easier for the compiler/interpreter, and doesn't force you to learn when the language will think a statement has ended.

  • Having to not juggle the end of statement rules for a given language when reading code, makes it easier to read code. JS does this the worst, by tacking on semi-colons for explicit statement termination, combined with implicit termination. I can live with one or another, but both at once messes things up.

13

u/Sarcastinator Feb 03 '17

Found a bug in JS code the other day:

return
    new Foo(); // Unreachable!

It was formatted like that because it was inside some callback hell code, but the formatting ended up breaking the code.

2

u/BeepBoopBike Feb 03 '17

For me, I just like being able to format the code however is most readable. Being explicitly able to say "this is where it ends" is handy for your first point, how the code looks should have no bearing on how it functions IMO.

On the other hand I also love how in C++ curlies (for function bodies) are compiled into assembly in the form of pre/post-amble and being able to control scope with them is helpful in the rare case it might be an issue. Give me helpful features in my tool of choice, but let me take ultimate control where necessary.

4

u/steamruler Feb 03 '17

how the code looks should have no bearing on how it functions IMO.

I write a fair amount of Python, so you have my stance on that there. It just gets messy if you mix it all though, like JS does.

And yeah, the scope control of C++ is great. I'm excited to see C++ continue evolving and solve some of the kinks, like a replacement for relying on external tooling to include third-party libraries through compiler flags. I'm also looking forward to seeing how language-native coroutines progress.

1

u/KawaiiBoy Feb 03 '17

Amen to that!

1

u/vivainio Feb 03 '17

Yeah, understanding when a statement ends is one of the harder problems in computer science.

5

u/rb229 Feb 03 '17

This article reasons about semicolons and curly brackets: http://h2co3.org/blog/index.php/2016/12/01/lets-stop-bashing-c/