Procedural-like Syntax Layer for Beginners in C# #115222
Unanswered
EdvaldoDantas
asked this question in
Ideas
Replies: 1 comment
-
C# language discussion belongs to https://github.com/dotnet/csharplang/discussions . It's very disliked to make the code sensible to make the code sensitive to file system. See dotnet/csharplang#2908 dotnet/csharplang#4722 |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
As a suggestion to make C# more beginner-friendly, especially for those coming from procedural languages like C or Python, I propose the introduction of a "procedural-like" syntax layer in C#.
The idea is to allow developers to write simple functions in separate files without needing to define classes or access modifiers. For example:
int Sum(int x, int y) { return x + y; }
Behind the scenes, the compiler would transform this into:
public static class SumFile {
public static int Sum(int x, int y) { return x + y; }
}
And to call it:
SumFile.Sum(2, 3);
This would provide a more approachable experience for newcomers by reducing initial syntax overhead, while still compiling into proper, structured C# code. It builds upon the existing top-level statements feature and expands it for better modularity.
I believe this feature could attract more students and beginners to the C# ecosystem.
Beta Was this translation helpful? Give feedback.
All reactions