1. 19
  1.  

  2. 35

    There’s really a problem with this blog post. I don’t know how it’s technically done but having to wait several seconds every time you display the tab is why almost nobody will read it.

    1. 20

      It is actually super-high-level web development. Kudos to @tedu for pulling it off.

      Pages are progressively enhanced using JavaScript if it is available. If it isn’t, users can still read the page. If JS is available, then UX is enhanced with a realtime loading indicator, much like the ten-pixel-bars top bars that are on many pages.

      After all, in this Third Age of JavaScript, we cannot simply trust the browser to render the page. We need to tell the user the progress of that.

      1. 14
        var delay = 100
        switch (progress) {
        	case 70:
        	case 73:
        	case 76:
        		delay = 250
        		progress += 3
        		break
        	case 79:
        		delay = 500
        		progress += 2
        		break
        	case 81:
        		progress += 14
        		break
        	default:
        		progress += 5
        		break
        }
        

        I have to give props for verisimilitude. And for teaching me where to find uBlock Origin’s “disable javascript on this page” function.

        1. 10

          I wouldn’t be surprised if @tedu spent a good twenty minutes fine tuning that for maximum annoyingness.

          1. 2

            You have more patience than me. It taught me where to find uBlock Origin’s domain-level blocklist.

          2. 9

            I’m sorta ok with progressive enhancement. What ground my gears was that it triggered every time the window (Chrome on Windows) regained focus. It made it really hard to find my place again in a page with lots of code.

            1. 19

              I mean, just so we’re all clear, it’s something between a joke and a protest statement, and what you’re complaining about is entirely the deliberate point: it’s a perfectly fine, instantly rendering webpage that’s being “progressively dehanced” by the presence of annoying JS.

              1. 4

                Wow… kids these days 😒

            2. 5

              Yeah, I love it. This “protest” is a nice compromise in comparison to sth like “Disable JS to enter the page”. It is annoying but still usable.

            3. 12

              The site loads almost instantaneously. Just disable JavaScript ;-)

              1. 11

                What’s really weird is all the markup appears to be there, and the loading is just for…giggles?

                1. 22

                  That sounds like something @tedu would do.

                2. 2

                  Well, @tedu also had a period with a self-signed certificate, the horror!

                  1. 2

                    When you have a self-signed certificate, you are expected to trust it on first use, and then the web browser remember it.

                    If the web browser remember the certificate of a website, noone, including a MitM possessing the key of a certificate trusted by your web browser, noone can tamper the connection anymore.

                    So you suddenly jump from a situation that looks suspicious security-wise, to one that can face the NSA kind of attack vector.

                    Of course, in the case of a MitM situation, your “accepted security exception” situation (self signed but trusted manually) would turn into a “green padlock” (certificate signed by the MitM) situation, and I doubt many will choose the “padlock with yellow cross” over the “padlock with green check mark”, even if icons barely have any accurate meaning on their own…

                    Simply wandering on an off-topic… Not actually meaning that Cloudflare should switch to self-signed right now… Oh, wait, Cloudflare are self-signing, they are their own trusted certificate authority…

                  2. 2

                    Just use links? ;)

                  3. 12

                    Come to the dark side, we have enums and match statements.

                    1. 1
                      switch (enum_variable) {
                      case enum_xx:
                      case enum_yy:
                      }
                      

                      would be another way of doing it. It requires using the syntax-heavy switch everywhere, maybe it was implicit that structs was used precisely used to avoid enum + switch. No idea…

                    2. 9

                      True … False … FileNotFound

                      Also, whenever I switch back to the tab this link is in it runs some sort of fancy “rendering” progress bar. Not sure what’s up with that.

                      I also am a bit disappointed it’s not a top 3 of the most valued structs in C. Oh well…

                      1. 1

                        Also, whenever I switch back to the tab this link is in it runs some sort of fancy “rendering” progress bar. Not sure what’s up with that.

                        It’s @tedu’s clever protest against JavaScript by way of progressive “dehancement.” Simply disable JavaScript, and the page functions beautifully.

                      2. 9

                        Love the artificial JS page slowdown (no sarcasm)

                        1. 5

                          Have you considered our savior, Optional<bool>?

                          1. 5

                            Almost everywhere I’ve seen it, the so-called tribool_t makes life very difficult.

                            I encountered some code that used a tribool_t when parsing bit-level compression. It would use true for success, false for failure, and FileNotFound (okay, something else, but I can’t remember what they actually used) to denote buffer underrun (e.g. needing more data to continue parsing). Conflating parsing with buffering was a huge mistake. (Think validating vs. parsing!) Every single point that could suffer an underrun had to store tons of temporary data to ensure that computation would resume at the right spot with the right state when you got more data.

                            I’ll underscore the fact that this wasn’t the type of thing where you parsed a length once and then pulled out a blob; think more along the lines of Huffman encoding where you could hit the end of the buffer at any point. Really gross.

                            1. 4

                              Maybe we need Setun for that.

                            2. 4

                              This doesn’t seem very C-like.

                              I realize C is old and has had many styles and that the idioms of C are weaker than most other languages, but still. This seems anti-idiom to me.

                              1. 3

                                Javascript protest shenanigans aside.

                                Why would you not just use an C enum for this instead?

                                1. 3

                                  enums are typed down to integer types. C compilers do not show any warning for different typedefs, and not even assignment for different types. Only comparison of different types, or alike.

                                  but for a struct, different struct names are considered as different types. The compiler will bug you out, this is what is desired: structs are a way to declare to the compiler that you actually mind very much how that variable is typed.

                                  1. 4

                                    You can use enum-typed variables (including return-values) in C, and the compiler warns you when you mix different enums. This is especially handy when you are working with FSMs. I understand the C-criticisms, but enum-mismatching is none of it if you are using enums right and not just store them in ints.

                                    1. 1

                                      I actually like enums and use them a lot ! :)

                                      I learned something today…

                                      1. 2

                                        I’m glad to hear that! I actually also found out about it a few years ago while working with FSMs and it helped me tremendously.

                                        1. 1

                                          One obvious use-case I see is returning an enum mylib_errno, and switching on that… or s/errno/state-machine-step/, or oneshot get_state() instead of zillion as big is_state_1(), is_state_2(), …

                                    2. 3

                                      There’s this obscure language I like that’s actually a backwards compatible superset of C, so you can compile your C code with it and use some of its new features as you see fit. One of them is called “enum classes” and it solves this problem perfectly.

                                      1. 3

                                        Is that the one you’re not allowed to talk about because it’s not C or Rust?

                                        I hear it’s okay for some stuff, not sure if anything critical has been written in it.

                                  2. 3

                                    While most people complain about C for “unsafety” and annoying manual memory stuff, this right here is why you should pick another language. If you want the compiler’s help just pick a compiler that knows how to help.

                                    1. 1

                                      I was dealing with a three-value scenario the other day, though it was at bit-level and for checking t/f matches with an ignore state, not error checking.