Threads for prattmic

    1. 2

      Where did the name “Swiss Tables” come from? It’s not immediately apparent from OP or the linked Abseil website. (Perhaps it’s in the linked video; I didn’t watch it)

      1. 5

        They are called “Swiss” because the team that developed the design was based out of Google’s Zurich office.

        1. 32

          I have also encountered people (online) who didn’t know that you could render web pages on the server.

          React was their default; I saw some static websites that were just static JSX in React. Like if you wanted to put up some photos of your apartment or vacation on your own domain, you would create a React app for that.

          People learn by imitation, and that’s 100% necessary in software, so it’s not too surprising. But yeah this is not a good way to do it.

          The web is objectively worse that way, i.e. if you have ever seen an non-technical older person trying to navigate the little pop-out hamburger menus and so forth. Or a person without a fast mobile connection.


          If I look back a couple decades, when I used Windows, I definitely remember that shell and FTP were barriers to web publishing. It was hard to figure out where to put stuff, and how to look at it.

          And just synchronizing it was a problem

          PHP was also something I never understood until I learned shell :-) I can see how JavaScript is more natural than PHP for some, even though PHP lets you render on the server.

          1. 23

            To be fair, JSX is a pleasurable way to sling together HTML, regardless of if it’s on the frontend or backend.

            1. 10

              Many backend server frameworks have things similar to JSX.

              1. 5

                That’s not completely true, one beautiful JSX thing is that any JSX HTML node is a value, you can use all your language at your disposal to create that HTML. Most backend server frameworks use templating instead. For most cases both are equivalent, but sometimes being able to put HTML values in lists and dictionaries and have the full power of the language do come in handy.

                1. 12

                  Well, that’s exactly what your OP said. Here is an example in Scala. It’s the same style. It’s not like this was invented by react or even by frontend libraries. In fact, Scalatags for example is even better than JSX because it is really just values and doesn’t even need any special syntax preprocessor. It is pure, plain Scala code.

                  Most backend server frameworks use templating instead.

                  Maybe, but then just pick a better one? OP said “many” and not “most”.

                  1. 6

                    Fine, I misread many as most as I had just woken up. But I’m a bit baffled that a post saying “pick a better one” for any engineering topic has been upvoted like this. Let me go to my team and let them know that we should migrate all our Ruby app to Scala so we can get ScalaTags. JSX was the first such exposure of a values-based HTML builder for mainstream use, you and your brother comment talk about Scala and Lisp as examples, two very niche languages.

                    When did I say that this was invented by React? I’m just saying that you can use JSX both on front and back which makes it useful for generating HTML. Your post, your sibling and the OP just sound slightly butthurt at Javascript for some reason, and it’s not my favourite language by any stretch of the imagination, but when someone says “JSX is a good way to generate HTML” and the response is “well, other languages have similar things as well”, I just find that as arguing in bad faith and not trying to bring anything constructive to the conversation, same as the rest of the thread.

                    1. 6

                      Let me go to my team and let them know that we should migrate all our Ruby app to Scala so we can get ScalaTags.

                      But the point is that you wouldn’t have to - you could use a Ruby workalike, or implement one yourself. Something like Markaby is exactly that. Just take these good ideas from other languages and use it in yours.

                      Anyway, it sounds like we are in agreement that this would be better than just adopting JavaScript just because it is one of the few non-niche languages which happens to have such a language-oriented support for tags-as-objects like JSX.

                    2. 2

                      I found that after all I prefer to write what is going to end up as HTML in something that looks as much as HTML as possible. I have tried the it’s-just-pure-data-and-functions approach (mostly with elm-ui, which replaces both HTML and CSS), but in the end I don’t like context switching it forces on my brain. HTML templates with as much strong checks as possible is my current preference. (Of course, it’s excellent if you can also hook into the HTML as a data structure to do manipulations at some stage.)

                      For doing JSX (along with other frameworks) on the backend, Astro is excellent.

                      1. 1

                        That’s fair. There’s advantages and disadvantages when it comes to emulating the syntax of a target language in the host language. I also find JSX not too bad - however, one has to learn it first which definitely is a lot of overhead, we just tend to forget that once we have learned and used it for a long time.

                    3. 8

                      In the Lisp world, it is super common to represent HTML/XML elements as lists. There’s nothing more natural than performing list operations in Lisp (after all, Lisp stands for LISt Processing). I don’t know how old this is, but it certainly predates React and JSX (Scheme’s SXML has been around since at least the early naughts).

                      1. 5

                        Yeah, JSX is just a weird specialized language for quasiquotation of one specific kind of data that requires an additional compilation step. At least it’s not string templating, I guess…

                        1. 1

                          I’m aware, I wrote such a lib for common lisp. I was talking that in most frameworks most people use they are still at the templating world.

                          1. 2

                            It’s a shame other languages don’t really have this. I guess having SXSLT transformation is the closest most get.

                        2. 1

                          Every mainstream as well as many niche languages have libraries that build HTML as pure values in your language itself, allowing the full power of the language to be used–defining functions, using control flow syntax, and so on. I predict this approach will become even more popular over time as server-driven apps have a resurgence.

                          JSX is one among many 😉

                    4. 14

                      I am not a web developer at all, and do not keep up with web trends, so the first time I heard the term “server-side rendering” I was fascinated and mildly horrified. How were servers rendering a web page? Were they rendering to a PNG and sending that to the browser to display?

                      I must say I was rather disappointed to learn that server-side rendering just means that the server sends HTML, which is rather anticlimactic, though much more sane than sending a PNG. (I still don’t understand why HTML is considered “rendering” given that the browser very much still needs to render it to a visual form, but that’s neither here nor there.)

                      1. 37

                        (I still don’t understand why HTML is considered “rendering” given that the browser very much still needs to render it to a visual form, but that’s neither here nor there.)

                        The Bible says “Render unto Caesar the things that are Caesar’s, and unto God the things that are God’s”. Adapting that to today’s question: “Render unto the Screen the things that are the Screen’s, and unto the Browser the things that are the Browser’s”. The screen works in images, the browser works in html. Therefore, you render unto the Browser the HTML. Thus saith the Blasphemy.

                        (so personally I also think it is an overused word and it sounds silly to me, but the dictionary definition of the word “render” is to extract, convert, deliver, submit, etc. So this use is perfectly inline with the definition and with centuries of usage irl so i can’t complain too much really.)

                        1. 4

                          You can render a template (as in, plug in values for the placeholders in an HTML skeleton), and that’s the intended usage here I think.

                          1. 3

                            I don’t think it would be a particularly useful distinction to make; as others said you generally “render” HTML when you turn a templated file into valid HTML, or when you generate HTML from another arbitrary format. You could also use “materialize” if you’re writing it to a file, or you could make the argument that it’s compilers all the way down, but IMO that would be splitting hairs.

                            1. 6

                              I’m reminded of the “transpiler vs compiler” ‘debate’, which is also all a bit academic (or rather, the total opposite; vibe-y and whatever/who cares!).

                              1. 2

                                It seems that was a phase? The term transpiler annoys me a bit, but I don’t remember seeing it for quite a while now.

                            2. 3

                              How were servers rendering a web page?

                              Worked very well for Opera Mini for years. Made very low-end web clients far more usable. What amazed me was how well interactivity worked.

                              1. 2

                                So now I want a server side rendering framework that produces a PNG that fits the width of my screen. This could be awesome!

                                1. 2

                                  There was a startup whose idea was to stream (as in video stream) web browsing similar to cloud gaming: https://www.theverge.com/2021/4/29/22408818/mighty-browser-chrome-cloud-streaming-web

                                  1. 1

                                    It would probably be smaller than what is being shipped as a web page these days.

                                    1. 6

                                      ESL issue. “To render” is fairly broad term meaning something is to provide/concoct/actuate, has little to do with graphics in general.

                                      1. 3

                                        Technically true, but in the context of websites, “render” is almost always used in a certain way. Using it in a different way renders the optimizations my brain is doing useless.

                                        1. 5

                                          The way that seems ‘different’ to you is the way that is idiomatic in the context of websites 😉

                                  2. 6

                                    React was their default; I saw some static websites that were just static JSX in React. Like if you wanted to put up some photos of your apartment or vacation on your own domain, you would create a React app for that.

                                    Unless it was being rendered on the client, I don’t see what’s wrong with that. JSX and React were basically the templating language they were using. There’s no reason that setup cannot be fully server-generated and served as static HTML, and they could use any of the thousands of react components out there.

                                    1. 4

                                      Yeah if you’re using it as a static site generator, it could be perfectly fine

                                      I don’t have a link handy, but the site I was thinking about had a big janky template with pop-out hamburger menus, so it was definitely being rendered client side. It was slow and big.

                                    2. 5

                                      React was their default; I saw some static websites that were just static JSX in React. Like if you wanted to put up some photos of your apartment or vacation on your own domain, you would create a React app for that.

                                      I’m hoping tools like Astro (and other JS frameworks w/ SSR) can shed this baggage. Astro will render your React components to static HTML by default, with normal clientside loading being done on a per-component basis (at least within the initial Astro component you’re calling the React component from).

                                      1. 8

                                        I’m not sure I would call a custom file type .astro that renders TS, JSX, and MD/X split by a frontmatter “shedding baggage”. In fact, I think we could argue that astro is a symptom of the exact same problem you are illustrating from that quote.

                                        That framework is going to die the same way that Next.JS will: death by a thousand features.

                                        1. 6

                                          huh couldn’t disagree more. Astro is specifically fixing the issue quoted: now you can just make a React app and your baseline perf for your static bits is now the same as any other framework. The baggage I’m referring to would be the awful SSG frameworks I’ve used that are more difficult to hold correctly than Astro, and of course require plenty of other file types to do what .astro does (.rb, .py, .yml, etc.). The State of JS survey seems to indicate that people are sharing my sentiments (Astro has a retention rate of 94%, the highest of the “metaframeworks”).

                                          I don’t know if I could nail what dictates the whims of devs, but I know it isn’t feature count. If Next dies, it will be because some framework with SSG, SSR, ISR, PPR, RSC, and a dozen more acronym’d features replaced it. (And because OpenNext still isn’t finished.)

                                          1. 6

                                            Astro’s design is quite nice. It’s flexing into SSR web apps pretty nicely I’d say. The way they organize things isn’t always my favorite, but if it means I can avoid ever touching NextJS I’m happy.

                                    3. 2

                                      benchstat is a super useful tool. Though it is obviously useful for use with Go benchmarks since it parses the format used by Go benchmarks, the tool itself isn’t really Go specific. The format is actually quite simple, so I’ll often convert other formats to work with the tool. For example, I’ll convert the output of perf stat to get quick cycle count comparisons.

                                      1. 2

                                        RISC-V: support for Zve32x, Zve64x, Zimop, Zcmop, Zama16b, Zabha, Zawrs, and Smcntrpmf extensions

                                        These extension names are getting out of hand

                                        Smcntrpmf extension extends the RISC-V Privileged ISA to support privilege mode filtering for the cycle and instret counters. (‘Sm’ for privileged M-mode extension, ‘cntr’ because it extends the ‘Zicntr’ extension, ‘pmf’ for Privilege Mode Filtering). This extension depends on the Zicntr extension.

                                        1. 4

                                          I was chatting to a friend about this just yesterday:

                                          <kivikakk> i love riscv extension names
                                          <kivikakk> tfw u’re wondering if u support xsfvfnrclipxfqf
                                          <kivikakk> or xsfvfwmaccqqq

                                          (these are REAL extension names, written by REAL isa authors)

                                          1. 8

                                            (these are REAL extension names, written by REAL isa authors)

                                            An engineer went to the optometrist to get their eyes checked. The doctor showed a slide and asked if they could read the letters:

                                            X S F V F N
                                            R C L I
                                            P X F
                                            Q F

                                            “Read the letters? I wrote the extension!”

                                            1. 1

                                              Incredible! (btw: to insert a hardbreak at end of line, end it with two spaces or a backslash \)

                                            2. 3

                                              Similar conversation I had with a coworker recently:

                                              Them: I think I can use GF2P8AFFINEQB for this problem!

                                              Me: New x86 instruction dropped!

                                              Me: Wait, that is a real instruction…

                                              1. 2

                                                The single letter extensions are also a bit weird: they proposed a tonne of bitmanip extensions but only four got ratified. Then, this year, they ratified the B extension as enabling only three of those four ratified extensions!

                                                What happens to the fourth ratified extension Zbc and the others still in draft?

                                                This means our ibex core is officially:

                                                RV32IMCBSmepmp_Zbc_Zbe0p9_Zbf0p9_Zbp0p9_Zbr0p9_Zbt0p9_Zicsr_Zifencei
                                                

                                                … I think. Based on the rules here: https://github.com/riscv/riscv-isa-manual/blob/main/src/naming.adoc

                                            3. 6

                                              I find this report confusing. Why does if items[hashIndex].key == nil show as taking 5.01s, but the call to bytes.Equal shows as only 390ms. Surely a slice lookup is much cheaper than a function call? If you are a Go performance expert and can help me interpret it, I’m all ears!

                                              I took a look at what was happening here and came away with two finding:

                                              1. items[hashIndex] is a significant source of cache misses.

                                              From perf record -e cache-misses, it is the largest source of misses in r9ProcessPart, followed very closely by the original chunk access on L115 (c := chunk[i]). This isn’t too surprising, as this index is basically a random lookup into a table too large to fit into cache (at least on my CPU). FWIW, about 66% of cache misses are in the kernel during the read call (presumably copying from page cache?), most of the rest of misses (~30%) are in r9ProcessPart. I am a bit surprised that the memequal in bytes.Equal didn’t have more misses accessing the key (~2%).

                                              These cache misses make the access disproportionately expensive.

                                              1. The bytes.Equal line has some sort of source attribution issue. Expanding the assembly for that line shows:
                                                  169        290ms      290ms           if bytes.Equal(items[hashIndex].key, station) {
                                                              20ms       20ms   4b6756:                                     MOVQ R10, 0x28(SP)                           r9.go:169
                                                             270ms      270ms   4b675b:                                     MOVQ AX, 0x98(SP)                            r9.go:169
                                                                                   ⋮
                                                                 .          .   4b696f:                                     JNE 0x4b67a8                                 r9.go:169
                                              

                                              That is clear not actually doing a comparison. bytes.Equal should call runtime.memequal.

                                              The assembly in r9ProcessPart is quite difficult to follow due to the complexity of the function, but there is definitely a call to runtime.memequal in there. I’m not sure if the compiler is failing to annotate the source line correctly, or if pprof is struggling to aggregate samples on instructions from inlined calls (this seems more likely, especially since the compiler seems to be moving the inlined code all over the place in this function).

                                              My run shows ~9.5s on items[hashIndex].key and 290ms on the call to bytes.Equal. But if I look further down the profile, there is ~4.5s in memeqbody, which is called from bytes.Equal -> runtime.memequal -> memeqbody. 4.5s here makes much more sense than only 290ms.