OOHtml – Object-Oriented HTML Implementation
github.com
github.com
<ul render="@items: (name,index) of ['dog','cat','ram'] / 'item';"></ul>
Maybe I am special, but this looks absolutely cursed to me. Logic in an HTML attribute string? Please no.
I don't have a quantitative reason for this feeling[1], but the idea of combining OOP principles - class, object, inheritance - with document markup gives me that feeling.
[1] I'd need to think about it for a second, but I am pretty sure that the root of this dread is the potential of a deep, deep pit-trap, where a class system runs parallel - but discrete - to the inherent semantics of HTML. But I'm not a big fancy-pants programmer. I'm sure my gut feelings can be safely discounted if this idea truly has some legs. I dunno. I like HTMX fine, but that's a different kettle of fish, isn't it? It's not got the same underlying notion of reification like OOP does. It's like the difference between a car with an automatic transmission option versus a car that has modular functionality that toggles whether or not a transmission is a thing or not, which may contain the quality of "automatic".
These seemingly simple template languages that promise an escape from the "unnecessary" bloat and complexity of the modern web are doomed to fail. Any level of adoption will drive deeper usage, which will drive more complex use cases, which will force more bolted-on general programming language features. Eventually your users discover (the hard way) why all the complexity in modern web frameworks exists, but now they're stuck programming in a shitty template language that is underbaked, awkward to use, has no ecosystem, shitty tooling and some rancid expression DSL you have to memorize. Cursed indeed.
But there's something you find when you follow a practice driven process, and the realisation that brought data binding in OOHTML is one of them.
I'm happy to write a post about this when I have more time. But thanks for your feedback.
And now you go down the same path.
If you are building real applications with this then you will find that OOHTML will need to be repeatedly extended in order to fit the more complex use cases that come with deeper usage. You will end up reinventing the wheel but worse. That's a great outcome if the project is a hobby or learning experience. But if you're trying to deliver real commercial outcomes with this tech I would start rethinking things now.
I'm happy to incorporate constructive feedback on this project, and it's early age affords us a great opportunity to do just that.
So what's your thought on the challenge?: a native way to bind an element's css properties, class list, attributes, etc. to application data?
Meanwhile, I am happy to put up a quick post regarding the thinking over here. I might have done a bit of that in the introductory article: https://dev.to/oxharris/revisiting-the-html-problem-space-an...
I think it could work if it decoupled the reactivity layer and exported a "rerender me" hook that libraries like react/preact/vue/solid/etc could use to manage reactivity.
Because let's be real, `<ul render="@items: (name,index)` and `v-for` type things are terrible. JSX got a lot of things right. It's a pretty darn good marriage of HTML and javascript as far as syntax goes. Besides className, key and the curly syntax to drop into javascript, its pretty pure and straight forward.
vue/angular are better than jsx. Differences are minor, of course. But why should it be jsx?
You cannot compare Vue/Angular (frameworks) to JSX (syntax extension for JavaScript). As a fact you could write your templates in Vue or Angular using JSX.
Both are fine. It doesn't have to be a war.
JSX is trivially converted to a Javascript function call which immediately explains everything about its capabilities and syntax.
I don't see how jsx is more trivial than html which is what cue templates are.
This goes into more details: https://news.ycombinator.com/item?id=19199423
https://es.discourse.group/t/proposal-esx-as-core-js-feature...
Data and code should live separately.
Many software engineers love consistency more than anything else, so when OOP works so well for that fraction, it looks "untidy" to have several different styles spread throughout. OOP apologists preach that it should be everywhere even if it doesn't make sense, so there's social pressure to force it all the places it's not needed.
For example: unit testing is almost impossibly hard with OOP. Encapsulation and OOP-flavored dependency injection add significant complexity when setting up a single function to unit test. You have to use extremely complex mocking libraries to test anything. On the other hand, pure static functions are trivial to test, just pass in the data and test the data coming back out. Yet OOP apologists still argue to this day that extremely difficult unit testing is worth it for the dubious benefit of having the whole codebase feel tidy.
Let's take the concept of interfaces in OOP as used for polymorphism. An interface is fantastic for swapping out multiple behaviors or strategies at runtime. Very handy. However, how many times in an average software project are they actually needed? A favorite trick I like to do with OOP codebases is count how many interfaces have more than one implementation (not counting unit tests). I recently helped a team with a project with ~4 million lines of C#. There were ~900 interfaces, and 6 of them had more than one implementation. The rest of the interfaces were just for unit test mocking. Not needed for polymorphism, just unit test cruft. Those 894 interfaces were mocked out only in unit tests. Each of their 10k unit tests was on average 60 lines of mocking logic. For the 6 places it was needed, a polymorphic interface was a great solution! The rest though, not needed at all, and if they'd reorganized the logic into pure static functions they could cut back most of those 60 line unit tests into 4-6 lines. Instead of 600,000 lines of unit test logic, they'd only have 60,000 lines. All that mocked out unit test logic was slowing them down considerably. Every tiny little change required fixing thousands of lines of brittle unit test logic.
This is just one dimension, but it's an important one. OOP is great in those few rare places it's needed, but the rest of the time it's a square peg in a round hole.
I could be misreading this, but it looks like this project is overriding the UA’s `querySelector` family of methods, which doesn’t quite sit right. I thought it was a best practice to level the built-in prototypes alone.
to leave* the built-in prototypes alone
Besides, I don't really want programming right in the HTML and never did. Your mind doesn't read text the same way it reads programming code; the HTML tags are enough. Put the code elsewhere.
Just in case, you are referring to C89, right? (Such language can't be a superset of C99 or later.)
> That's what this says to me.
I haven't written any PHP for years, but I think `<?` was already heavily discouraged back when I was still doing PHP things. Any surviving PHP codebases should have a similar guideline (for example, [1] for WordPress).
[1] https://developer.wordpress.org/coding-standards/wordpress-c...
The namespace idea did seem interesting though.
I have jumped on and off of web development in the last 8 years. Everytime I jump back in there are changes.
I ended webdev around 2011 being pretty good with jquery, using ajax to load part of web pages. Did some cool stuff for its time.
Came back to webdev in 2014 using knockoutjs. Seemed like bloat but did not question decision outside my control. I did like the idea of changing a value and it automatically applied the change on screen.
Came back to webdev in 2018 using angular. This was my decision and only because "it was popular" so anyone could take over hte project. Felt like duplicating my work to be honest.
Now, its 2022 and back on web dev. React. npm. Seriously... WTF! One site was using npm and grunt JUST TO MINIFY FILES!! Again... WTF!
Maybe there is something good about this OOHtml and missing the point entirely. WOuld not be suprised using this requires over 1000 npm dependencies.
It'd be nice to actually have a nice clean, fast site for once that doesn't present you with a load of spinners or other nonsense while the content actually loads. Before your face gets DDOSed with adverts.
The modern web is a disgrace. I sometimes wonder if some devs actualy use the sites they create.
Absolutely. It's just when you jump back in the webdev world and you see changes you end up learning them to keep yourself relevant.
As the years have passed, since starting with knockoutjs (for me) the back of my mind was slowly accepting the "old ways" are the best way to simplify and solve the actual problem.
I was slowly moving back to using jQuery.. and, in the last year, have been moving over to htmx.
If I get you correctly, is it that the other features like scoped styles and scripts, or html imports, don't look as good?
For data binding, I can see peoples frustration: syntax! And that's to say we've got to have more extensive conversations around here.
I don’t know if I would use this for any serious project. Maybe a hobby project
Don't hesitate to open an issue on project repo when you do use it on a hobby project.
I’m open for new ideas though, I might give this a try in a small project.