If you could make breaking changes to C#, what would you do?
-
@jaloopa said in If you could make breaking changes to C#, what would you do?:
If you genuinely can't work out what it's doing then it's super hard to rewrite it and be sure you've caught all the edge cases.
True, but chances are you're in the code because what's there doesn't handle all the edge cases either.
@jaloopa said in If you could make breaking changes to C#, what would you do?:
In the real world, the unclear code is usually just a distraction on the way to finding the real issue you're trying to fix, and you're already a day behind on your estimate so stopping to refactor something peripherally related isn't a priority
I've found that doing a bit of refactoring can make the real problem easier to find. Not every time, but often enough I consider it a useful tool.
-
@raceprouk said in If you could make breaking changes to C#, what would you do?:
@cheong said in If you could make breaking changes to C#, what would you do?:
So the learning curve of the language becomes much steeper than it should have been.
If you can find a developer who can use a language they haven't learnt, I'll show you a conman.
Code written in the original C# language specification is readable by anyone who ever have experience in C-family languages, even when they never learnt C# before.
Every syntax change adds to the learning curve. Some change is necessary as they adds real functionality to the language (e.g.: generics) but a lot of others are just syntax sugars.
Now the question is, how much sugar to add before C# become yet another write only language ? I think a good way to measure would be: If you find a MVP or someone who should familiar with the language, explains how the new syntax works, and give them a tiny code segment using the syntax with bug to be debugged. If they are unable to correct it with their naked eyes, chances are the new syntax is not a good idea to add to the language.
-
@cheong said in If you could make breaking changes to C#, what would you do?:
If they are unable to correct it with their naked eyes, chances are the new syntax is not a good idea to add to the language.
That doesn't sound like a good metric to me. Not all bugs can be fixed by eye-balling the code: sometimes, you need to trace through it and see where certain values are coming from, and how they change.
-
@cheong said in If you could make breaking changes to C#, what would you do?:
I'd like to bring the rant in my comment here to attention.
MSDN forums never cease to suck.
For the record, that's an evidently wrong answer (it doesn't actually execute the code in the second string, so the result is
Input: input Begins with uppercase? input.StartsWithUpper() ? "Yes" : "No"
And yep, that was the answer proposed by the Microsoft moderator.
-
@raceprouk said in If you could make breaking changes to C#, what would you do?:
@cheong said in If you could make breaking changes to C#, what would you do?:
If they are unable to correct it with their naked eyes, chances are the new syntax is not a good idea to add to the language.
That doesn't sound like a good metric to me. Not all bugs can be fixed by eye-balling the code: sometimes, you need to trace through it and see where certain values are coming from, and how they change.
That's why I said "tiny segment". The example in my linked thread is actually just a one-liner that can be rewritten in three lines.
-
@pleegwat said in If you could make breaking changes to C#, what would you do?:
What if ORANGE contains a single statement, currently commented out for debugging?
if (everything.HasGoneToShit()) everyone.Panic(); else everyone.Relax();
What happens if the
else
line is commented out? Commenting out lines always has the chance to cause unexpected problems.
-
@maciejasjmj said in If you could make breaking changes to C#, what would you do?:
@cheong said in If you could make breaking changes to C#, what would you do?:
I'd like to bring the rant in my comment here to attention.
MSDN forums never cease to suck.
For the record, that's an evidently wrong answer (it doesn't actually execute the code in the second string, so the result is
Input: input Begins with uppercase? input.StartsWithUpper() ? "Yes" : "No"
And yep, that was the answer proposed by the Microsoft moderator.
As people who spend lots of time there, I could tell you that I think Wendy has not been able to pick up problems people asking there yet. But she is just an employee of contractor appointed by Microsoft (as you can see the badge named "contingent staff") to look after the forums, she does not need to be a C# expert there (or she could probably find a much better paying job).
But that's not the focus of problem I want to raise.
-
@cheong said in If you could make breaking changes to C#, what would you do?:
she does not need to be a C# expert there
Then why is she suggesting answers? If she doesn't know C#, she shouldn't be suggesting answers that simply will not work.
-
@coldandtired said in If you could make breaking changes to C#, what would you do?:
What happens if the else line is commented out? Commenting out lines always has the chance to cause unexpected problems.
I find relaxation after a good panic to be beneficial in most cases.
-
@raceprouk said in If you could make breaking changes to C#, what would you do?:
@cheong said in If you could make breaking changes to C#, what would you do?:
she does not need to be a C# expert there
Then why is she suggesting answers? If she doesn't know C#, she shouldn't be suggesting answers that simply will not work.
Marking answers is part of her job as moderator there. And if yourself is not sure about the answer of question, aim for replies of MVPs often give you good chance of marking a correct answer. Btw, it's not even marking answer, just "proposing" the reply as answer. People (including me) usually don't take that very seriously.
That also explains why people frequently complain about it. This type of question/discussion appear on that forum almost once every half year. (The second thread on this topic is only on the second page)
-
@cheong said in If you could make breaking changes to C#, what would you do?:
Marking answers is part of her job as moderator there.
No, her job is to moderate the discussion. That's why her role is 'moderator', not 'expert' or 'specialist'.
Answers should only be suggested by people who know what the answer should be.
-
@raceprouk said in If you could make breaking changes to C#, what would you do?:
@cheong said in If you could make breaking changes to C#, what would you do?:
Marking answers is part of her job as moderator there.
No, her job is to moderate the discussion. That's why her role is 'moderator', not 'expert' or 'specialist'.
Answers should only be suggested by people who know what the answer should be.
AFAIK, the contracting company (Pactera if I'm not mistaken) was using "number of question not answered in forum" as one of the metrics at performance review. That's why about once a year, you see that in some forums moderators actively "closing threads" (marking answers, convert questions to discussions, or moving thread to Off-topic forum)
-
@cheong Ah, so the issue is shitty performance metrics. Makes sense.
-
@raceprouk Btw, Microsoft had tried to remedy that by giving frequent visitor of the forums right to mark answer. Also I was also given that right, you can see from my activity that I seldom use it.
Why? I'll only read the thread if I'm interested on the topic, and if I'm interested on the topic I usually will join the discussion, making myself in inappropriate position to mark answer there.
-
@raceprouk said in If you could make breaking changes to C#, what would you do?:
@cheong said in If you could make breaking changes to C#, what would you do?:
So the learning curve of the language becomes much steeper than it should have been.
If you can find a developer who can use a language they haven't learnt, I'll show you a conman.
I solved Joel's MIT-Scheme question without knowing the language. Does that mean I'm a fraud? A conman? Forever doomed to either be a carpet installer or a fake?
-
@zecc said in If you could make breaking changes to C#, what would you do?:
@cheong said in If you could make breaking changes to C#, what would you do?:
"Efficiency to type" is rarely a bottleneck to development speed because after all, we need to think before we type. On the other hand, lacking "efficiency to read" will cause all kinds of maintainability problem, make beginners difficult to pick up the language, and make the code more error prone.
Why I'm for mandatory braces and semicolons.
Because you like to make things harder on newbies, thus holding off your competition?
-
@dreikin said in If you could make breaking changes to C#, what would you do?:
@zecc said in If you could make breaking changes to C#, what would you do?:
@cheong said in If you could make breaking changes to C#, what would you do?:
"Efficiency to type" is rarely a bottleneck to development speed because after all, we need to think before we type. On the other hand, lacking "efficiency to read" will cause all kinds of maintainability problem, make beginners difficult to pick up the language, and make the code more error prone.
Why I'm for mandatory braces and semicolons.
Because you like to make things harder on newbies, thus holding off your competition?
Uh, what? Is the goal here to make a language that's easy for newbies to pick up, or to make a language that does its job cleanly? The stated point was that mandatory braces and semicolons make code that's mandatorily easier to read.
-
@pie_flavor said in If you could make breaking changes to C#, what would you do?:
The stated point was that mandatory braces and semicolons make code that's mandatorily easier to read.
I don't agree.
Console.WriteLine("Hello, World!");
Console.WriteLine("Hello, World!")
Is one of those any harder to read than the other? And on a related note, if you had the latter embedded in the middle of a 20-line method, is there any obvious reason to believe something's wrong with it before the compiler screams at you?
-
@masonwheeler In well-written code there needs not be a difference.
The reason ASI is evil does not lie in readability, and I put optional braces on the same pile.
-
@cheong said in If you could make breaking changes to C#, what would you do?:
functionally identical to the previous version.
That shouldn't matter. What should matter is if it's functionally identical to the specs.
-
@masonwheeler said in If you could make breaking changes to C#, what would you do?:
@pie_flavor said in If you could make breaking changes to C#, what would you do?:
The stated point was that mandatory braces and semicolons make code that's mandatorily easier to read.
I don't agree.
Console.WriteLine("Hello, World!");
Console.WriteLine("Hello, World!")
Is one of those any harder to read than the other? And on a related note, if you had the latter embedded in the middle of a 20-line method, is there any obvious reason to believe something's wrong with it before the compiler screams at you?
How about this Kotlin code?
val value = Foo() .doSomething(bar)
Linebreak indicates the separation of ideas. You could easily interpret
value
to be simply a newFoo
object, since semicolons aren't required. But that's not the case - it's the result ofdoSomething
. A noob could easily misread that. It's also harder on the parser, for the same reason.
-
Not sure if this got mentioned before
in python
for item in container: if search_something(item): # Found it! process(item) break else: # Didn't find anything.. not_found_in_container()
Something like that in C# would be great.
-
@pie_flavor said in If you could make breaking changes to C#, what would you do?:
It's also harder on the parser, for the same reason.
Not particularly; you just have a parser rule that zero or more whitespace characters can exist in a member reference expression between a base value and the member reference. That's actually a very, very simple thing to put in a parser.
-
@lucas1 said in If you could make breaking changes to C#, what would you do?:
Not sure if this got mentioned before
in python
for item in container: if search_something(item): # Found it! process(item) break else: # Didn't find anything.. not_found_in_container()
Something like that in C# would be great.
I think a labeled break would be much more useful. Especially since you can just do this in Java:
loop: { for (Item item : container) { if (searchSomething(item)) { process(item); break loop; } } notFoundInContainer(); }
-
@pie_flavor said in If you could make breaking changes to C#, what would you do?:
I think a labeled break would be much more useful. Especially since you can just do this in Java:
Java's not my strongest language, but when you say "labels" and then have a
break loop;
in there, it almost looks like what you set up would be an infinite loop if a match exists in the container.
-
@pie_flavor No
foreach(var item in collection) { //snip } else { //snip }
Mine is much simpler to understand.
-
@masonwheeler No, that's not it at all. You're breaking out of the construct which was labeled. In this case, the outermost brace-block. This skips the
notFoundInContainer
function since it's contained within the brace-block.
-
@lucas1 Simpler to understand if you already understand what it's doing, maybe. I had to look up what the else clause meant to understand what the hell it was doing. What I'm saying is that labeled break/continue like Java has would be applicable in a much wider variety of situations. Similar to how the traditional
for
loop is complex and seems magic to noobs because it can be used for so many different things.
-
@pie_flavor said in If you could make breaking changes to C#, what would you do?:
Similar to how the traditional
for
loop is complex and seems magic to noobs because it can be used for so many different things.I assume you mean the C
for
loop?That's because it is magical and complex. It's not a
for
loop at all, per the original ALGOL definition; it's just a bunch of really weird syntactical sugar on top of awhile
loop.
-
@pie_flavor For real?
"if collection and has items loop and do { whatever in block }, if not do another thing."
-
@masonwheeler Who thinks a for loop is complicated except noobs to programming?
-
@masonwheeler I nicked the for else example straight from the python language docs.
The break exists in in a lot of languages but the whole for else construct he just didn't seem to grok.
-
@masonwheeler said in If you could make breaking changes to C#, what would you do?:
That's because it is magical and complex.
Ok, so what? All I'm saying is that they valued maneuverability over simplicity, which is a good choice to make.
@lucas1 said in If you could make breaking changes to C#, what would you do?:
@pie_flavor For real?
"if collection and has items loop and do { whatever in block }, if not do another thing."
Just because it's simple doesn't mean it's obvious. Especially given that
else
usually means simply what the English word used for it means. I don't know what keyword it would use, but 'else' seems wrong. And I'm maintaining that labeled break would be more useful than for(each)-else, especially since it can accomplish the same thing.
-
There is normally an if statement before a collection iteration in C# and in Java even if it is to check whether it is null.
-
@lucas1 o...k? I have no idea why that's relevant.
-
@pie_flavor because the construct I have proposed in a mythical language does it.
-
@lucas1 said in If you could make breaking changes to C#, what would you do?:
@pie_flavor because the construct I have proposed in a mythical language does it.
@pie_flavor said in If you could make breaking changes to C#, what would you do?:
@lucas1 o...k? I have no idea why that's relevant.
-
@pie_flavor Are you dense to the other possible uses?
-
@lucas1 said in If you could make breaking changes to C#, what would you do?:
@pie_flavor Are you dense to the other possible uses?
Perhaps you are misunderstanding which posts I am misunderstanding the relevance of since I didn't quote it.
@lucas1 said in If you could make breaking changes to C#, what would you do?:
There is normally an if statement before a collection iteration in C# and in Java even if it is to check whether it is null.
-
@pie_flavor yeh and the for else statement stops you from having to make the addition null check .. some nice syntactic sugar.
-
@lucas1 said in If you could make breaking changes to C#, what would you do?:
@pie_flavor yeh and the for else statement stops you from having to make the addition null check .. some nice syntactic sugar.
That's not true.
Try a
for ... else
construct in Python when you're iterating over something whose value isNone
, and you'll get:TypeError: 'NoneType' object is not iterable
-
@masonwheeler That kinda defeats the whole point of doing it. You can tell I do python in my spare time.
Fuck it python is shit then ;-)
-
@lucas1 said in If you could make breaking changes to C#, what would you do?:
@djls45 said in If you could make breaking changes to C#, what would you do?:
@lucas1 said in If you could make breaking changes to C#, what would you do?:
@djls45 It already does it.
case 1: case 2: doStuff(); default: doOtherStuff();
C# does that? Does it allow that with other cases than
default
?@djls45 yes if you define them. Thus Enums.
Actually, it doesn't allow that. In fact, MSDN explicitly states:
C# does not allow execution to continue from one switch section to the next.
The closest you can get to having fallthrough in c# is something like this:
case 1: case 2: doStuff(); goto default; default: doOtherStuff(); break;
-
@abarker No you just leave the goto out. I am sure I said that you can fall through swtich statements.
You could put in the goto default but it is defunct, unless you have a more case statements.
Sorry this isn't the gotcha that you think it is.
-
@lucas1 said in If you could make breaking changes to C#, what would you do?:
@abarker No you just leave the goto out. I am sure I said that you can fall through swtich statements.
You could put in the goto default but it is defunct, unless you have a more case statements.
Sorry this isn't the gotcha that you think it is.
You did say that, but that doesn't make you right. Check the spec again.
-
@lucas1 In C#, it's a compiler error not to end a
case
block with eitherbreak
,throw
, orgoto case
.
-
@abarker Nope.
-
@raceprouk when? I didn't say anything to do with ending a case block. I said about it falling through.
-
-
@raceprouk I never said anything about ending a case block.