Live data from Hacker News

Marko – A declarative, HTML‑based language

markojs.com

111–120 of 189 posts

Re: Marko – A declarative, HTML‑based language

#111
post #68

I didn't look deep into Marko yet, but in my opinion JSX is by far the best HTML template language there is. And it's not restricted to React. Most other template languages hits serious limitations really fast. I tried and hated (for non trivial things): Angular, Handlebars, Razor (dotnet) and Vue (which does support JSX optionally).

Have you ever given lit html a whirl?

Re: Marko – A declarative, HTML‑based language

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

Speaking of writing javascript instead of JSX, I'm a big fan of the hyperscript approach:

      var ListComponent = () => {
        let count = 0, selected = null
        return {
          view: ({attrs: {items}}) =>
            m("div", [
              m("p", "Clicked: " + count + " times"),
              m("ul", items.map(item =>
                m("li", {
                  onclick: () => { count++; selected = item },
                  style: {cursor: "pointer", color: item === selected ? "blue" : "black"}
                }, item)
              )),
              selected && m("p", "Selected: " + selected)
            ])
        }
      }

Re: Marko – A declarative, HTML‑based language

#115
post #114

Dear front end devs Please chill w making new languages and frameworks that re-solve solved problems. The internet is working fine as it is. Warmest regards, Matt

Matt,

Marko was created over a decade ago at Ebay.

One of its core dependencies is morphdom, which has been used successfully by a slew of frontend view libraries like Marko, including Phoenix LiveView.

Please chill. In general.

Use cases are not all equivalent.

Ignorance is boring.

Re: Marko – A declarative, HTML‑based language

#117
post #112
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.

Speaking of writing javascript instead of JSX, I'm a big fan of the hyperscript approach: var ListComponent = () => { let count = 0, selected = null return { view: ({attrs: {items}}) => m("div", [ m("p", "Clicked: " + count + " times"), m("ul", items.map(item => m("li", { onclick: () => { count++; selected = item }, style: {cursor: "pointer", color: item === selected ? "blue" : "black"} }, item) )), selected && m("p"…

This looks like what JSX compiles into. You can do the same (or similar) with React by using `React.createElement` instead of `m` (or just alias it) so you don't need JSX.

Re: Marko – A declarative, HTML‑based language

#118
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} )

Marko can! It's "define" tag lets you create reusable templates in your reusable templates.

https://markojs.com/docs/reference/core-tag#define

Re: Marko – A declarative, HTML‑based language

#119
post #37

Maybe just me but I actually think building web apps is already fun. I’ve got a hot reloading instant dev environment, I can publish to users in an instant… it’s great! Looking at the Marko examples I feel the same way I do whenever similar stuff gets showcased: it’s trying to focus too hard on brevity and/or cutesiness and doesn’t seem like it would scale well to a full, complex web app. But maybe it’s not supposed…

React has a clear separation of concern? Excuse me? I only see do-it-all pre-styled components in the real world.
Post reply on HN