WTF Bites


  • Considered Harmful

    @tsaukpaetra Ew, anonymous types. Why not value tuples?


  • Notification Spam Recipient

    @pie_flavor said in WTF Bites:

    @tsaukpaetra Ew, anonymous types. Why not value tuples?

    Brevity.


  • Considered Harmful

    @tsaukpaetra Yes, new { x, y } is so much more concise than (x, y).


  • Notification Spam Recipient

    @pie_flavor said in WTF Bites:

    @tsaukpaetra Yes, new { x, y } is so much more concise than (x, y).

    I'm apparently :doing_it_wrong: that way...

    0_1513206811554_10649d22-8b18-49a1-9169-5eefc37a6e22-image.png

    I'll take my version instead.


  • Dupa

    @gąska said in WTF Bites:

    @tsaukpaetra I miss the times when we could argue about effects of GMO on health in a topic about PHP syntax and no one bat an eye. But that was two forum migrations ago, and I wasn't even registered.

    Yeah, you registering BROKE EVERYTHING!


  • Considered Harmful

    @tsaukpaetra ... wat?


  • And then the murders began.

    @pie_flavor said in WTF Bites:

    @tsaukpaetra Ew, anonymous types. Why not value tuples?

    Because then I'd have to get VS2017 on me. Ewww.


  • Considered Harmful

    @unperverted-vixen I don't touch VS2017. Project Rider all the way.


  • Banned

    @kt_ said in WTF Bites:

    @gąska said in WTF Bites:

    @tsaukpaetra I miss the times when we could argue about effects of GMO on health in a topic about PHP syntax and no one bat an eye. But that was two forum migrations ago, and I wasn't even registered.

    Yeah, you registering BROKE EVERYTHING!

    It's their own fault for not handling Unicode correctly!


  • Notification Spam Recipient

    @pie_flavor said in WTF Bites:

    @tsaukpaetra ... wat?

    That's exactly what I said when you talked about tuples in a linq query.

    I apparently don't know how to use them.


  • Considered Harmful

    @gąska I still can't actually search for posts by you; you're too far down on the list to scroll from simply a G, it won't match a name if it's not front-anchored, and I can't type that 'ą' on US-INTL.


  • Banned

    @pie_flavor said in WTF Bites:

    I can't type that 'ą' on US-INTL.

    Liar.


  • Considered Harmful

    @tsaukpaetra Just actually tested. E_NO_REPRO.

    https://i.imgur.com/R2ukjix.png


  • Considered Harmful

    @gąska How?


  • Notification Spam Recipient

    @pie_flavor said in WTF Bites:

    @tsaukpaetra Just actually tested. E_NO_REPRO.

    https://i.imgur.com/R2ukjix.png

    🤷🏻♂ You saw what happened when I did it.


  • Considered Harmful

    @tsaukpaetra I also saw what happened when I did it.
    Perhaps you also have local variables named x and y?
    Or maybe you aren't using C#7.1?


  • Notification Spam Recipient

    @pie_flavor said in WTF Bites:

    C#7.1

    NFC. Does this tell you anything?

    0_1513215227218_578cc84f-77e9-4357-8c97-d8025b4b8ca2-image.png



  • @tsaukpaetra said in WTF Bites:

    @pie_flavor said in WTF Bites:

    C#7.1

    NFC. Does this tell you anything?

    0_1513215227218_578cc84f-77e9-4357-8c97-d8025b4b8ca2-image.png

    IIRC, that means you're running C# v5. v7 is native to .NET framework 4.7.x

    But I'm sure that's not entirely accurate.


  • Considered Harmful

    @tsaukpaetra It does. C#7 only works on .NET 4.6.2 and onwards.


  • Banned

    @tsaukpaetra C# version setting is different from .Net version setting.


  • Notification Spam Recipient

    @pie_flavor said in WTF Bites:

    @tsaukpaetra It does. C#7 only works on .NET 4.6.2 and onwards.

    Sweet.

    Well, I'm not exactly hurting for the loss, so anonymous types they shall remain! :)


  • Notification Spam Recipient

    @gąska said in WTF Bites:

    @tsaukpaetra C# version setting is different from .Net version setting.

    Well, in that case C#7 isn't even available because we're on VS 2015.

    0_1513215675526_c0fe4532-3194-460d-96aa-6ce6088cb568-image.png


  • Considered Harmful

    @tsaukpaetra Lame-o. Other fun things you are missing include:

    • Inline out variables
    • Pattern matching variable assignment
    • Ref locals/returns
    • Local methods
    • Throw expressions
    • Async returning things other than Task
    • Async main
    • Implicitly typed default
    • Reference assemblies
    • Auto property initializers
    • using static
    • Null check operators
    • String interpolation
    • Exception filters
    • nameof
    • await in catch/finally
    • Extension methods in collection initializers
    • Collection initializers for Dictionary and similar

  • Notification Spam Recipient

    @pie_flavor said in WTF Bites:

    Auto property initializers

    I think I can do that already...

    @pie_flavor said in WTF Bites:

    using static

    VS did that (unexpectedly) when I referenced a different class. Still not sure why.

    @pie_flavor said in WTF Bites:

    Exception filters

    What I think that means is probably not what the devs made it to mean...

    @pie_flavor said in WTF Bites:

    Null check operators

    The question-mark things? I do that in one or two places too...

    @pie_flavor said in WTF Bites:

    Extension methods in collection initializers

    Sadly, I don't to much with extension methods...

    @pie_flavor said in WTF Bites:

    Collection initializers for Dictionary and similar

    Huh. Somehow I seem to have made do without so far...



  • @pie_flavor said in WTF Bites:

    await in catch/finally

    The whole system of async/await being shoehorned into the language sucks. Why can't they make everything a coroutine and have IO operations throw the thread back in the pool?

    Oh right, I'm describing Go again.


  • Considered Harmful

    @ben_lubar because coroutines don't actually run in parallel or take advantage of multiple processors? And I'm confused what you mean with IO and threads.



  • @pie_flavor said in WTF Bites:

    @ben_lubar because coroutines don't actually run in parallel or take advantage of multiple processors? And I'm confused what you mean with IO and threads.

    In Go, go foo() starts foo() in a new coroutine, and coroutines are automatically run on a number of threads based on the number of logical processors available to the program.

    IO operations like file.Write(bytes) happen asynchronously and let other coroutines run on the thread while they are being waited for.


  • Considered Harmful

    @ben_lubar Well, I like the good old verbose way of doing things. If you put the pieces together yourself, you can disassemble them and make something new. And are you telling me that .NET async IO operations don't do that thread thing?



  • @pie_flavor said in WTF Bites:

    @ben_lubar Well, I like the good old verbose way of doing things. If you put the pieces together yourself, you can disassemble them and make something new. And are you telling me that .NET async IO operations don't do that thread thing?

    I'm telling you that the language and standard library should just do that without forcing you to write await before every function call.


  • Notification Spam Recipient

    @pie_flavor said in WTF Bites:

    @ben_lubar Well, I like the good old verbose way of doing things. If you put the pieces together yourself, you can disassemble them and make something new. And are you telling me that .NET async IO operations don't do that thread thing?

    No, they do their best to not actually thread if memory serves. There was an article referenced somewhere about that. Lemme search...

    This isn't the one I'm thinking of, resuming...

    No, that's not right either.... Ok, one more go...

    Ok I give up, I can't find the thing. Here's to hoping what was found in the stead is useful anyway.


  • 🚽 Regular

    @pie_flavor said in WTF Bites:

    Rider all the way

    :giggity:


  • Discourse touched me in a no-no place

    @pie_flavor said in WTF Bites:

    If you put the pieces together yourself, you can disassemble them and make something new.

    If people have to put all the pieces together themselves, they actually say “fuck it, this is hard” and do something crappy and surface-easy instead.



  • @ben_lubar said in WTF Bites:

    In Go, go foo() starts foo() in a new coroutine

    No. It starts foo in a new thread. The fact that it then maps the user-land threads to a smaller number of kernel-land threads is irrelevant. There are many programming environments that do or did that (cue Java “green” threads). If the underlying operating system is sensible, it is actually a pretty bad idea.

    A coroutine, on the other hand, does absolutely nothing with threads. A coroutine is a function that can suspend itself in multiple places, returning (yielding) a value from each of them, and be continued, possibly with additional parameter. It is a simple source-level transformation that converts a function to an object with appropriate method. It is called completely synchronously.

    Now this can be used in many ways, but there are two common cases:

    • Iterators/generators. These simply return next element of a collection in each step, except they can generate the elements on the fly without ever having to store the complete list in memory.
    • The async/await: Async function is one that instead of returning a value takes a callback that it will pass the result to when it is ready. And await for it packs the rest of the current function into a callback and passes it in. It only works with a reactor (event loop) and does not use threads.

    Maybe you were confused by the similarity of the neologism goroutine that Go uses to call it's threads, but they are still threads, not coroutines as C#/Python/C++ etc. understand them.


  • area_can

    @bulb go uses lightweight threads, right? Or am i thinking of erlang



  • @bb36e Yes, “lightweight threads” is one of the names for it. Windows calls them “fibres”, Java called them “green threads” before they realized it is a bad idea.

    Also, only the Google Go compiler does. The GNU Go compiler uses normal threads. It simply makes much more sense that way on most operating systems.

    Anyway. The point is that a thread, whether lightweight or not, is a different animal from coroutine.


  • Discourse touched me in a no-no place

    @bulb said in WTF Bites:

    A coroutine, on the other hand, does absolutely nothing with threads.

    That's not entirely true. If the coroutine doesn't just make a resumption context (which is the underlying reality of what you were talking about when you said that a function is converted into an object) but also associates a stack with that resumption context, then the mechanism is effectively enough that you can implement green threads on top using a little extra work. The key is whether the coroutine can only yield from its top-level function or whether it can also yield from the functions that it calls without special extra syntax (i.e., no screwing around with chains of async/awaits).

    It all boils down to whether there's extra stacks about. ;)



  • @bb36e said in WTF Bites:

    Erlang

    Erlang actually only appears to have processes. It probably schedules them on kernel threads to reduce copying, but it their effects are isolated—it is purely functional, so there are no side-effects—and the runtime can transparently schedule them across cluster nodes.



  • @dkf said in WTF Bites:

    but also associates a stack with that resumption context

    No, it does not. In the languages where I've seen it it is a separate transformation for each frame.

    @dkf said in WTF Bites:

    you can implement green threads on top using a little extra work

    You don't want to do that on top of the C#/Python/C++/JavaScript/… version. The point of threads normally is that you can take any function and run it in a thread, but only explicitly marked functions become coroutines.

    Of course if you use continuation-passing in the underlying machine, effectively all functions become coroutines and that is a good basis for green threads. But the only language I know of that actually does that is scheme with it's call-with-current-continuation. And possibly Perl6. But none of the usual languages implementing async/await and yield has that.



  • @tsaukpaetra said in WTF Bites:

    What I think that means is probably not what the devs made it to mean...

    You can now add a boolean expression to your catch statement (with the keyword when). That catch is only eligible if both the type of the exception matches and the when expression is true. From a program logic point of view, this is no different from including if(!<when expression>) throw; in the catch, but from a debugger's point of view they're worlds better: since the exception isn't being caught and rethrown, it's still got all the context from the original throw that would have been thrown away.

    @ben_lubar said in WTF Bites:

    I'm telling you that the language and standard library should just do that without forcing you to write await before every function call.

    Backwards compatibility. There's a huge amount of code that's been written since 2001 that assumes it'll always be called on the same thread (WinForms, COM STA come to mind) and that I/O doesn't create a reentrancy risk.

    @bulb said in WTF Bites:

    The async/await: Async function is one that instead of returning a value takes a callback that it will pass the result to when it is ready. And await for it packs the rest of the current function into a callback and passes it in. It only works with a reactor (event loop) and does not use threads.

    It does not necessarily use threads. In C#, if the results of an awaited-for function become available while the original thread is busy, and the continuation doesn't immediately rely on any thread-local information, then it gets resumed on another thread rather than getting stuck waiting. For UWP specifically, you're encouraged to use async/await because of this threading behavior, since Microsoft didn't trust developers to handle moving high-latency operations to a background thread and then deal with manually passing continuations to the UI thread for status updates.



  • @djls45 said in WTF Bites:

    I've run into this several times now, so I'm thinking it might not be a fluke that it keeps occurring.

    If I have a Windows update waiting to restart the computer, but I keep delaying it, eventually the audio devices attached to the system quit working and videos on webpages won't play either.
    I have to restart the computer in order to get those functionalities back.

    This is a Win7 Ent 64-bit laptop with a Logitech headset and a dock.

    This is happening again, sorta. I have an update that I've put off a couple times now, and Outlook and IE have quit using the network connection. (I just had to reload the page(s) in IE for it to work again.) I can still access remote folders with Windows Explorer and other browsers use the internet connection just fine (I'm writing this in Chrome right now, as usual). It's just these Microsoft programs that have quit working so far. I can still watch online videos, so I'm not yet to that point yet, and headphones still work. I'm sure after I apply the update(s) they'll work correctly again.



  • TDWTF front page articles (which do exist) have stopped working over https. Using the http version works, but the https one that comes in on the rss feed immediately resets connection and doesn't load.


  • Banned

    Someone fucked up my college's Wi-Fi configuration and when I try to access HTTPS websites (which nowadays consists of majority of the whole internet, including Google), instead of redirecting to login page, I get SSL certificate error and Chrome refuses to visit desired website and there's no "connect anyway" button. Thanks God there's this Polish Reddit-wannabe website which didn't see any update since 2009, because it all works over HTTP and after logging in I can access HTTPS just fine.

    Also, the "+" button covers lower right corner of post composer on mobile.


  • kills Dumbledore

    @gąska said in WTF Bites:

    Chrome refuses to visit desired website and there's no "connect anyway" button

    Click advanced

    0_1513267458793_91a598eb-b84c-4c1a-b07a-37e8eae067d4-image.png

    Click proceed to site

    0_1513267525554_8433873b-1686-44d1-9c62-3684443cb1af-image.png


  • Banned

    @jaloopa I didn't see it. Maybe I'm blind. Maybe mobile is different. Maybe they removed it in some update I have and you don't.


  • BINNED

    PHP.

    That is all.







    Ok, ok, I'll elaborate...

    php > $array1 = [0 => 'a', 10 => 'b', 20 => 'c'];
    php > $array2 = [5 => 'd', 15 => 'e', 25 => 'f'];
    php > print_r(array_merge($array1, $array2));
    Array
    (
        [0] => a
        [1] => b
        [2] => c
        [3] => d
        [4] => e
        [5] => f
    )
    php > print_r($array1 + $array2);
    Array
    (
        [0] => a
        [10] => b
        [20] => c
        [5] => d
        [15] => e
        [25] => f
    )
    php > $array2 = ['5' => 'd', '15' => 'e', '25' => 'f'];
    php > print_r(array_merge($array1, $array2));
    Array
    (
        [0] => a
        [1] => b
        [2] => c
        [3] => d
        [4] => e
        [5] => f
    )
    php > print_r($array1 + $array2);
    Array
    (
        [0] => a
        [10] => b
        [20] => c
        [5] => d
        [15] => e
        [25] => f
    )
    

    So, array_merge will always fuck up your keys, regardless of the type of the key. The + (union) operator will preserve the keys.

    Also, the docs either lie or are incomplete:

    Merges the elements of one or more arrays together so that the values of one are appended to the end of the previous one. It returns the resulting array.

    If the input arrays have the same string keys, then the later value for that key will overwrite the previous one. If, however, the arrays contain numeric keys, the later value will not overwrite the original value, but will be appended.

    Values in the input array with numeric keys will be renumbered with incrementing keys starting from zero in the result array.

    Yeah, string keys as well, it seems. You fucks.

    And if you're wondering what the fuck the difference is:

    The + operator returns the right-hand array appended to the left-hand array; for keys that exist in both arrays, the elements from the left-hand array will be used, and the matching elements from the right-hand array will be ignored.

    To summarize:

    1. array_merge prefers the later arrays, and overwrites the previous ones in case of string keys, but will keep all the values in case of numeric keys
    2. + operator prefers the left operand and will ignore the duplicate keys in the right operand
    3. Why in the holy fuck is the + operator, which will ALWAYS remove some values if duplicate keys exist, called the UNION operator if it IGNORES THE FUCKING VALUES?
    4. Why in the holy fuck is there no way of controlling what array_merge does, where I would accept Error out if there are duplicates as a valid option?
    5. Who the fuck designed this inconsistent shit?
    6. WHARRGARBL!

    Extra bonus addition:

    Prototype for array_key_exists:

    bool array_key_exists ( mixed $key , array $array )
    

    Prototype for property_exists:

    bool property_exists ( mixed $class , string $property )
    

    Yes, thank you for making those two with a different argument order. This is not confusing at all when working with objects returned by json_decode, which are a nested structure of objects and arrays, depending on what they were in the original JSON. Thank holy fuck for autocomplete.

    0_1513267903303_98ce2fcd-4b20-4756-b963-e367b735f76d-image.png



  • @jaloopa That override doesn't exist if the site uses strict transport security (all of Google, many many other places) or public key pinning (also all of Google, also a few other places).



  • @jaloopa said in WTF Bites:

    @gąska said in WTF Bites:

    Chrome refuses to visit desired website and there's no "connect anyway" button

    Click advanced

    0_1513267458793_91a598eb-b84c-4c1a-b07a-37e8eae067d4-image.png

    Click proceed to site

    0_1513267525554_8433873b-1686-44d1-9c62-3684443cb1af-image.png

    Chrome will not show the "I know what I'm doing, so connect me already" option if the security protocol is "outdated" and the cert isn't validated. But it only shows the cert validation issue.



  • @twelvebaud said in WTF Bites:

    @jaloopa That override doesn't exist if the site uses strict transport security (all of Google, many many other places) or public key pinning (also all of Google, also a few other places).

    The override also doesn't exist when the error is that the connection was reset by the server, which is fixed now, by the way.



  • @gąska said in WTF Bites:

    Someone fucked up my college's Wi-Fi configuration and when I try to access HTTPS websites (which nowadays consists of majority of the whole internet, including Google), instead of redirecting to login page, I get SSL certificate error and Chrome refuses to visit desired website and there's no "connect anyway" button. Thanks God there's this Polish Reddit-wannabe website which didn't see any update since 2009, because it all works over HTTP and after logging in I can access HTTPS just fine.

    Also, the "+" button covers lower right corner of post composer on mobile.

    Every network with a login page that I have ever tried to use did that. It makes complete sense, really: they're trying to hijack an HTTPS connection in order to send you someplace else. And your device doesn't have a root certificate installed to tell it to trust them. For all it knows, they're doing a MITM attack.

    The solution is always to go to an HTTP page, get redirected to their login page, do the login, and then your device is registered with the network and it stops trying to block/interrupt your connections and send you to the login page instead.



  • @anotherusername said in WTF Bites:

    The solution is always to go to an HTTP page

    I like http://gstatic.com/generate_204 for this.


Log in to reply