Threads for taowen

  1. 1

    put the object to a special array is just another way to set feature flag. it is just a harder to find out feature flag. Add field to a object or add field outside the object but with pointer to it.

    1. 1

      What they seem to be describing is a vague approximation of the Entity Component System pattern. The benefit is that it moves the complexity of the entire program out of the object itself and into the systems that need to know that state. Why does an entity need to know it’s visible? Shouldn’t the system handle that for all entities with that component instead? There isn’t any one answer, but this kind of pattern might simplify your program a lot.

      1. 1

        the code checking for a particular flag should put into files close to each other ( put into the same system ), that is the essence.

    1. 2

      Seems like there are more and more anti-SPA articles popping up: https://github.com/taowen/awesome-html/blob/main/README.md#reflection

      1. 6

        The experience of using GatsbyJS is a nightmare. Errors are truly impossible to debug. Plug-in documentation is always lacking to the point where I have to read the source. All the integration points are unbelievably complicated. GraphQL is a terrible abstraction layer for a small personal site. It’s lots of great ideas in theory but absolutely awful in practice.

        I’m waiting for Astro to be done enough for me to rebuild my site in it so I can deliver a near-zero JS site (other than the theme switcher).

        I haven’t liked a static site generator since Metalsmith.

        1. 2

          Is metalsmith not an option for you? I’m curious to know why.

          1. 1

            I hadn’t heard of metalsmith until this comment. It looks really cool! If I ever need a js static site generator I’ll give it a serious look.

            1. 1

              When a static site generator stops being actively maintained you can definitely keep using it but you have to freeze everything from Node.JS to all your dependencies. That’s extremely fine and not a problem at all except I’m a web developer by trade so I want to be trying new things all the time.

              1. 1

                Oh wow I spoke too soon, after 5 years it’s back with a maintainer: https://metalsmith.io/news/2022-01-27/metalsmith-is-back/

            2. 1

              I’m really enjoying Nikola, but I’m a Python guy so that goes a long way :)

              Metalsmith looks really great. If it ain’t broke, don’t fix it! :)

              1. 1

                What do you need from Astro that’s blocking you from moving to it? I just moved my personal site from NextJS to Astro and I love it. But my site is very simple, just some MDX and React rendered to a blog.

                1. 1

                  I hit some blocking issues last I tried a few months ago, eg https://github.com/withastro/astro/issues/2225. Looks like that one might not be fixed.

                  I also REALLY want to be able to collocate images with the mdx file that uses it but this isn’t a deal breaker.

                  It’s almost there for me.

                  1. 2

                    I hit some blocking issues last I tried a few months ago, eg https://github.com/withastro/astro/issues/2225. Looks like that one might not be fixed.

                    Ahh, my styles are in a plain external stylesheet, so I haven’t run into this problem.

                    I also REALLY want to be able to collocate images with the mdx file that uses it but this isn’t a deal breaker.

                    Yeah, I had that pattern in my previous site. With Astro I just adopted a naming convention so that it’s easy to tell which images go with each blog post, given they can’t be co-located. I don’t have many posts, or images, so for me it was an easy change.

                    1. 1

                      Yeah same. The collocation issue didn’t get ported to the RFC process so we’re unlikely to get it: https://github.com/withastro/astro/issues/1618

                2. 1

                  I think writing the integration code ourself can make debugging a lot easier. I have written a guide on only using vite to statically generate a website: https://github.com/taowen/vite-howto/tree/main/packages/SSR/generate-static-website

                1. 1

                  Argument HTML with iOS like layout animation and gestures, deliver modern user experience with traditional monolith web server

                  1. 1

                    Write code with React + TSX, we can statically verify the identifier referenced. But write code in htmx / jquery, we lose the support of static type checking ( from Microsoft )

                    1. 3

                      there are many similar libraries in low-js category https://github.com/taowen/awesome-html But avoid javascript is the wrong attitude, JavaScript is not the problem. Htmx just reinvent a dsl to do the job of JavaScript

                      1. 12

                        Htmx just reinvent a dsl to do the job of JavaScript

                        That’s not quite the way to think about it, IMO. It’s more like there are a lot of really common interaction patterns that browsers don’t natively implement, and which have to be implemented in JavaScript. And the way browser development has actually gone, browsers don’t implement these things, but provide more and more power for building JavaScript applications. HTMX is more like a polyfill for an alternate universe where browsers let you do all of the most common AJAX patterns declaratively, as part of HTML.

                        It’s like date pickers. Until relatively recently, browsers did not implement a native date picker control, and they had to be implemented in JavaScript. There must be thousands of jQuery date/time picker implementations. Today, there are HTML 5 input types for date, time, and date/time, and most browsers implement them natively. You can throw away your JavaScript datepicker implementations now. From my point of view, HTMX is like this; what if HTML had absorbed the most common and useful AJAX patterns and you could now throw away your JavaScript implementations of those patterns.

                        1. 6

                          One reason I prefer Alpine.js to Stimulus is that Stimulus was written by people who don’t like JavaScript, and Alpine was not. Stimulus goes out of its way to not use JS conventions, whereas Alpine is just a convenient way to write JS inline but still have it work with componentized layouts.

                        1. 1

                          Vue 3 is a rective UI framework already. With a little bit of code https://vue-db.js.org/ you can turn Vue 3 application into a reactive database

                          1. 5

                            The original David Parnas paper on extensible code is titled “Designing Software for Ease of Extension and Contraction.”

                            Extension means adding cases, contraction means deleting them.

                            The contraction bit was always there.

                            Extension and contraction go hand in hand; they’re both consequences of well designed modularity.

                            I strongly recommend reading that Parnas paper, as well as that on modularity, if by any bad luck you haven’t yet.

                            1. 1

                              Thank you for the paper recommendation. The modularity paper seems a lot more often-referenced than the one you bring up.

                              1. 1

                                I like the paper a lot. A key insight is to specify the “minimal requirement” and build up from there. If every software project has two requirement set, one being “minimal”, another being “all plugins installed, full bloated state”, it will be a lot easier to keep a modular architecture. The product designer, instead of programmer, should be responsible for specifying how these two requirement set can be met in the same time. The solution of modularity problem might not in the hands of programmer, but in the product designing side.

                                1. 1

                                  Thanks Tao! There are some challenges to selling, as you described in the post: it has to be used on new projects, it is open source so they can host it themselves if they wish. But then there is also managed hosting, support, additional products on top -> most big open source projects successfully monetize this way. And there is this notion of “monopoly” as you said - with solution like this, it is important to be stable and well spoken of to be used by a lot of people, that is a barrier to entry but it also means it is equally hard for others.

                                1. 1

                                  I have developed a framework categorizing everything as these three types. Able to maintain the cache value on change, so that we can minimize the state.

                                  1. 9

                                    The article seems like a trillion dollar disaster itself, wasting a good title. There’s quite lot of craptalk throughout. Also appeals to authorities spread across the post… Seriously think that Linus Torvalds doesn’t do any mistakes and him avoiding OOP would not be one such mistake? Research institutions favored over industry practices? What the heck dude? You still trust everybody after this mess?

                                    Then there’s the bull about functional programming as a remedy in the middle. When you bring it over to mean coding in Javascript, it becomes the same turd with the label in the can replaced by an another. Yeaah.. Sell it to us!

                                    Warning you ahead: There’s the classical “complexity is bad” -talk mixed in. Complexity down. Ohwait what is meant with complexity here? The guy/gal tells it’s shared mutable state and errorneous abstraction, low signal-to-noise. All those things common in OOP. Maybe the worse problem you have would be that nothing you ever wrote is actually correct? People find bugs in your stuff decades afterwards, and others add their own bugs in! Things have to get quite complex to actually do the things you want them to do and there’s nothing you can do about that. Terabytes of memory in your system. How would you expect that your software could even be simple in the same way it was when you had 32 kilobytes of available memory?

                                    And this dogma about mutable state.. Little they do know that latest theorem provers like Idris2 are ok with mutable state and handle it well because of progression into affine/linear logic, and you don’t have problems with reasoning over mutable state with that tool. Then there’s that thing “Separation logic” for reasoning about traditional programs. Mutability or parallellism in OOP aren’t the things that make it bad. They’re merely just things that OOP doesn’t do jack shit about. It’s completely ineffective in handling those things, just like the “FP” is, it’s just that with “FP” you aren’t even able to do anything with mutable state so the problem’s solved?

                                    All that incense over message passing is old stuff. It was there when I started coding. Too bad it doesn’t work because messages really provide very little in terms of what you can predict about program’s behavior, often things go over multiple steps before they accept the same message again, meanwhile everything can go wrong. Even Haskell doesn’t help because you still do typo or forget precedence rules somewhere such that it passes the type checker without being noticed and introduces a new case that isn’t catched by any of your seven test suites because it’s a new way to get it wrong.

                                    There’s lot of things you can argue spread around there. Encapsulation as global state? OOP modeling real world through its inheritance? All of those factories and MonaLisaProviders being complexity? Bit of intertextual references to classical texts (kingdom of nouns, that was fun to read years ago).

                                    Too bad(good?) to the author of that post. People are going to get back into dragging them to your level and arguing with you, just refuting what you say. Unit testing must be great because we test things in real world to make sure they qualify! It can’t be bad with coding?! That time surely isn’t wasted like you claim. Controlling your private parts is important so why not private/protected/public is important too. Surely packing things together must be an abstraction and that’s necessary to write software at all.

                                    Meanwhile, your whole industry is a fraud in the progress. You even already know it and feel something that your peers call “impostor syndrome”. Sigh.

                                    Nothing of OOP does anything because it attacks the false problem in the first place just like many other software solutions do. You blame yourself about missing targets but you aren’t even aiming at the target when you press fire. Things such as static or dynamic doesn’t mean anything at all. You should foremost care about what you know with certainty of program’s behavior before it runs.

                                    The history is indeed repeating itself, and this dude is repeating it. This time with FP.

                                    1. 1

                                      Nothing of OOP does anything because it attacks the false problem in the first place just like many other software solutions do. You blame yourself about missing targets but you aren’t even aiming at the target when you press fire.

                                      Indeed. A problem well-stated is half solved. We did not spend enough time on investigating what is the real problem, and what actually makes the problem hard, but spend far too much time on arguing arbitary solution. Here are some problems I find fascinating:

                                      • How to make developer perceive the global architecture when we only have a dark screen of 80 characters scrolling over thousands of files?
                                      • How to make developer perceive what is actually going on when we only have “console.log” as a tiny torch lighting up the cave?
                                      • If somewhat mutable state is inevitable, how to make “variable” or something with “identity” easier for human cognition? Is mutability the problem, or we are simply having too many states, especially too many ungrounded, local, transient states?
                                      • It is well-known attention is single threaded, and developer can only do informal reasoning with attention. How to make software source code read like “single threaded” but actually exploit parallesim in the runtime?
                                      • Why re-use is more successful in certain area, but not in other? Is it because there is a missing common ground to make the inter-changable parts economy flourish?

                                      I don’t know exactly when people invent OOP or FP, what kind of problem do they have in mind. It will be more constructive when we can start discussion from the problem.

                                    1. 2

                                      Would be nice to come up some concrete algorithm to calculate the “Code Cognitive Load”. It is already well-known, language and tool designer need to incorporate human-computer-interface knowledge to improve their design. There are couple of communities and conferences working on this front: