Live data from Hacker News

Marko – A declarative, HTML‑based language

markojs.com

101–110 of 189 posts

Re: Marko – A declarative, HTML‑based language

#101
post #57

Earlier quoted context omitted.

I mostly agree with you but React isn’t just JavaScript. JSX is not JavaScript. It’s just that we’re so used to it we don’t consider it notable any more. Worth keeping in mind when you’re looking at a brand new framework.

I mean, you’re technically correct. But you’re also not understanding the point. What people mean when they say “React is just JavaScript” is… 1) JSX, more than any other templating system, is just HTML interleaved with JavaScript. It’s HTML, and anything between { and } is evaluated as JavaScript. 2) Inserting a React component’s “HTML tag” in your JSX is _actually_ the same as calling the JavaScript function. The H…

It’s not JavaScript if you can’t make an html page locally and open it in your browser without things like an http server or need to transpile.

Re: Marko – A declarative, HTML‑based language

#102
post #57

Earlier quoted context omitted.

I mostly agree with you but React isn’t just JavaScript. JSX is not JavaScript. It’s just that we’re so used to it we don’t consider it notable any more. Worth keeping in mind when you’re looking at a brand new framework.

I mean, you’re technically correct. But you’re also not understanding the point. What people mean when they say “React is just JavaScript” is… 1) JSX, more than any other templating system, is just HTML interleaved with JavaScript. It’s HTML, and anything between { and } is evaluated as JavaScript. 2) Inserting a React component’s “HTML tag” in your JSX is _actually_ the same as calling the JavaScript function. The H…

> JSX, more than any other templating system, is just HTML interleaved with JavaScript. It’s HTML, and anything between { and } is evaluated as JavaScript.

That’s not true though and IMO is one of the weaknesses of JSX: it looks like something it is not. Having to use className instead of class is one of the most obvious tells. But in theory if it was just HTML with {}s I should be able to do:

    

    

    {stringContainingHTML}
and many other things you’re actually not able to do. Not to mention that things like onClick aren’t actually HTML attributes and are instead event listeners, etc etc.

Once you grasp that what you’re actually doing is a function call with an object of arguments it makes sense. But it isn’t HTML. It’s a chain of function calls.

We’re all really used to it so we don’t think about it a lot. But I always try to remind myself of that when I look at a new unfamiliar syntax.

(not to mention, your example isn’t correct! don’t map to Component(), it maps to previouslyUnknownFunction(Component()), which is another confusing factor)

Re: Marko – A declarative, HTML‑based language

#103
post #99

Earlier quoted context omitted.

Could you please try to be a bit more substantive with your comments? E.g., Why do you think JSX is the best? What limitations did you hit with those other template languages?

Most template languages can't do something like that: // data const numbered = true // or false const strings = ["a", "b", "c"] // render const items = strings.map(i => Item {i} ) if (numbered) return ( {items} ) else return ( {items} )

RippleJS is doing the same sort of thing, but better IMO

Re: Marko – A declarative, HTML‑based language

#104
post #56

It looks interesting and in a past life I probably would have tried it out but do you know why I like React? Because it's just JavaScript. This ` ` and ` ` syntax is awful.

In a past life we did try it... Marko has been around for years.

It started as a project at eBay and then got spun out to an open project around 2015

Re: Marko – A declarative, HTML‑based language

#105
post #57
post #56

It looks interesting and in a past life I probably would have tried it out but do you know why I like React? Because it's just JavaScript. This ` ` and ` ` syntax is awful.

I mostly agree with you but React isn’t just JavaScript. JSX is not JavaScript. It’s just that we’re so used to it we don’t consider it notable any more. Worth keeping in mind when you’re looking at a brand new framework.

It almost was JavaScript! ES4 was going to have something very similar to JSX tags. Well, an extension to ES4 called E4X

Re: Marko – A declarative, HTML‑based language

#108
post #57
post #56

It looks interesting and in a past life I probably would have tried it out but do you know why I like React? Because it's just JavaScript. This ` ` and ` ` syntax is awful.

I mostly agree with you but React isn’t just JavaScript. JSX is not JavaScript. It’s just that we’re so used to it we don’t consider it notable any more. Worth keeping in mind when you’re looking at a brand new framework.

It is thin syntax sugar.

  
is just

  jsx(MyComponent, { prop: value })
Libraries and apps can use JSX or JS syntax.
Post reply on HN