|
Athas posted:I'm surprised what in SML wouldn't make sense to an entirely new programmer. I wasn't a new programmer. It still didn't make sense. But then, I just don't get functional languages in general.
|
# ? Feb 8, 2021 18:46 |
|
|
# ? May 31, 2024 04:10 |
|
Athas posted:Nowadays they use F# for that course, primarily because it merged with a subsequent OOP course, and they wanted to stick to a single language. Also, SML is more or less dead. Whoa, I wasn’t aware that anywhere taught F#. Are comfortable sharing anything about the specific institution?
|
# ? Feb 8, 2021 20:36 |
|
If you're a mediocre programmer you use C#, if you're a failed programmer you use F#
|
# ? Feb 8, 2021 23:40 |
|
if you're a programmer who's frustrated about having nothing better to do you post broad statements about programming languages you dislike
|
# ? Feb 9, 2021 04:36 |
|
Programming only leads to bugs. Every language. Doesn't matter.
|
# ? Feb 9, 2021 04:44 |
|
Absurd Alhazred posted:Programming only leads to bugs. Every language. Doesn't matter. not only, but yes, inevitably
|
# ? Feb 9, 2021 04:47 |
|
I don't dislike C# or F# just stating some facts The best language would be A#
|
# ? Feb 9, 2021 05:17 |
|
You're all wrong, the best programming language is English, for responsibly writing good documentation.
|
# ? Feb 9, 2021 07:06 |
|
My PHP is self documenting
|
# ? Feb 9, 2021 07:12 |
|
Happy Thread posted:You're all wrong, the best programming language is English, for responsibly writing good documentation. Uh, Esperanto, like, right over here. Just saying.
|
# ? Feb 9, 2021 07:21 |
|
raminasi posted:Whoa, I wasn’t aware that anywhere taught F#. Are comfortable sharing anything about the specific institution? Several universities in Europe teach it to undergrads.
|
# ? Feb 9, 2021 10:20 |
|
raminasi posted:Whoa, I wasn’t aware that anywhere taught F#. Are comfortable sharing anything about the specific institution? University of Copenhagen, but I think there are many places that teach F#.
|
# ? Feb 9, 2021 15:50 |
|
Volmarias posted:Uh, Esperanto, like, right over here. Just saying. You misspelled
|
# ? Feb 9, 2021 19:41 |
|
Happy Thread posted:You're all wrong, the best programming language is English, for responsibly writing good documentation. Good what?
|
# ? Feb 9, 2021 20:20 |
|
Presto posted:Good what? You know, comments like “DO NOT REMOVE” and “temporary hack 12/8/2005” and “here be dragons”. Documentation.
|
# ? Feb 10, 2021 10:36 |
|
Soricidus posted:You know, comments like “DO NOT REMOVE” and “temporary hack 12/8/2005” and “here be dragons”. Documentation. // XXX - gently caress
|
# ? Feb 10, 2021 10:45 |
|
TIL the assumption that Sunday is the start of the week is literally hardcoded into the C# standard library. Thanks Microsoft
|
# ? Feb 10, 2021 12:45 |
|
Xarn posted:TIL the assumption that Sunday is the start of the week is literally hardcoded into the C# standard library. I haven't ever had to write any C# code that cares what the "start of the week is" but it seems to be based on cultures? which seems sensible? code:
quote:Sunday
|
# ? Feb 10, 2021 12:56 |
|
we considered ourselves an invariant culture
|
# ? Feb 10, 2021 12:59 |
|
Today I found a new one. A login web form sending the credentials with GET.
|
# ? Feb 10, 2021 13:06 |
|
Tei posted:Today I found a new one.
|
# ? Feb 10, 2021 13:26 |
|
Tei posted:Today I found a new one. It's testing friendly! Last place I worked at had multiple GET requests that updated DB rows, and even had comments along the lines of "we shouldn't be doing this but..."
|
# ? Feb 10, 2021 13:26 |
|
Hammerite posted:I haven't ever had to write any C# code that cares what the "start of the week is" but it seems to be based on cultures? which seems sensible? https://docs.microsoft.com/en-us/dotnet/api/system.dayofweek?view=net-5.0 (Also lol at listing the fields in alphabetical format)
|
# ? Feb 10, 2021 13:28 |
|
Volte posted:I was once hired to fix a site that kept getting "hacked" and that's what it was doing. It also didn't actually check the password so you could type anything and it would still log you in. The login form was a placeholder that was generated by Dreamweaver. https://twitter.com/SwiftOnSecurity/status/1359444877751246850
|
# ? Feb 10, 2021 13:30 |
|
They really should have made the day of week enum be assigned values like, 37-43, with the lowest number being Thursday, just to make it blindingly obvious that you should be using the localization facilities to turn it into user-relevant stuff instead of goofing around with the numbers directly.
|
# ? Feb 10, 2021 13:32 |
|
Not sure if C# enums support it, but the best solution would be to say "nope, not convertible to numbers, get lost".
|
# ? Feb 10, 2021 15:23 |
|
Xarn posted:Not sure if C# enums support it, but the best solution would be to say "nope, not convertible to numbers, get lost". The C# spec defines enums as backed by an integral type. It’s always going to be a number in one way or another. That’s how computers work. The UTF-8 string literal “Friday” interpreted as a big-endian unsigned integer is 77,457,208,402,297 - and if that was the spec I’m sure we’d hear people complaining that Microsoft should have used the natural, correct representation of “Vendredi” or “星期五”instead. The entire point of using an enum is that your code doesn’t and shouldn’t need to care how those numbers map to symbolic representations, once you’re past serialization and hardware boundaries. If you ever find yourself doing arithmetic operations on enum values in a high-level language, that’s a good sign to stop and think really hard about what you’re doing. And, if you ever find yourself directly operating on internal representations of date or time values, just stop. You’re lucky that you just got frustrated that the invariant culture didn’t match your assumptions instead of creating a subtle bug out of some weird calendar trivia question.
|
# ? Feb 10, 2021 16:42 |
|
Space Gopher posted:The C# spec defines enums as backed by an integral type. C++ lets you declare enum class which forces you to actively cast to an integer to do any arithmetic on it, which helps.
|
# ? Feb 10, 2021 16:43 |
|
Xarn posted:https://docs.microsoft.com/en-us/dotnet/api/system.dayofweek?view=net-5.0 That does not mean that the first day of the week is hardcoded to be Sunday. It just means that Sunday is hardcoded to be the first field in the enum. As Hammerite mentioned, the culture defines what the first day of the week is, not the enum. Given that they chose to use an enum, this is literally the only way they could have done it (other than starting the enum at a different day, of course). All .NET enums are always convertible to some integer type, so there's no way to prevent people from converting it to a number. You could opt to not explicitly set the backing value in the enum, but then .NET will just implicitly give the enum fields a value. Jabor's suggestion is really the only thing they could have done to make it harder for people to do the wrong thing, but even that wouldn't have prevented it. I guess they could've also opted to give the fields random values that change between every .NET release, but that would probably have caused MS more issues that it would ever solve. Since the addition of extension methods, they could've also added a culture sensitive extension method that returns the "number" of the day of the week, which would've been nice. Granted if someone needs that, it's quite easy to just implement.
|
# ? Feb 10, 2021 16:51 |
|
Absurd Alhazred posted:C++ lets you declare enum class which forces you to actively cast to an integer to do any arithmetic on it, which helps. It's the same in C#, you can't preform arithmetic on an enum directly, you'd have to cast it first. And, iirc, in order to do that, you need to know which integer type is the backing type, e.g. if you cast an enum to a short while it's backed by an int, you get a runtime exception.
|
# ? Feb 10, 2021 16:54 |
|
Should do it like hash seeds and randomize calendar enum values each launch. That'll learn ya.
|
# ? Feb 10, 2021 16:58 |
|
Does C# let you do order comparisons on enums without casting them? If so, that's a big part of the problem.
|
# ? Feb 10, 2021 17:00 |
|
pokeyman posted:Should do it like hash seeds and randomize calendar enum values each launch. That'll learn ya. Talk about backwards combatability!
|
# ? Feb 10, 2021 17:02 |
|
ultrafilter posted:Does C# let you do order comparisons on enums without casting them? If so, that's a big part of the problem. Yes, it does. As you'd expect it just compares the backing values.
|
# ? Feb 10, 2021 17:03 |
|
dwazegek posted:It's the same in C#, you can't preform arithmetic on an enum directly, you'd have to cast it first. And, iirc, in order to do that, you need to know which integer type is the backing type, e.g. if you cast an enum to a short while it's backed by an int, you get a runtime exception. Enums in C# directly support comparisons, bitwise operators, addition, and subtraction. https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/language-specification/enums#enum-values-and-operations There are places where this is useful, especially the bitwise operators, but if you find yourself doing it, it’s a real good time to stop and double-check that it’s the best approach.
|
# ? Feb 10, 2021 17:04 |
|
I am having difficulty imagining a situation where you would want to know the underlying numerical values of a "days of the week" enum, or be tempted to compare them numerically, add or subtract them, etc.
|
# ? Feb 10, 2021 17:28 |
|
If you want to know whether today is before Thursday, and you're not thinking clearly, you might be tempted to do that comparison with <.
|
# ? Feb 10, 2021 17:34 |
|
Tei posted:Today I found a new one. I have seen a payment processor that sends payment details (Cc and all) as an "image" request. This was last year.
|
# ? Feb 10, 2021 17:34 |
|
Tei posted:Today I found a new one. Private Internet Access (the VPN) used to do this
|
# ? Feb 10, 2021 17:41 |
|
|
# ? May 31, 2024 04:10 |
|
pokeyman posted:Should do it like hash seeds and randomize calendar enum values each launch. That'll learn ya. This is unironically the correct answer. The other alternative is to embrace being a high level language and disallow accessing the underlying bit representation. This even has the advantage of letting the compiler optimize it as needed. Space Gopher posted:Youre lucky that you just got frustrated that the invariant culture didnt match your assumptions instead of creating a subtle bug out of some weird calendar trivia question. No, I am currently disentangling piece of code that has 0 tests and is tangentially related in a sev 2 production incident. It starts by converting a MonthOfDay + start time as utc into a linear representation of time in a week (This is actually not the bug, and the code in question does not depend on which day starts the week, but I am still not amused by the current state)
|
# ? Feb 10, 2021 21:20 |