top | item 39353516

OOHtml – Object-Oriented HTML Implementation

47 points| ambigious7777 | 2 years ago |github.com | reply

63 comments

order
[+] gloosx|2 years ago|reply
<!-- The loop -->

<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.

[+] CipherThrowaway|2 years ago|reply
It looks cursed because it is cursed. It's the classic "back to the basics" web technology nonsense that is hello world optimized and completely unsuited to any real world business purpose.

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.

[+] MilStdJunkie|2 years ago|reply
Do you know the line in that one Cake song, "bowel shaking earthquakes/of doubt . ."?

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".

[+] trilbyglens|2 years ago|reply
Tbh this is basically jsx. Jsx is also cursed.
[+] parhamn|2 years ago|reply
I've been wondering recently if there could be a more generic JSX renderer that could be built into browser. <script type="jsx"> type thing.

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.

[+] orangepanda|2 years ago|reply
Have you looked at ECMAScript for XML (E4X) ?
[+] beebeepka|2 years ago|reply
but what about those if us who prefer other template engines?

vue/angular are better than jsx. Differences are minor, of course. But why should it be jsx?

[+] DeathArrow|2 years ago|reply
When I read about object oriented anything, I can't stop that object is a poor fit for most things programming, mostly because encapsulation and inheritance.

Data and code should live separately.

[+] JackMorgan|2 years ago|reply
OOP is the perfect fit for <10% of every codebase I've worked on. It is so good for that 10% that it encourages people to wonder if perhaps it should be applied everywhere else.

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.

[+] toastal|2 years ago|reply
Great for all my cases where when my <cat> elements cleanly inherits from <animal>!

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.

[+] toastal|2 years ago|reply
inherit* from

to leave* the built-in prototypes alone

[+] cognomano|2 years ago|reply
Tag languages were a success because SGML. Once we past XML tag languages are not loved by many people. JSON, YAML, and a myriad of another languages are being teach and used today. Don’t get me wrong — I loved when the XML 1.0 spec was published but the broken promise that we would never need to write XML by hand was the cause of hate to tag languages. Object Orientation is hated these days by many people. Those are the challenges this kind of projects have ti overcome in order to be successful.
[+] hyperhello|2 years ago|reply
The comment-based data-binding syntax <?{ }?> proposed is not going to be PHP compatible.

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.

[+] lifthrasiir|2 years ago|reply
PHP has supported a long tag syntax `<?php` since PHP 3 in order to be compatible with XML, and a short tag `<?` can be always turned off. As long as it doesn't conflict with `<?=` (which is now an always-available short tag syntax for `<?php echo`), `<?{ ... }?>` should be okay even for PHP.
[+] omoikane|2 years ago|reply
Are there websites built with this? I might expect it to be used for their own website, but currently webqit.io does not resolve.
[+] phrasecode|2 years ago|reply
Nice catch. But yes we're currently buying a Progressive Web App right now with OOHTML. I'm happy to share after we've made progress.
[+] himmelattack|2 years ago|reply
There are some really interesting ideas here. I love how scoping works and is integrated with the other parts of the framework.
[+] phrasecode|2 years ago|reply
This is a great feedback and I'm sure that this conversation and some of the frustration around will help us get even better.
[+] transfire|2 years ago|reply
Sorry. There’s way too much complexity here. And too much shouting!

The namespace idea did seem interesting though.

[+] phrasecode|2 years ago|reply
This is a great feedback and I'm sure that this conversation and some of the frustration around will help us get even better.
[+] masfoobar|2 years ago|reply
Whenever I see OO[something] in the world of programming, I have that face my mother would be ashamed of.

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.

[+] trollied|2 years ago|reply
There's no reason why you can't still dev the "old" way.

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.

[+] troupo|2 years ago|reply
Apart from some things, it's quite damning that a single person came up with better suggestions than the entire W3C/WHATWG. Namespacing; scoping; HTML Imports with lazy loading, inheritance and contexts...
[+] Devasta|2 years ago|reply
The WHATWG was founded as a response to the push from the W3C to try and push everything to XHTML. HTML can never be improved, that belief is at the heart of the WHATWG, even if they don't openly admit it. The best you can hope for is endless Javascript that occasionally have angle brackets sprinkled in.
[+] phrasecode|2 years ago|reply
Your feedback really stands out here dude. I'm hoping that the whole conversation here and some of the frustration will lead to something even better for OOHTML.
[+] xg15|2 years ago|reply
Are they trying to reinvent XSLT again?
[+] chuckadams|2 years ago|reply
The scoped IDs are a good idea, and I'd love to see that make its way into the HTML standard. Not having to generate unique IDs to attach labels to is nice. The rest of this looks like it's trying to appropriate Vue or Angular's template languages, which ought to stay in Vue and Angular where they belong.
[+] phrasecode|2 years ago|reply
Feels good to know. It really already saves the day for me.

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.

[+] xyst|2 years ago|reply
Looks like author put in some serious time into this project. It’s a shame the last update was 10 months ago. Linked website does not resolve for me either.

I don’t know if I would use this for any serious project. Maybe a hobby project

[+] phrasecode|2 years ago|reply
Author here. Looks like you missed something about the last update thing. I do actively work on it and ever poised to incorporate feedback.

Don't hesitate to open an issue on project repo when you do use it on a hobby project.

[+] Alifatisk|2 years ago|reply
Reminds me of Vue. I guess this would be the ”buildless” version of it, but with bizarre syntax.

I’m open for new ideas though, I might give this a try in a small project.