|
i thought it literally won’t compile with unused variables? which is actually infuriating at times
|
# ? Jun 29, 2022 13:56 |
|
|
# ? Apr 26, 2024 22:35 |
|
my homie dhall posted:i thought it literally won’t compile with unused variables? which is actually infuriating at times it won’t but you can use underscores in assignment to indicate that the variable is expected to be unused also if you hoist a variable for conditional assignment or have a named return then assignment to those vars is considered use even if you don’t use them later in the code
|
# ? Jun 29, 2022 14:03 |
|
Kazinsal posted:this all continues to validate my belief that go is just c/c++ for people who are too stupid to write c/c++ Nobody is smart enough to write C++ tho
|
# ? Jun 29, 2022 14:08 |
|
also C because compiler writers treat the C language spec the same way that Exxon-Mobil accountants treat the tax code
|
# ? Jun 29, 2022 14:43 |
|
Blinkz0rz posted:it won’t but you can use underscores in assignment to indicate that the variable is expected to be unused
|
# ? Jun 29, 2022 15:36 |
|
Sagacity posted:it must feel really productive when debugging that when you've commented out a block of code you also have to hunt down any variables that are now unused i'm confused, you're arguing against further deletion of go code?
|
# ? Jun 29, 2022 15:59 |
|
pokeyman posted:i'm confused, you're arguing against further deletion of go code?
|
# ? Jun 29, 2022 17:07 |
|
Kazinsal posted:this all continues to validate my belief that go is just c/c++ for people who are too stupid to write c/c++ it’s not a belief. It’s literally why Google created Go.
|
# ? Jun 29, 2022 17:27 |
|
pokeyman posted:i'm confused, you're arguing against further deletion of go code?
|
# ? Jun 29, 2022 17:28 |
|
I've just started working on a C# codebase that has nullability checking turned on, and it seems a bit...poo poo. Like, first off, it seems that 'null' for reference types vs 'null' for value types is handled completely differently by the language, which makes it impossible to return 'null' from a method generic in T, even if the T in the return type is optional, unless you constrain T to be either a struct or a class, which is obviously a bit of a dealbreaker if you want the class to be generic over any T. Otherwise you have to return 'default', which doesn't work if you want to tell the difference between, say, null and zero. Also it seems like the '!' operator on nullable types doesn't mean 'unwrap and throw if null' like in many other languages, but just means 'ignore the warning', so dumb poo poo like this not only compiles, but *doesnt crash*: code:
|
# ? Jul 1, 2022 13:47 |
|
I haven't used nullability checking in c# yet but based on https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/builtin-types/nullable-value-types it seems like you're just supposed to cast it to the nonnullable type to get the desired behavior (equivalent to "unwrapping" it and panicking if it's null in another language)? The syntax/behavior seems a bit weird compared to just disallowing nullability and adding straight up optional types to the language with syntactic sugar but I think that's a side effect of how they have tried to ensure compatibility unfortunately.
|
# ? Jul 1, 2022 14:12 |
|
Anyone seen places do maybe 2-4 weeks of pair programming either all day or part day to help onboard entry level people and get them up to speed on older/larger code bases? How'd it go? We've got docs...kinda...but our dev team has always been 1-3 people so theres been lots of changes from the original baseline docs that might not be documented well.
|
# ? Jul 1, 2022 14:20 |
|
CarForumPoster posted:Anyone seen places do maybe 2-4 weeks of pair programming either all day or part day to help onboard entry level people and get them up to speed on older/larger code bases? How'd it go? We've got docs...kinda...but our dev team has always been 1-3 people so theres been lots of changes from the original baseline docs that might not be documented well. 4 weeks full time pairing sounds like a lot. Typically I have an onboarding doc/tutorial/exercises i give people. If they run into issues I ask them to bring things up. I plan for daily check-ins, and dial it up if there's some issue. Usually takes people about a week.
|
# ? Jul 1, 2022 14:34 |
|
toiletbrush posted:Is there some shorthand for 'I expect this value to be non-null so pls unwrap it but throw an exception if it isnt'? the c# non-nullability hack is a compile-time thing so runtime checks are not included Enterprise® Best® Practices® would require you to throw a useful exception every time: code:
code:
|
# ? Jul 1, 2022 14:35 |
|
NihilCredo posted:the c# non-nullability hack is a compile-time thing so runtime checks are not included code:
|
# ? Jul 1, 2022 14:43 |
|
toiletbrush posted:I've just started working on a C# codebase that has nullability checking turned on, and it seems a bit...poo poo. Like, first off, it seems that 'null' for reference types vs 'null' for value types is handled completely differently by the language, which makes it impossible to return 'null' from a method generic in T, even if the T in the return type is optional, unless you constrain T to be either a struct or a class, which is obviously a bit of a dealbreaker if you want the class to be generic over any T. Otherwise you have to return 'default', which doesn't work if you want to tell the difference between, say, null and zero. ! is a hack to work around the compiler not being able to understand certain null checks. Like imagine you have IEnumerable<Butt?> butts. If you try to iterate the content you're gonna have to null check everything, so a simple way to avoid nulls would be var nonNullButts = butts.Where(_=>_!=null). However, the compiler cant really understand that and will treat nonNullButts as still being IENumerable<Butt?>. As a workaround you can change it to butts.Where(_=>_!=null).Select(_=>_!) which will force the compiler to treat the output as IEnumerable<Butt>. As far as im aware Nullable is enforced entirely at the compiler level for backwards compat. So string? optional and string notOptional in your example are both nullable strings under the hood and its the compiler slapping your hand when you try to mix the syntax. In general though i've been loving nullable being turned on.
|
# ? Jul 1, 2022 14:44 |
|
Shaggar posted:! is a hack to work around the compiler not being able to understand certain null checks. Like imagine you have IEnumerable<Butt?> butts. If you try to iterate the content you're gonna have to null check everything, so a simple way to avoid nulls would be var nonNullButts = butts.Where(_=>_!=null). However, the compiler cant really understand that and will treat nonNullButts as still being IENumerable<Butt?>. As a workaround you can change it to butts.Where(_=>_!=null).Select(_=>_!) which will force the compiler to treat the output as IEnumerable<Butt>. string is a reference type anyway, so string? as a type sounds weird to me
|
# ? Jul 1, 2022 14:52 |
|
Shaggar posted:. foreverialy nullable, fully typesafe, turned on and loving it
|
# ? Jul 1, 2022 16:53 |
|
leper khan posted:string is a reference type anyway, so string? as a type sounds weird to me Nullable types suck so even if the c# nullability checking is uglier than option types in other languages and there's some weirdness based on how it had to be implemented, it still seems like a huge improvement.
|
# ? Jul 1, 2022 16:54 |
|
Powerful Two-Hander posted:foreverialy nullable, fully typesafe, turned on and loving it wrapped up like a monad, fully wrapped in permanent data constructor
|
# ? Jul 1, 2022 17:10 |
|
type check me daddy
|
# ? Jul 1, 2022 17:20 |
|
mystes posted:Huh? Isn't the whole point of the nullable stuff so that you can treat reference types as non-nullable so if you want to make it nullable you have to use stuff like "string?"? Are you just saying that you don't like nullability checking? String can be null already. It is a reference type. Int is a value type. It can not be null. A nullable int is a value typed wrapper around an int, allowing semantically for a null valued int. Not that the meaning of that is immediately clear (probably set vs unset)
|
# ? Jul 1, 2022 17:27 |
|
leper khan posted:String can be null already. It is a reference type.
|
# ? Jul 1, 2022 17:30 |
|
mystes posted:Isn't the entire point of the nullability checking stuff in c# is that you can change the behavior so the compile won't allow reference types to be assigned null unless you explicitly mark it as nullable? The nullable syntax stuff (eg int?) is to allow value types to be null. Not to prevent reference types from being null.
|
# ? Jul 1, 2022 17:36 |
|
leper khan posted:The nullable syntax stuff (eg int?) is to allow value types to be null.
|
# ? Jul 1, 2022 17:44 |
|
Now go take a screenshot of the first three paragraphs of that page.
|
# ? Jul 1, 2022 17:48 |
|
kotlin is pretty good about nullable references I never got into C# (or dot net for that matter) but avoiding Null Pointer Exceptions at compile time seems to be something that should have been implemented in every language higher than C Like, it should have been a feature in the 90s.
|
# ? Jul 1, 2022 17:51 |
|
pseudorandom name posted:Now go take a screenshot of the first three paragraphs of that page. I have no idea which part you're referring to? And I don't see anything implying the part of nullability checking is "Not to prevent reference types from being null" like leper khan was saying which I understand to be literally the whole point of nullability checking? I guess either I must be misunderstanding the whole point of adding nullability checking to c# or I have no idea why I'm even bothering posting in yospos anymore.
|
# ? Jul 1, 2022 17:54 |
|
sb hermit posted:kotlin is pretty good about nullable references compilers were very primitive in the 90s and most efforts back then was about generating code that didn't completely suck "compilers generate better assembly than you can write by hand" was not always true
|
# ? Jul 1, 2022 17:56 |
|
i think they're just unaware of the c# 8 changes because explicitly nullable reference types were just sort of nonsense in c# for a very long time due to the lack of non-nullable reference types
|
# ? Jul 1, 2022 17:57 |
|
mystes posted:
this is a feature added in C# 8.0
|
# ? Jul 1, 2022 17:58 |
|
leper khan posted:The nullable syntax stuff (eg int?) is to allow value types to be null. The "Nullable reference types" feature does the opposite, it's a dumb name. It adds static analysis to check that reference types are not null, unless marked as nullable (e.g. String?).
|
# ? Jul 1, 2022 17:59 |
|
pseudorandom name posted:this is a feature added in C# 8.0 So wow you really got me by making me scroll up the page to the c# 8.0 part which I guess I stealthily omitted from my post in the middle of this discussion which was explicitly about nullability checking in recent versions of c# in the first place. Great job, terrible programming thread. mystes fucked around with this message at 18:11 on Jul 1, 2022 |
# ? Jul 1, 2022 18:07 |
|
throwin a programming fit on a saturday morning
|
# ? Jul 1, 2022 18:52 |
|
mystes posted:Seriously what are you even trying to say here? The "string?" type was specifically brought up in this conversation in the context of enabling nullability checking and then leper khan said that it made no sense because strings are already reference types and then proceeded to argue with me when I tried to explain how nullability checking works. I'm in management now. Giving slightly outdated programming guidance is praxis
|
# ? Jul 1, 2022 18:56 |
|
Achmed Jones posted:throwin a programming fit on a saturday morning I wish. Friday morning here.
|
# ? Jul 1, 2022 19:00 |
|
Achmed Jones posted:throwin a programming fit on a saturday morning
|
# ? Jul 1, 2022 19:00 |
|
lol imagine getting angry about programming languages.
|
# ? Jul 1, 2022 19:04 |
|
I don't have to imagine, I use them all the time
|
# ? Jul 1, 2022 19:09 |
|
|
# ? Apr 26, 2024 22:35 |
|
FlapYoJacks posted:lol imagine getting angry about programming languages. Imagine not getting angry about programming languages
|
# ? Jul 1, 2022 19:09 |