Threads for StuntProgrammer

  1. 2

    Why is this written in ancient JavaScript in 2022? It just makes everything unclear for no benefit. It uses close to 30 lines to define default arguments, which are now just part of the JS spec. IE11 is not supported by Microsoft. Either you’re writing for modern browsers or for browsers without JS, but there’s no benefit in writing for browser with ancient JS.

    1. 2

      Thank you for your feedback. I had in my head that optional function parameters were part of ES6, which has only limited support on the oldest browsers I target. At your suggestion, I learned that this limited support /does/ include optional function parameters and I’ve updated my article accordingly.

      As a side note, I found the tone of your remarks to be somewhat confrontational. You may find that your future critiques are more widely received in the generous spirit they are given if you share them in a collaborative tone.

      1. 1

        Sorry about the tone. I found the code bugs me because it’s quite difficult to read. I wanted to go back and post a comment rewriting it to be clearer but haven’t had the time yet. The basic idea is you want to separate fetching from retrying. Make a generic retryer that can retry anything and then pass in the fetcher as a specific case.

        What browsers are you targeting by the way? And why? In my experience if you don’t actually test in older browsers, there’s no point in trying to write to them because you’ll get something wrong accidentally and have a showstopping bug but not actually know about it. To have working code, it has to be tested in the relevant environment, so the best strategy for someone without QA team is to target both modern JS and no JS, but not old JS, which is impractical to test.

        1. 2

          Most developers I’ve met have their own preference on when and how to factor out apparently-generic functionality. My personal preference is to not factor something out until I have at least two concrete uses for it. I think I do a better job of weighing the trade-offs and finding the right place to “draw the line” with a couple of real-world examples to work from. I also know myself well enough to know that I enjoy a good yak-shave, so I try not to tempt myself with developing a “generic method for transferring condiments” when “passing the salt” will suffice.

          For lofi.limo I test against Firefox 52 and Chrome 49 on Windows XP, current Firefox, Chrome, and IE on Windows 10, current Safari and Chrome on macOS, and current Safari on iOS. I haven’t found this testing to be burdensome. I support XP because it’s a nice thing to do and it gives me pleasure to do it. I’ve heard from some of my listeners that they like to listen on older, disused hardware in their workshop, sewing room, or similar environment.

          1. 1

            Gotcha, makes sense. Glad to hear you’re actually testing it and not relying on intuition. Windows XP is 20 years old. That’s retrocomputing by any definition. Retrocomputing is cool! But your blog post would be more clear if you prefaced it by saying that that’s your audience, not general web devs. I wouldn’t accept a PR that looked like your original code because it’s very hard to read. The browsers added promises and fetch and ES6 etc. because the old code was harder to read and write, and the new code is designed to be easier. But I’m not a retrocomputing developer, so it’s just a different standard, like how demoscene is different or games dev is different. For retrocomputing it makes sense.

    1. 6

      This kind of tag-soup rubs me the wrong way. The only reason it’s valid is to grandfather the messed-up HTML that got written in the early days when people learned HTML on the street, and browsers would try to parse almost anything. This is literally the way I learned to write HTML in 1994 before I learned about the actual DOM structure.

      The result is sort of like a hypothetical lenient C compiler that will let you leave out close braces and parens and just do it’s best to guess what you meant. It saves a few keystrokes but it becomes very easy to make accidental mistakes that are hard to catch.

      And HTML like this in the wild is why scraping is so hard to do — you can’t just use an ordinary parser unless the page is XHTML; instead you need something that knows about all the shortcuts and will insert the necessary tags to make it valid. (libTidy is the usual tool for this.)

      1. 2

        I’ve heard this rationale for tag omission before, but I’m not sure it’s quite right. I was just a punk kid at the time all this went down, so maybe someone who was on the mailing lists at the time will stop in to correct me… but…

        I think it was always deliberate and meant to make documents easy to author. I found in the HTML+ spec from 1993 that the end tag for “p” elements was already optional at that time. I didn’t find mention in TBL’s “About HTML” of end-tags for “p” elements at all, optional or otherwise!

        https://www.w3.org/MarkUp/HTMLPlus/htmlplus_11.html http://info.cern.ch/hypertext/WWW/MarkUp/Tags.html

        1. 3

          I think it was always deliberate and meant to make documents easy to author.

          It’s worth noting that there weren’t any authoring tools early on. Of course they’re going to make it easy to write by hand, because everyone is doing that.

          I have to wonder if perhaps the W3C push for XHTML was about 10 years too soon. In the early 00s, there was a lot of tooling for writing HTML. But the lightweight markup languages hadn’t quite taken off yet. I think markdown was created in 2005, and I first heard about it in like 2007 or 2008. You still had a sizeable contingent of folk writing HTML by hand at the time.

        2. 2

          Luckily this isn’t tag soup that needs a quirks mode tidying, but a valid structure with well-specified parsing rules. If you implement the html5 parsing algorithm as per spec, it will handle this fine. If you don’t, your parser is broken

        1. 7

          I remember learning how lean HTML in the diveintohtml5 book. One thing missing from this article is the famous <meta charset="utf8"> which even works on IE5.

          1. 3

            That’s a good point! It’s important to specify UTF-8 if that’s what you’re using (and it’s usually what I use). It’s also compliant to indicate it with a byte-order-mark at the beginning of the document or with an appropriate content-type header.

            The character encoding need not be specified if you’re happy with the default, but I expect nowadays most authors will want to use UTF-8.

            1. 2

              Why do you need a byte-order mark with UTF-8?

              1. 3

                “Byte-order mark” is a legacy name, dating back to the days when there were only two possible Unicode encodings (UTF-16BE and UTF16-LE). However, it’s a codepoint that’s represented differently in every standard Unicode encoding, does not represent a valid Unicode character, and its various Unicode encodings extremely unlikely to appear in any non-Unicode encoding. That means it’s very useful as an encoding declaration, even for encodings like UTF-8 with only one legal byte ordering.

          1. 10

            If more people understood HTML, they would stop using Markdown incorrectly—such as using blockquotes for callouts and admonitions instead of for quoting a body of work, or figures + figcaptions, definiton lists instead of unordered lists with heading elements. Ironic that developers tease people for using WYSIWYG editors improperly—like <b> for headings and excessive <br> tags and &nbsp;—and then misuse their lightweight markup syntaxes.

            1. 23

              If I could give young developers one piece of advice, it would be this:

              Reading the manual or the standard or the RFC or whatever the definitive documentation is for the tools that you use is a super-power.

              1. 4

                As soon as markdown provides me with callout and admonition formats, (or even a reasonable standard way of defining them myself) I’ll be happy to fix that.

                1. 3

                  Pretty sure markdown is a superset of HTML, but I don’t see how HTML would solve that problem? Is there an <admonition> tag?

                  1. 2

                    We had something similar way back, but sadly the “blink” element has since been deprecated…

                    1. 2

                      Ah, fond memories of <marquee> :’D

                    2. 2

                      Even if it did, escaping to HTML isn’t my idea of a reasonable way – if I wanted HTML I’d be using it, not markdown. It’s a usable kludge/escape hatch when you need it, but html in markdown isn’t a solution.

                      1. 6

                        The original Markdown allowed HTML because the point of the original Markdown was to eliminate the tedious bits of HTML when authoring blog posts, not to replace HTML entirely.

                        1. 3

                          I know why it’s there… my point was that if the goal is to eliminate said tedium, and there’s a markdown format code that generates the output I want without it, why would I go back to html for some purported semantic purity.

                          Aside from that, the current reality of markdown has strayed considerably from that original point, and now many uses of it no longer support html at all or significantly restrict it.

                          1. 1

                            To each their own I guess. I have my own markup language I use for blogging [1] and it has support for generating tables (some example tables). But it doesn’t support all the semantics of HTML tables, and when I need those (like this example) the ability to drop down into actual HTML is nice. Did I go back to HTML for some purported semantic purity? I don’t think so, but you may think differently. And would I go to the trouble to try to support all of HTML’s table semantics in my markup language? No way. For me, it’s rare enough that I stray from the general table format (of the first example) that supporting other formats would be a waste of time—the occasional “drop down to HTML markup” doesn’t bother me that much.

                            [1] I don’t store the post entries in this format, but in the final HTML output, mainly because I want the ability to change the markup language if some aspect annoys me. I’ve already made multiple changes. I’m also not forcing others to use this format, since it’s really geared towards my own usage.

                            1. 2

                              Did I go back to HTML for some purported semantic purity? I don’t think so, but you may think differently

                              Sorry, didn’t mean to imply that’s what you were doing… rather just referring to my original point upthread: I see no issue at all using markdown blockquotes when they give me the formatting I want even though an html aside might be “more correct” but at the expense of having to write all the html and css to achieve the same thing.

                              1. 1

                                I love that you support <abbr> where most other tools don’t

                                1. 2

                                  Thank you. I still don’t know how to handle the following case [1]: “While the IRA may take actions against US interests that would effect Alice’s (a member of the IRA) IRA, can an automated process work out which expansion of IRA [2] should be used for each instance?” But so far, that’s been an extreme outlier case and rarely comes up.

                                  [1] From http://boston.conman.org/2003/11/19.2

                                  [2] For the record: Irish Republican Army, International Reading Association, Individual Retirement Account.

                      2. 1

                        Psst you can use use AsciiDoc most places you’d use Markdown and get that ability plus extra benefits.

                        1. 2

                          Yeah, AsciiDoc and ReST were both better options than markdown, imho… but I eventually gave in to the overwhelming adoption markdown got.

                          1. 3

                            I mean your own projects you can undermine the hegemony with said better options

                      3. 2

                        such as using blockquotes for callouts and admonitions

                        Is this a correct use of blockquote? If not, why? And what’s the proper alternative?

                        1. 4

                          “aside” might be an appropriate element to use, if “callout” means something like what I’d call a pull-quote. If the text flows with its surroundings, maybe just a class on a regular paragraph would be sufficient.

                        2. 1

                          Huh! I might look into using figures and figcaption in my markdown; I’m already using html anyway for svg with png fallback. Thanks!

                        1. 6

                          This is fine for simple things that won’t be scraped but if you’re building something that might be scraped, please, from someone who spent years writing scrapers and crawlers, write standards-compliant, validating HTML5. It’s easier to introduce syntax errors and other problems when doing shorthand stuff. If you want to be lazy, consider a preprocessor like HAML or Jade that can emit good HTML that satisfies human eyes, browsers, and scrapers alike.

                          1. 19

                            This is standards-compliant, valid HTML. That’s part of what’s so great about it :)

                            Check it out: https://validator.w3.org/nu/?doc=http%3A%2F%2Flofi.limo%2Fblog%2Fwrite-html-right

                            1. 9

                              Validators and most browsers will certainly handle this correctly, since it is, after all, valid. But I wouldn’t be surprised if most other HTML parsers will (incorrectly) not handle it.

                              Oh, did you know there’s an even better shoelace knot than tying the bow as a square knot? It’s more secure, and much harder to mess up.

                              1. 3

                                Oh no! I just got the hang of tying them this way… but thank you!

                                I think my coworkers thought I was joking, but I’ve often commented that shoes and socks that don’t let you down are more important than we realize for leading a happy life.

                                1. 6

                                  Sam Vimes would agree 100%.

                            2. 14

                              I’ve written my fair share of scrapers as well, and my feeling is as a scraper author it’s your responsibility to handle the content you’re ingesting. Generally when scraping, your gain >>> their gain (if their gain is even positive, which it often is not), so asking them to do extra work to make your scraping effort easier feels unfair.

                              Also, a standards-compliant parsing library should handle this fine. For example, bs4 does:

                              >>> from bs4 import BeautifulSoup
                              >>> BeautifulSoup(...) # snippet from article with unclosed <p>, etc.
                              <!DOCTYPE html>
                              <html><head><title>Building a Streaming Music Service with Phoenix and Elixir</title>
                              </head><body><h1>Building a Streaming Music Service with Phoenix and Elixir</h1>
                              <p>
                              I thought it would be nice to make a streaming music service focused on
                              bringing lo-fi artists and listeners together.
                              Early on, I built a series of prototypes to explore with a small group of
                              listeners and artists.
                              Since this is a technical article, I'll jump right into the requirements we
                              arrived at, though I'd love to also write an article on the strategies
                              and principles that guided our exploration.
                              
                              </p><h2>Requirements</h2>
                              <p>
                              We liked a loose retro-computing aesthetic with a looping background that
                              changed from time to time.
                              We preferred having every listener hear the same song and see the same
                              background at the same time.
                              And we liked the idea of sprinkling some "bumpers" or other DJ announcements
                              between the songs.</p></body></html>
                              
                              1. 1

                                This is a great demonstration of the evolution of communal tooling over time. BeautifulSoup was unavailable to me in the environment I was using at the time (2009-2013; we did spectacularly questionable amazing things with mostly just XSL 1.0). I speculate that BS was not quite so robust back then, either. For really complex stuff, we could sub out to Selenium but it was very expensive to our crawling timelines to do so or we could switch to a JVM stack with an extended project scope and cost. I had the privilege of asking some government website authors things like, “Could you fix this one broken tag?” with a 15-30 day wait and it was done, saving the taxpayer some money.

                              2. 3

                                Yeah, I wanted my site to be really easy to scrape. Even Bing (powers DuckDuckGo, Ecosia, Yahoo, and most other alternative engines) gets tripped up when you eliminate optional tags.

                                I ended up going the other way by writing well-formed polygot XHTML5/HTML5 markup and validate all my pages with both xmllint and the Nu HTML Checker before each push.

                              1. 14

                                Thanks to Aaron for posting this. Such a great reminder.

                                Anyone interested in this subject, check out a series of three very tiny books called “UPGRADE YOUR HTML” by Jens Oliver Meiert.

                                They give great step-by-step examples for eliminating optional tags and attributes, reducing HTML to its cleanest simplest valid form. The author is a super-expert in this specific subject, working with Google and W3C on this. His bio here: https://meiert.com/en/biography/

                                From LeanPub: https://leanpub.com/b/upgrade-your-html-123

                                From Amazon: https://www.amazon.com/gp/product/B08NP4GXY2/

                                1. 2

                                  Oh, wow! Thank you for sharing these books. They look like they’d be right up my alley.

                                1. 3

                                  I’m a bit on the edge about this. I did learn a lot even if honestly I don’t write much HTML bu hand these days.

                                  It does looks clean and challenges habits yet it relies a lot on knowing “obscure” details of HTML. It’s all implicit.

                                  Nonetheless why not after all, it shows elegant HTML written with good knowledge of it.

                                  1. 4

                                    Thank you for your kind words! Maybe we can get the word out and make these details less obscure ;)

                                  1. 6

                                    This is great! I’m already fully in agreement with the philosophy for my site http://catern.com/ but I didn’t know some of the tricks about when you could validly omit tags like <html> and <head>! I’m going to start using that right away!

                                    And, it’s obvious in retrospect, but writing tables one-row-per-paragraph makes perfect sense. Previously I’ve been using org-mode radio tables (complicated Emacs stuff) to write my tables, but maybe now I can do away with that!

                                    1. 1

                                      Nice site! I’m delighted I could show you something new :)

                                    1. 2

                                      this is a really nice article and i appreciate the youtube links, will definitely watch later. i was wondering if you planned on having a demo up and running soon or a repo to plug? sometime later this year i want to build a stream on my own personal site and am planning on building it with phoenix/elixir. it’s a rather complicated task but i like biking and would be interested in creating a client that i can stream and play my music on so that other’s can listen while i ride without getting copystruck + it seems like a fun side-project!

                                      edit: i found the link! should’ve probably waited before sending this comment in but i was a little hyped to see someone building a similar project out in the open!

                                      1. 3

                                        Thank you for the kind words! Sure thing: it’s up and running at http://lofi.limo/

                                        Sounds like a cool project; hope you’ll share it here :)

                                        1. 2

                                          for sure, this sort of thing is exactly what excites me about the web!! i’m probably younger than a lot of the people on here but i think it’s probably the same feelings other generations talk about when they reminisce on the old web. it’s cool that even though there are tools out there for people to bootstrap projects like that instantly (i.e. twitch and yt) but building it yourself is part of the fun, in my opinion. i was mostly inspired by the creator of this site who has his own personal stream set up.

                                          1. 2

                                            I agree! This is the fun stuff. I love to pop open a beer and watch Joshua hack away on his old Mac. So mellow and relaxing…

                                            1. 2

                                              Sorry but who is Joshua?

                                              Brilliant website btw. Have been listening to it intermittently while at work. Much better than listening on youtube and watching the uBlock counter go up every second.

                                              1. 2

                                                Sorry but who is Joshua?

                                                jcs, whose stream was mentionned by flbn.

                                      1. 2

                                        I looked into making a communal radio towards the end of 2021. It seemed like liquidsoap was the best in this space, but I lost a lot of time due to other committments

                                        1. 1

                                          Liquidsoap looks really interesting! Thank you for the pointer :)

                                        1. 2

                                          Thank you for sharing this! I particularly enjoyed the quick dive into how Phoenix leverages macros for just about all of it’s magic.

                                          1. 1

                                            Yeah, very clear and helpful. I know they say “don’t use macros” and I understand that from a business sense of trying to limit risk and technical debt. But, becoming a language power user really is so empowering.

                                            1. 2

                                              I imagine what they really mean is “try not to use them” which I think is probably good advice. If you can do something without macros, it’s likely to be more understandable later since there’s one less layer to think about. But if you can’t do it without macros, you’ll probably be glad you’ve got a language that has them 😀

                                          1. 14

                                            Isn’t the problem that Babel is somewhat unsexy project being at a dead end?

                                            A few years ago, if you wanted to write “plain” Javascript and get somewhat ergonomic features (ES6, async/await etc), you had to transpile for backwards compat in the browsers. However browser have caught up. If you are that way inclined, it’s today possible to hand code plain javascript and both get somewhat ergonomic features and run in most browsers.

                                            But then, does anyone hand code javascript anymore? The sane choice is Typescript (or Rust! or some other typed language), and why would I not use Typescript directly instead of Babel? Ok, granted, Babel has a gazillion plugins and allow for building all sort of things, but it goes into the realms of “bundling”.

                                            Bundling used to be synonymous with webpack, not sure it is anymore. We use esbuild because it’s blazingly fast https://github.com/evanw/esbuild - and we managed to cram all bundling needs into it (CSS, Typescript, SVG etc).

                                            Babel is a beast of a project, with an enormous dependency tree. It might just be me, but I actively try to make sure none of our tools (testing, building, bundling) pull in Babel.

                                            If I were to donate to an open source project in this area. I’d try to find something that takes us out of this transpiling madness, or at least does it extremely fast (like esbuild).

                                            1. 7

                                              Despite the hype, I don’t think TypeScript has overtaken JavaScript usage (or is even probably that close, to be honest). I prefer vanilla JS to TS or babelized JS. None of the projects I work on require supporting ancient browsers, so modern browsers do fine with features.

                                              Babel is a beast of a project, with an enormous dependency tree. It might just be me, but I actively try to make sure none of our tools (testing, building, bundling) pull in Babel.

                                              I’m not sure why this matters if you’re using babel as a dev-dependency. It’s not like it’s shipped to browsers with your production code.

                                              1. 5

                                                I’m not sure why this matters if you’re using babel as a dev-dependency. It’s not like it’s shipped to browsers with your production code.

                                                Oh, wow. Trust me, even dev-dependencies can cause unwanted hair loss. The fewer things there are, the fewer things there are to break. Not to say it makes sense to get rid of all the things, necessarily… but I sympathize with the desire.

                                                1. 3

                                                  The concern feels kinda vague to me. I agree it can “feel” weird to pull in large dependencies via npm, but Babel is a compiler. You could say similar things about typescript. I have used both in production and never been aware of shipping a bug that was the result of either tool. If you’re going to use a compiler then you’re trusting and hoping it works, and I feel like the largeness of that tool’s codebase should mostly be a black box to the developer who wields it. Otherwise we could really just say the same thing about any compiler, like ever.

                                                2. 5

                                                  I prefer vanilla JS to TS

                                                  What’s your reason for this? Whenever I have to switch over to vanilla JS from TS I can feel my productivity slow down by about 10x, and I’m about 10x less confident that the code will behave as intended especially after a refactor or when I have to deal with the this funny-business that vanilla JS developers like to use.

                                                  The intellisense alone is worth the switch, not to mention the number of bugs caught by the type system that would otherwise cause mysterious runtime errors. Personally I would love to take a TypeScript job but for my own sanity would never in a million years accept a job writing vanilla JS.

                                                  1. 2

                                                    My reason for wanting less boilerplate and another layer between what I’m writing and what is actually deployed? :P

                                                    I’m not sure what you even mean with the this funny-business that vanilla JS developers like to use - I don’t use this really ever, but I write functional JS. If I’m writing classes for a project (i.e. if a project uses classes and I want my code to look the same), I use fat arrows to encapsulate this just like you would in TS. TS to me is a way for people who came from things like Java to feel “safe” in a language they don’t quite understand. TS to me is the Java-ization of JavaScript and in my experience at 4 different companies, the people who love TS largely come from that background.

                                                    I’ve been writing JS (vanilla) since the late 90s. It’s a language I know and understand very well. TS introduces complexity (both dependencies and its own type quirks) with little to no benefit for me. I’ve never had issues with types in any of the apps I’ve developed.

                                                    1. 2

                                                      You should be an assembly programmer then! :)

                                                      I’ve witnessed a number of people use this as a “magic” rebindable-at-will state variable to enable/disable certain features of a callback function depending on the context. It might be momentarily convenient for the author, but it’s a huge pain for others to read / maintain.

                                                      The big advantage to TS is the type inference and intellisense, which are forms of baked-in, on-demand, automatically-in-sync documentation. It’s also not just Java programmers who like TS – Haskell programmers feel much more comfortable writing TS rather than JS. I’m sure you’ve heard of fp-ts!

                                                3. 5

                                                  Isn’t the problem that Babel is somewhat unsexy project being at a dead end?

                                                  All the more reason to pay people to care about the project: if your project uses it, that’s cheap compared to paying developers for keeping up with the JavaScript build system hype train and integrate all the things you need to be sexy and modern.

                                                  1. 7

                                                    “Unsexy” is a very good reason to pay people to work on it.

                                                    “At a dead end” is a very good reason to stop spending money on it. I don’t use Babel at work, even though I write JavaScript, because all of our supported browsers have async/await, and the rest of the ES proposals are nice but not that nice.

                                                    1. 1

                                                      “Unsexy” is a very good reason to pay people to work on it.

                                                      “At a dead end” is a very good reason to stop spending money on it.

                                                      You encapsulated that much better then I could have. Allowing “Unsexiness” to control tech is one of my pet peeves.

                                                  2. 2

                                                    But then, does anyone hand code javascript anymore?

                                                    That’s how Javascript is taught in schools.

                                                    1. 2

                                                      But then, does anyone hand code javascript anymore?

                                                      Sure thing. And you’re exactly right: writing for reasonably modern browsers is reasonably easy. For projects I’ve worked on lately (where the JS component hasn’t been the bulk of the code) it seems to have been a good tradeoff against fussing with a deep development stack.

                                                      1. 2

                                                        There’s a big reason why even in TS projects a lot of people still use Babel: Babel is compatible with TS nowadays, and for development setups it’s much faster than even webpack + TS with the threaded approach.

                                                        I’ve worked on more than one project where for development we had a Babel doing TS (where not all aspects of type checking are as strict on every rebuild) and for production we go with the actual Typescript compiler and do stricter type checking in case the Babel TS checker missed something.

                                                        I believe even the out of the box setups of popular projects starters like Create React App and Next.js do exactly that.

                                                      1. 7

                                                        What an interesting read, and a delightful site. I remember in the late 90’s we had an absolute mountain of inexpensive NE2000 clones (mostly ISA) and happily used them with Windows and OS/2 but quickly gave up trying to get them to work reliably with Linux. I didn’t know why at the time, but this really explains a lot. I think there was some reasonably ubiquitous 3Com PCI card we settled on for the Linux machines.

                                                        1. 6

                                                          probably the 3com 3c509, which was the Adaptec AHA-1542 of network cards.

                                                          1. 1

                                                            I think that was it! Good memory.

                                                          2. 1

                                                            Yup. I was just starting to use Linux professionally at the time, and remember being delighted to discover a box of old 3Com PCI cards at work, because of their great Linux support at the time. I think it was the Etherlink III?

                                                            1. 1

                                                              Sounds reasonable.

                                                              Like you I came into possession of a box of old 3com cards in the late 90s and I think I used them for many years until I switched to 100MBit

                                                              And the amount of RTL8029 that died after a few weeks was staggering, whereas the RTL8139s worked perfectly fine. (Or maybe I am mixing it up and the 8139s were bad and the 8029s had worked fine, but surely one of those 2). This is something the article doesn’t mention (or if I got it wrong, then 8139 isn’t an NE2000) and maybe our local bunch of LAN party goers had extraordinarily bad luck or the batch of Realtek cards sold here were all flaky, but they were cheap and we always had a few spares because they died all the fricking time. If you had 20 people for a weekend of LAN party you could bet that one person had to switch to a new card before the event was over, so I 100% do not believe in software issues here.

                                                          1. 1

                                                            I love this! Great project concept!

                                                            One question. In many frameworks, multiples of the same param key are treated as an array of values. Did you get your approach, taking the last value as canonical, from a standard out there? I always wondered if there is something that tells us how to handle that.

                                                            1. 1

                                                              Thank you for the kind words! I’m not familiar with a specification for the content of a query string. I see that RFC 3986 mentions “query components are often used to carry identifying information in the form of key=value pairs.”

                                                              I’ve seen it handled three ways: first-value, array, or last-value. First-value may have some security benefit in particular contexts for resisting additional parameters being added to the end. Array, of course, is handy if you want to accept an array. Last-value is easy to implement. I’ve also seen conventions like “array[]=foo;array[]=bar;array[]=baz” or “foo[bar]=baz” used to encode more complex data structures.

                                                            1. 5

                                                              Pet peeves:

                                                              #!/usr/bin/env perl

                                                              use strict;

                                                              use warnings;

                                                              1. 4

                                                                or

                                                                #! /usr/bin/env perl                                                            
                                                                use Modern::Perl '2015';
                                                                
                                                                1. 5

                                                                  I personally find it clearer to do

                                                                  use v5.12; # or whatever
                                                                  use warnings;
                                                                  

                                                                  Versions 5.11 and above automatically activate strict mode. Specifying the exact version number plus a line activating warnings isn’t too much boilerplate, I think.

                                                                  1. 2

                                                                    I like the Modern::Perl invocation because you get say too.

                                                                    But it is an extra dependency for sure.

                                                                    1. 2

                                                                      use v5.10 and later should also enable say.

                                                                      1. 2

                                                                        TIL, thanks.

                                                                        TBH I just started using Modern::Perl after getting the book. I’ve added the boilerplate as an abbrev in Emacs so I don’t have to bother with remembering it.

                                                                  2. 2

                                                                    also of note —

                                                                    $ perldoc perldelta
                                                                     ...
                                                                    $ perldoc perl5120delta
                                                                    
                                                                            use 5.12.0;
                                                                    
                                                                        means:
                                                                    
                                                                            use strict;
                                                                            use feature ':5.12';
                                                                    

                                                                    Also learned that 5.12 is Y2038 compliant

                                                                    It may not mean much to you, but your kids will love it! :-)

                                                                    1. 4

                                                                      That’s good to know! My plan to live forever is working so far…

                                                                  3. 2

                                                                    Hahah, yeah, fair enough. I usually do all that (hm, well, not always env – there are some tradeoffs) but I figured if I was going to go old-school may as well go all the way. Inscrutable runtime errors are the spice of life, right?

                                                                    1. 1

                                                                      For those of us who haven’t used perl in a long time (and IIRC were taught this way), what should we be doing instead and why?

                                                                      1. 1

                                                                        I think spetz was saying I /should/ have done those things but didn’t. If you learned to do things that way, I think you’re still good-to-go. Though some folks up-thread mentioned some other options that may have additional benefits if you’re running a recent-enough version of Perl.

                                                                        1. 2

                                                                          Exactly, my fingers automatic type strict and warnings when starting a new perl file. I read up on the other examples and I like them.

                                                                          Personally I don’t care for ‘say’ and use print/printf but there is other benefits. In my world mostly that the script will behave on a server the same way it does when developing it, and that’s a point I will take with me.

                                                                          1. 1

                                                                            Oh you’re no doubt correct, my bad, ty.

                                                                      1. 3

                                                                        I find it very amusing that this projects basically start with code that looks a lot like cgi-lib.pl, which gives me flashbacks to my first Perl/CGI scripts from the mid-90ies

                                                                        1. 2

                                                                          That’s great! That’s exactly the time I was thinking of when I wrote it. Glad it came through. Fun times, but I’m happy we don’t still have to write everything that way.