▲ 333 ▼ Why make it complicated? (lemmy.ml) submitted 1 year ago* by HiddenLayer555@lemmy.ml to c/programmer_humor@programming.dev 123 comments fedilink hide all child comments Made with KolourPaint and screenshots from Kate (with the GitHub theme).
[–] piccolo@sh.itjust.works 8 points 1 year ago* (1 child) In C#, you can use 'var' to have an impilict type variable. String name = "" var name = "" permalink fedilink source parent hideshow 2 child comments replies: [–] pipe01@programming.dev 24 points 1 year ago (1 child) So, a keyword permalink fedilink source parent hideshow 2 child comments replies: [–] sus@programming.dev 20 points 1 year ago* (last edited 1 year ago) (3 children) So I think it's still probably unclear to people why "mix of keywords and identifiers" is bad: it means any new keyword could break backwards compatibility because someone could have already named a type the same thing as that new keyword. This syntax puts type identifiers in the very prominent position of "generic fresh statement after semicolon or newline" ..though I've spent like 10 minutes thinking about this and now it's again not making sense to me. Isn't the very common plain "already_existing_variable = 5" also causing the same problem? We'd have to go back to cobol style "SET foo = 5" for everything to actually make it not an issue permalink fedilink source parent hideshow 6 child comments replies: [–] piccolo@sh.itjust.works 4 points 1 year ago Ah I was misunderstanding the problem. And learned something new about C#, seems in order to avoid breaking existing code they introduce "contextual keywords" var being added later, it is a contextual. You can create a class 'var' and the compiler will prefer it. permalink fedilink source parent [–] AnotherPenguin@programming.dev 3 points 1 year ago (1 child) At least in C#, you can define variables with keyword names like this: var @struct = "abc" I think in Kotlin you can do the same, and even include spaces with backticks like val abstract class = "abc" I'm not sure if other languages allow that, regardless it should be rarely used. permalink fedilink source parent hideshow 2 child comments replies: [–] pivot_root@lemmy.world 4 points 1 year ago (1 child) Swift also uses backticks and Rust has a dumb one in the form of r#thekeyword. Still much better than introducing a async as a new keyword in a minor version of a language and breaking a bunch of libraries. permalink fedilink source parent hideshow 2 child comments replies: [–] fayaz@lemmy.world 4 points 1 year ago Python? permalink fedilink source parent [–] HiddenLayer555@lemmy.ml [S] 1 point 1 year ago* (1 child) any new keyword could break backwards compatibility Wouldn't that happen anyway with variable and function names? Any type other than primitive/built in ones are usually camel case so lower case keywords are more likely to clash with single word variable and function names, unless you restrict the cases of those too or allow keyword overriding or something. permalink fedilink source parent hideshow 2 child comments replies: [–] sus@programming.dev 3 points 1 year ago* (1 child) Yeah, it's in my edit I realized the same thing. I'm thinking it doesn't actually really make sense and the real reason is more "the specific way C does it causes a lot of problems so we're not poking syntax like that with a 10 foot pole" + "it makes writing the parser easier" + maybe a bit of "it makes grepping easier" permalink fedilink source parent hideshow 2 child comments replies: [–] HiddenLayer555@lemmy.ml [S] 1 point 1 year ago* One thing that annoyed me about C# as a Java guy is that it really wants you to use camel case for function and property names, even private ones. I don't like it specifically because it's hard to differentiate between a function/property and a type. But C# has quite a few keywords and seem to like adding them more than Java. Maybe that's their way of ensuring keywords don't clash with stuff? permalink fedilink source parent
[–] pipe01@programming.dev 24 points 1 year ago (1 child) So, a keyword permalink fedilink source parent hideshow 2 child comments replies: [–] sus@programming.dev 20 points 1 year ago* (last edited 1 year ago) (3 children) So I think it's still probably unclear to people why "mix of keywords and identifiers" is bad: it means any new keyword could break backwards compatibility because someone could have already named a type the same thing as that new keyword. This syntax puts type identifiers in the very prominent position of "generic fresh statement after semicolon or newline" ..though I've spent like 10 minutes thinking about this and now it's again not making sense to me. Isn't the very common plain "already_existing_variable = 5" also causing the same problem? We'd have to go back to cobol style "SET foo = 5" for everything to actually make it not an issue permalink fedilink source parent hideshow 6 child comments replies: [–] piccolo@sh.itjust.works 4 points 1 year ago Ah I was misunderstanding the problem. And learned something new about C#, seems in order to avoid breaking existing code they introduce "contextual keywords" var being added later, it is a contextual. You can create a class 'var' and the compiler will prefer it. permalink fedilink source parent [–] AnotherPenguin@programming.dev 3 points 1 year ago (1 child) At least in C#, you can define variables with keyword names like this: var @struct = "abc" I think in Kotlin you can do the same, and even include spaces with backticks like val abstract class = "abc" I'm not sure if other languages allow that, regardless it should be rarely used. permalink fedilink source parent hideshow 2 child comments replies: [–] pivot_root@lemmy.world 4 points 1 year ago (1 child) Swift also uses backticks and Rust has a dumb one in the form of r#thekeyword. Still much better than introducing a async as a new keyword in a minor version of a language and breaking a bunch of libraries. permalink fedilink source parent hideshow 2 child comments replies: [–] fayaz@lemmy.world 4 points 1 year ago Python? permalink fedilink source parent [–] HiddenLayer555@lemmy.ml [S] 1 point 1 year ago* (1 child) any new keyword could break backwards compatibility Wouldn't that happen anyway with variable and function names? Any type other than primitive/built in ones are usually camel case so lower case keywords are more likely to clash with single word variable and function names, unless you restrict the cases of those too or allow keyword overriding or something. permalink fedilink source parent hideshow 2 child comments replies: [–] sus@programming.dev 3 points 1 year ago* (1 child) Yeah, it's in my edit I realized the same thing. I'm thinking it doesn't actually really make sense and the real reason is more "the specific way C does it causes a lot of problems so we're not poking syntax like that with a 10 foot pole" + "it makes writing the parser easier" + maybe a bit of "it makes grepping easier" permalink fedilink source parent hideshow 2 child comments replies: [–] HiddenLayer555@lemmy.ml [S] 1 point 1 year ago* One thing that annoyed me about C# as a Java guy is that it really wants you to use camel case for function and property names, even private ones. I don't like it specifically because it's hard to differentiate between a function/property and a type. But C# has quite a few keywords and seem to like adding them more than Java. Maybe that's their way of ensuring keywords don't clash with stuff? permalink fedilink source parent
[–] sus@programming.dev 20 points 1 year ago* (last edited 1 year ago) (3 children) So I think it's still probably unclear to people why "mix of keywords and identifiers" is bad: it means any new keyword could break backwards compatibility because someone could have already named a type the same thing as that new keyword. This syntax puts type identifiers in the very prominent position of "generic fresh statement after semicolon or newline" ..though I've spent like 10 minutes thinking about this and now it's again not making sense to me. Isn't the very common plain "already_existing_variable = 5" also causing the same problem? We'd have to go back to cobol style "SET foo = 5" for everything to actually make it not an issue permalink fedilink source parent hideshow 6 child comments replies: [–] piccolo@sh.itjust.works 4 points 1 year ago Ah I was misunderstanding the problem. And learned something new about C#, seems in order to avoid breaking existing code they introduce "contextual keywords" var being added later, it is a contextual. You can create a class 'var' and the compiler will prefer it. permalink fedilink source parent [–] AnotherPenguin@programming.dev 3 points 1 year ago (1 child) At least in C#, you can define variables with keyword names like this: var @struct = "abc" I think in Kotlin you can do the same, and even include spaces with backticks like val abstract class = "abc" I'm not sure if other languages allow that, regardless it should be rarely used. permalink fedilink source parent hideshow 2 child comments replies: [–] pivot_root@lemmy.world 4 points 1 year ago (1 child) Swift also uses backticks and Rust has a dumb one in the form of r#thekeyword. Still much better than introducing a async as a new keyword in a minor version of a language and breaking a bunch of libraries. permalink fedilink source parent hideshow 2 child comments replies: [–] fayaz@lemmy.world 4 points 1 year ago Python? permalink fedilink source parent [–] HiddenLayer555@lemmy.ml [S] 1 point 1 year ago* (1 child) any new keyword could break backwards compatibility Wouldn't that happen anyway with variable and function names? Any type other than primitive/built in ones are usually camel case so lower case keywords are more likely to clash with single word variable and function names, unless you restrict the cases of those too or allow keyword overriding or something. permalink fedilink source parent hideshow 2 child comments replies: [–] sus@programming.dev 3 points 1 year ago* (1 child) Yeah, it's in my edit I realized the same thing. I'm thinking it doesn't actually really make sense and the real reason is more "the specific way C does it causes a lot of problems so we're not poking syntax like that with a 10 foot pole" + "it makes writing the parser easier" + maybe a bit of "it makes grepping easier" permalink fedilink source parent hideshow 2 child comments replies: [–] HiddenLayer555@lemmy.ml [S] 1 point 1 year ago* One thing that annoyed me about C# as a Java guy is that it really wants you to use camel case for function and property names, even private ones. I don't like it specifically because it's hard to differentiate between a function/property and a type. But C# has quite a few keywords and seem to like adding them more than Java. Maybe that's their way of ensuring keywords don't clash with stuff? permalink fedilink source parent
[–] piccolo@sh.itjust.works 4 points 1 year ago Ah I was misunderstanding the problem. And learned something new about C#, seems in order to avoid breaking existing code they introduce "contextual keywords" var being added later, it is a contextual. You can create a class 'var' and the compiler will prefer it. permalink fedilink source parent
[–] AnotherPenguin@programming.dev 3 points 1 year ago (1 child) At least in C#, you can define variables with keyword names like this: var @struct = "abc" I think in Kotlin you can do the same, and even include spaces with backticks like val abstract class = "abc" I'm not sure if other languages allow that, regardless it should be rarely used. permalink fedilink source parent hideshow 2 child comments replies: [–] pivot_root@lemmy.world 4 points 1 year ago (1 child) Swift also uses backticks and Rust has a dumb one in the form of r#thekeyword. Still much better than introducing a async as a new keyword in a minor version of a language and breaking a bunch of libraries. permalink fedilink source parent hideshow 2 child comments replies: [–] fayaz@lemmy.world 4 points 1 year ago Python? permalink fedilink source parent
[–] pivot_root@lemmy.world 4 points 1 year ago (1 child) Swift also uses backticks and Rust has a dumb one in the form of r#thekeyword. Still much better than introducing a async as a new keyword in a minor version of a language and breaking a bunch of libraries. permalink fedilink source parent hideshow 2 child comments replies: [–] fayaz@lemmy.world 4 points 1 year ago Python? permalink fedilink source parent
[–] HiddenLayer555@lemmy.ml [S] 1 point 1 year ago* (1 child) any new keyword could break backwards compatibility Wouldn't that happen anyway with variable and function names? Any type other than primitive/built in ones are usually camel case so lower case keywords are more likely to clash with single word variable and function names, unless you restrict the cases of those too or allow keyword overriding or something. permalink fedilink source parent hideshow 2 child comments replies: [–] sus@programming.dev 3 points 1 year ago* (1 child) Yeah, it's in my edit I realized the same thing. I'm thinking it doesn't actually really make sense and the real reason is more "the specific way C does it causes a lot of problems so we're not poking syntax like that with a 10 foot pole" + "it makes writing the parser easier" + maybe a bit of "it makes grepping easier" permalink fedilink source parent hideshow 2 child comments replies: [–] HiddenLayer555@lemmy.ml [S] 1 point 1 year ago* One thing that annoyed me about C# as a Java guy is that it really wants you to use camel case for function and property names, even private ones. I don't like it specifically because it's hard to differentiate between a function/property and a type. But C# has quite a few keywords and seem to like adding them more than Java. Maybe that's their way of ensuring keywords don't clash with stuff? permalink fedilink source parent
[–] sus@programming.dev 3 points 1 year ago* (1 child) Yeah, it's in my edit I realized the same thing. I'm thinking it doesn't actually really make sense and the real reason is more "the specific way C does it causes a lot of problems so we're not poking syntax like that with a 10 foot pole" + "it makes writing the parser easier" + maybe a bit of "it makes grepping easier" permalink fedilink source parent hideshow 2 child comments replies: [–] HiddenLayer555@lemmy.ml [S] 1 point 1 year ago* One thing that annoyed me about C# as a Java guy is that it really wants you to use camel case for function and property names, even private ones. I don't like it specifically because it's hard to differentiate between a function/property and a type. But C# has quite a few keywords and seem to like adding them more than Java. Maybe that's their way of ensuring keywords don't clash with stuff? permalink fedilink source parent
[–] HiddenLayer555@lemmy.ml [S] 1 point 1 year ago* One thing that annoyed me about C# as a Java guy is that it really wants you to use camel case for function and property names, even private ones. I don't like it specifically because it's hard to differentiate between a function/property and a type. But C# has quite a few keywords and seem to like adding them more than Java. Maybe that's their way of ensuring keywords don't clash with stuff? permalink fedilink source parent