dotnet / csharplang

The official repo for the design of the C# programming language
11.61k stars 1.03k forks source link

Make C# more beginner friendly #1469

Closed gulshan closed 4 years ago

gulshan commented 6 years ago

As great as the language C# is, currently I don't see it is being used for introduction to programming that much. Beginning programming with some language increses it's mindshare and markertshare in my opinion. So, I would like to raise some points which I think will make C# more "beginner friendly". Many of these are found from comparison with Python (which is kind of first choice for beginners nowadays'). And while some of them are language issues, some others are about tooling or library. But I'm keeping all of them together here.

Most of these are already proposed. I am just posing them together with a focus on simplicity for the beginners.

HaloFour commented 6 years ago

This repository is specifically about changes to the language specification. Most of your "proposals" don't involve language changes and the others I feel are already covered by other proposals so I don't think that your meta-proposal is particularly necessary.

svick commented 6 years ago

I think Microsoft can (and should) bundle [.net sdk] with Windows

Which version of the SDK and runtime? A Windows installation can live for many years, but an important feature of the .Net Core SDK is that various versions of it can live side-by-side (and are not interchangeable). So what policy should Windows use to decide which version of the SDK and runtime to install and upgrade?

I think Microsoft can (and should) […] talk to Linux distributions to bundle it

I think one reason why this hasn't happened yet is that .Net Core SDK wasn't buildable from source (it required some binary assets). But fixing that is underway at dotnet/source-build, so I hope .Net Core SDK will start showing up in official repositories of Linux distributions in the near future.

But the process [of running in browser] should more readily available, adopted and highlighted in various ways where appropriate like documentation and tutorials (both first party and third party).

The official docs gained the ability to run code in the browser fairly recently. I expect more and more documentation will be converted to use that approach over time (and you can help by submitting PRs).

When someone is just starting to learn programming, creating a "project", whether visually or through command line dotnet new is a hurdle s/he has to overcome. So, it will be helpful for beginners if a single file can be run with a single command. Something like dotnet run file.cs will be useful.

I think running a single .cs file doesn't make much sense, but running a .csx (C# script) file is a great idea. According to https://github.com/dotnet/cli/issues/2336#issuecomment-259597011, scripting is not going to be part of .Net Core SDK itself.

But .Net Core 2.1 will have better support for tools like filipw/dotnet-script. With that, you should be able to do this:

dotnet install tool -g dotnet-script
dotnet script file.csx

I think that's good enough.

Focus on scripts

I mostly agree, see above.

Programming languages resembling more to human language(English to be specific) is easier to begin with.

I don't think this is a good idea. Even if it made learning the language slightly easier, I think it would still make the language worse overall.

list and dictionary syntax

There are proposals for that: https://github.com/dotnet/csharplang/issues/1238 or https://github.com/dotnet/csharplang/issues/1399.

So, local immutables with let will make the life easier for beginners IMO.

Isn't learning two different syntaxes (var and let) actually harder? Whether you like it or not, mutable variables are and will be an important part of programming in C#. I think beginners should learn about them, even if good support for immutable variables existed in C#.

svick commented 6 years ago

@HaloFour

This repository is specifically about changes to the language specification. Most of your "proposals" don't involve language changes and the others I feel are already covered by other proposals so I don't think that your meta-proposal is particularly necessary.

Do you know of a good place where such overarching discussions can take place?

While ensuring that discussion stays on-topic is to some degree necessary (especially when it comes to details about issues that belong to some other repo), I think being too strict about isolating discussions into their respective repos can be harmful to the community.

HaloFour commented 6 years ago

@svick

Do you know of a good place where such overarching discussions can take place?

Out of the dotnet repos I honestly don't know. They all seem to direct unrelated conversations to the other repos to keep their Issues section on topic. Some direction from MS might be a good idea here.

That said, in this case I don't necessarily think there is an overarching theme. Each of the proposals above are disparate and orthogonal and only loosely bound by the subjective notion that they would make C# easier to learn.

ufcpp commented 6 years ago

Running in browser: https://try.dot.net/ https://github.com/dotnet/try list and dictionary syntax: https://github.com/dotnet/csharplang/issues/414 https://github.com/dotnet/csharplang/issues/1238

sharwell commented 6 years ago

The interesting thing about beginners is they never stay that way for long. One of the following will happen:

  1. They lose interest and stop using the language
  2. They stop being beginners and move on to "advanced"

It's important to keep the second in mind while trying to avoid the first¹. Features aimed at beginners should only be implemented if they continue to be useful features of non-beginners. Otherwise the whole situation becomes a bait-and-switch, making it much harder to move on from being a beginner.

¹ It's fine to lose interest if programming isn't what you want to do in life, but we want strong retention for programmers interested in solving problems for which C# is a good fit among one or more available options.

gulshan commented 6 years ago

Features aimed at beginners should only be implemented if they continue to be useful features of non-beginners.

Agreed. But usefulness is subjective IMO.

sharwell commented 6 years ago

@gulshan Here's my initial comments on the original post:

KathleenDollard commented 6 years ago

I agree that C# can be easier for beginners.

Some of the language changes you propose are already available in VB. Why not encourage beginners there?

I have watched several beginners struggle with x = x + 1. However, I think this moment of rethinking is a really important first step. I'd like to make the language around it easier to find (maybe Try.dot.net), but I think it's a speed bump folks need to address.

I wonder if for many programmers the "basic graphics" isn't really "something I can see." Do you think Unity may play a role here? Or just simple WinForms programs that are much simpler than a website?

svick commented 6 years ago

@KathleenDollard

I have watched several beginners struggle with x = x + 1. However, I think this moment of rethinking is a really important first step. I'd like to make the language around it easier to find (maybe Try.dot.net), but I think it's a speed bump folks need to address.

This reminds me of SharpLab's recently added Explain mode. It takes a piece of C# code, explains all the features used in it and links to their documentation. I think it could be useful for beginners looking at unfamiliar piece of code.

Currently, it doesn't explain the basics like =, but that's something that could be added.

DavidArno commented 6 years ago

I have watched several beginners struggle with x = x + 1

Then don't teach them it. Mutating variables in that fashion is counter-intuitive to beginners and hard for even experienced developers to follow in their heads when the code gets more complex. So encourage immutability of variables:

var x2 = x + 1; // problem solved
KathleenDollard commented 6 years ago

It depends on what is going on.

You're right that it's sensible to learn assignment (the hard part, that was an equality operator since Kindergarten) separate from mutability.

When the underlying thing is changed, it should mutate. Reusing a variable other than to indicate the inherit mutability of the thing (a loop counter, for example) is not helpful.

I suspect we agree, but lack context due to x's, which is probably a more important thing for beginners - work with something they know or can see - moving things around on screen (Winforms, Unity, etc) is my go to.

DavidArno commented 6 years ago

@KathleenDollard,

I suspect we agree...

I suspect we do, too. But I tell you what, I'll add your functional C# talk at SDD in a couple of weeks to my list of talks to attend and will let you know afterwards 😀

KathleenDollard commented 6 years ago

I look forward to meeting you at SDD! Be sure to track me down.

That talk is definitely not a beginner's talk :)

LeonG-ZA commented 6 years ago

It's already extremely beginner friendly. The most beginner friendly compared to everything else in my opinion.

ahdung commented 6 years ago

agree, need do until