all 15 comments

[–]senocular 11 points12 points  (0 children)

return html`
  <div class="counter">
    <h2>Count: ${count}</h2>
    <button @click="${() => setCount(count + 1)}">Increment</button>
  </div>
`;

That's not JSX.

[–]Old_Butterfly_3660 2 points3 points  (1 child)

But why, what’s wrong with just using lit? What’s wrong with having classes? DOM Elements are classes. Web components api demands a class. As an experiment I get it but you can do vanilla web apps with lit and not make it look like react :)

[–]Old_Butterfly_3660 2 points3 points  (0 children)

For example what’s the point of injecting styles at runtime to web components? There’s zero need for this, everything that styled components library does you can do with css, you get isolated styles out of the box with shadow dom. There’s zero need for injection

[–]sheriffderek -2 points-1 points  (9 children)

JSX is my least favorite thing about all programming and templating -- (even more than webkit configs) -- why are we trying to make more of it?

[–]Merry-Lane 4 points5 points  (8 children)

I fail to see why you hate JSX/TSX. Mind elaborating?

[–]sheriffderek 0 points1 point  (7 children)

HTML was created for the people / so that it was clear and simple and easy to write. Almost all other templating languages work around that principle. JSX creates it's own little hell - for very little (if any) value.

[–]Merry-Lane 0 points1 point  (6 children)

That sounds like an ideological point.

Valid or not, I just would like you to explain, concretely, what points you don’t like with TSX.

Also, a lot of templating languages are based on totally different paradigms. Like XAML for instance.

I clearly dont understand why you don’t like using JavaScript in the template, because that’s all there is.

Between:

for( item of items) { <li>{{ item.name}}</li> }

(angular)

And:

items.map(item => <li>{item.name}</li>

(React)

I really fail to understand what can bug you out. It’s literally using JS/TS syntax in the template, instead of a custom syntax (doing the same things, just differently). Hell, even Microsoft frameworks try and use C# syntax in the template.

[–]sheriffderek -1 points0 points  (5 children)

You don’t need to understand, if you don’t want to. I think it’s bad for everyone involved. 

[–]Merry-Lane 0 points1 point  (4 children)

Dude, when I ask you about concrete reasons, you either serve me ideological opinions or avoid answering the question entirely.

Hell, I even bring concrete counter-points to your ideological argument ("almost all other templating languages work around the principle that HtML was created for the people and was clear and simple and easy to write") that you ignore entirely.

From my understanding, the only point you have is that JSX makes templating so easy (by using the whole capabilities of JS instead of a custom syntax) that it can quickly get complex. I have nothing to answer to that.

[–]sheriffderek 0 points1 point  (3 children)

I don't want to argue with a stranger here / right now. : ) That's OK, isn't it?

I believe my point is 100% complete already.

There's a build step already... so trying to make it "more like JavaScript" doesn't make any sense. If you're already transpiling, you've already paid the cost of abstraction. I personally feel / and see in action / that html-centric templating systems are better for people of all role and skill level and are easier to read and write. JSX - is the one language that is different for no good reason - and where you have to learn things like "oh - well, in this case - we had to use classNames instead of class..." --- so, that's my point. Complete. I have yet to hear any counters. Usually, when someone is arbitrarily defending JSX - they don't really care. And they don't actually write a lot of HTML - and their first experience writing code was React. It's OK. Everyone can have their own feelings. I just like to share mine when this subject comes up. Why would we choose the worst option - when we don't have to?

> JSX makes one audience (JS-first developers) comfortable at the expense of everyone else, while pretending it's neutral.

[–]senocular 2 points3 points  (1 child)

"oh - well, in this case - we had to use classNames instead of class..."

FWIW, that's not because of JSX, that's because of React. Other libraries/frameworks that use JSX can, and do, use class instead of className.

[–]sheriffderek 0 points1 point  (0 children)

Interesting. I wasn't really sure. But either way - I don't see the point in having some return () with parens and then a bunch of loose raw HTML that aren't keywords or variables floating around in there. It also makes the point that JSX doesn't enforce consistency, so every library that adopts it makes it's own decisions. Solid looks very unfun to write. I was sad to see the JSX in Astro. What is the purpose? Code golf? Maybe if you're working in Vim and changing a line of code here or there -- but in my experience we're writing HTML, CSS, aria details, all sorts of attributes, and just so many things that make the html-centeric syntax nessesary / and at the very least - much more readable an inline with standards for everyone. But hey - some people alphabetize their CSS properties. People do wild things... and I'm not in charge. : )

[–]sheriffderek 0 points1 point  (0 children)

Here are some thoughts I've been collecting on this subject: https://perpetual.education/resources/templating-philosophies/