Live data from Hacker News

Marko – A declarative, HTML‑based language

markojs.com

31–40 of 189 posts

Re: Marko – A declarative, HTML‑based language

#31

Today is ${new Date().toDateString()} Random number: ${Math.floor(Math.random() * 100)} Sorry, I don't like it. I already disliked that immensely in PHP. Not going back to that spaghetti mesh-up. The intro is also incorrect in my opinion. It writes a "HTML-based language", but this is more a hybrid of HTML and JavaScript. Why is JavaScript not mentioned in the intro?

  p “Today is {Date.today}”,
  p “Random number: {(^100).pick}”
Thought I would share this example as written in Raku using https://harcstack.org

Re: Marko – A declarative, HTML‑based language

#32
post #23

Today is ${new Date().toDateString()} Random number: ${Math.floor(Math.random() * 100)} Sorry, I don't like it. I already disliked that immensely in PHP. Not going back to that spaghetti mesh-up. The intro is also incorrect in my opinion. It writes a "HTML-based language", but this is more a hybrid of HTML and JavaScript. Why is JavaScript not mentioned in the intro?

Is there any significant difference between that and element.innerHTML=` Today is ${new Date().toDateString()} Random number: ${Math.floor(Math.random() * 100)} ` (ideally .setHTML() when it's available) At that point I think I'd have a skeleton html file that fetches a JS that does it all. I'd take JS with embedded HTML over HTML with embedded JS.

Isn't it wonderful that we live in a world where both ways can exist together, along with a myriad of other ideas for how to do the exact same thing?

Re: Marko – A declarative, HTML‑based language

#33

The problem when taking several languages and mixing them together this way is that the result is supposed to have brevity, but it’s actually unreadable. You need slash to mean something grammatical, colon has to say something, you can speak “open brace” in a way that anticipates; @ means “at”. This code looks more like a compression scheme.

I think I managed to combine three languages in one with Mint ( https://mint-lang.com/ ): 1. There is HTML (tags) with, but without interpolation {...} you can put string literals, variables and everything that type checks as HTML children. 2. There is CSS but only in style blocks where you can interpolate any expression you need and put in if and case expressions too. 3. There is the normal Mint code you write the l…

It's there a way to define routes in a nested, hierarchial fashion, preferably across multiple modules?

For example, with react-router, my root route object array I define by spreading out other route object arrays that I've imported from other modules in my project. And each of those do the same thing, recurring as necessary until I get to the full depth of my route tree.

Re: Marko – A declarative, HTML‑based language

#34

Earlier quoted context omitted.

Either solution sounds more verbose than the example and require writing code in at least one other source file

But they're both framework-agnostic. This snippet works with any framework and any build step. Today is Random number: I'll concede that Alpine.js is harder to understand and more verbose than Marko's syntax, but in order to use Marko you have to commit to the Marko framework. If you're willing to choose a framework solely for its JS-in-HTML capabilities, there are much better choices (like SvelteKit that handles JS-…

Fwiw, Marko predates svelte quiet significantly.

It was originally created by eBay iirc, back in 2014 or so.

It's syntax was even stranger back then, like writing "h1.myClass my header" to create a my header and similar

Re: Marko – A declarative, HTML‑based language

#35
post #23

Today is ${new Date().toDateString()} Random number: ${Math.floor(Math.random() * 100)} Sorry, I don't like it. I already disliked that immensely in PHP. Not going back to that spaghetti mesh-up. The intro is also incorrect in my opinion. It writes a "HTML-based language", but this is more a hybrid of HTML and JavaScript. Why is JavaScript not mentioned in the intro?

Is there any significant difference between that and element.innerHTML=` Today is ${new Date().toDateString()} Random number: ${Math.floor(Math.random() * 100)} ` (ideally .setHTML() when it's available) At that point I think I'd have a skeleton html file that fetches a JS that does it all. I'd take JS with embedded HTML over HTML with embedded JS.

No.

But you can write dreadful code in any language

Re: Marko – A declarative, HTML‑based language

#36
Honestly I don't know... I'm somewhat skeptical about these "next big thing that will fix all your pains in web development". There is so much fragmentation in JS libraries / frameworks. Angular, React, Vue, Svelte, Asto, SolidJS, NextJS, Nuxt, Qwik... The list is so overwhelming. Almost each one claims that it fixes a problem in other framework, and a year later the other framework fixes that issue... I think it's better to stick to a big old player, such as Angular.

Re: Marko – A declarative, HTML‑based language

#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 to and maybe that’s fine.

React and Svelte and the rest can read clunkily at times but they have a clear separation of concerns and I’m glad for that.

Re: Marko – A declarative, HTML‑based language

#38
post #36

Honestly I don't know... I'm somewhat skeptical about these "next big thing that will fix all your pains in web development". There is so much fragmentation in JS libraries / frameworks. Angular, React, Vue, Svelte, Asto, SolidJS, NextJS, Nuxt, Qwik... The list is so overwhelming. Almost each one claims that it fixes a problem in other framework, and a year later the other framework fixes that issue... I think it's b…

Honestly I don't know... I'm somewhat skeptical about these "next big thing that will fix all your pains in web development". There is so much fragmentation in JS libraries / frameworks. Angular, React, Vue, Angular, Asto, SolidJS, NextJS, Nuxt, Qwik... The list is so overwhelming. Almost each one claims that it fixes a problem in other framework, a year later the other framework fixes an issue... I think it's better to stick to a big old player, such as Svelte.

Re: Marko – A declarative, HTML‑based language

#39
post #32
post #23

Earlier quoted context omitted.

Is there any significant difference between that and element.innerHTML=` Today is ${new Date().toDateString()} Random number: ${Math.floor(Math.random() * 100)} ` (ideally .setHTML() when it's available) At that point I think I'd have a skeleton html file that fetches a JS that does it all. I'd take JS with embedded HTML over HTML with embedded JS.

Isn't it wonderful that we live in a world where both ways can exist together, along with a myriad of other ideas for how to do the exact same thing?

The point is that both ways contain the same "spaghetti" that the OP is complaining about and that it's unclear what alternative they actually prefer.
Post reply on HN