Marko: An HTML-Based Language
markojs.com
markojs.com
People plug-in all sorts into python, why not `from microphp import tpl`, `tpl("blah.phtml")` etc.
<html..>
<? foreach($xs as $y): ?>
<? $y; ?>
<? endforeach; ?>
</html>But dedicated template languages have superior ergonomics these days, so why bother adapting PHP to it?
I've just used my own RYO CMS for 15+ years for website work... it's gone through lots of updates, but it's super simple. I'd never make it public as a framework because any decent dev should be able to roll their own anyway, and I don't need the aggravation. But it's basically a VERY simplified cross between {{handlebars}} and React, without attempting to bind the whole DOM to data, plus a DSL for specifying all the pages and modules of each website in SQL, and setting up english-language router rules.
I'd ditch ergonomics any day for understanding what's going on and being able to pare it down as much as possible. Simple website clients pay so little these days it's basically charity work... you need something you can both do in an hour AND never have to worry about WordPress updating.
Not surprising, but sad that Adobe flacks don't even know what it is. The world would be a lot more interesting if Macromedia was still a going concern, maybe aligned with Unity or some other ecosystem for game production.
I think I recall Flash did try to offer some type of iPhone app development features towards the end of it's useful life but Jobs effectively sentenced Flash to death so most everyone had jumped ship by this point.
I'd much rather use ColdFusion than Microsoft Power BI, if I had to choose. (MS-BI is probably a better fit for non-programmers.)
Is there anything that would out of the box: 1) do fully static server-side rendering that outputs zero JS by default, 2) still be capable of rendering client-side interactive components where appropriate (for user agents with JS), 3) have both of the above as equal first-class citizens without contrived workarounds needed to achieve either interactivity or SSR, 4) handle all required bundling/fetching at build stage and load fast at runtime, 5) be isomorphic and leverage TypeScript typings to validate the correctness of the whole thing at build time as much as possible, and ideally 6) allow easy reuse of preexisting React components?
"my use case doesn't need a JS framework so we don't need JS frameworks"
But I think the general principle applies, and you can even go further: try building simpler things. This is why I use static websites + a little JS and some API calls until I absolutely need my own server/SPA/etc.
I don't buy the isomorphic thingy that reduces cognitive load because that's not only it's not absolutely true, it could be false and brings other type of problems.
Also, this trope that "JavaScript can only render websites that require JavaScript to read" is a common misconception. Next.js, for example, is perfectly capable of rendering websites that work for clients with JavaScript disabled. In fact, that was kind of the original point of SSR: to make websites that search crawlers could read by processing the HTML sent from the server. The server renders the initial page, and then the client (optionally, if following best practices) "hydrates" the DOM to render any further content that requires client-side interaction (indeed, it's bad practice to require hydration, and a mismatch between server rendered DOM and hydrated DOM will generate warnings in development).
slim-lang + htmx or stimulusjs and a single dev can replace a team.
They provide some opinionated/convenient ways to author code but deliver fully server-side rendered HTML. They use fancy means to detect where interactivity is needed, and only ship JavaScript to the browser for those components.
In fact, they make what you describe easier to achieve. When you do it on your own, it’s up to you to ensure one piece JavaScript doesn’t mess another piece up, it’s up to you to sync back-end with front-end—but with a good framework you get encapsulation, bundling, and typing with compile-time checks (if you removed an attribute from some object server-side but forgot to update the client side, your build will fail with a useful error message before you can deploy it).
It definitely has not gained a lot of traction outside of ebay but there is a fair amount of buzz around the marko6 release with a completely new tags-based language.
It is also one of the few frameworks that leverage html streaming in a simple way (and has for a long time) and offers islands-style partial hydration out of the box.
<if(user.loggedOut)>
<a href="/login">Log in</a>
</if>
And that <ul>
<for|color, index| of=colors>
<li>${index}: ${color}</li>
</for>
</ul>
Looks scary. ${index} and ${color} require escaping, (user.loggedOut) requires parentheses and |color, index| requires pipes. I just don’t understand what is going on.What I like React for is that I can use JavaScript for things that seem to belong to JavaScript, like conditionals and loops. And components just have properties that may be dynamic and conditioned, in which case they obviously require JavaScript. But here the syntax breaks that separation of concerns IMO.
Anyway, I traced the JavaScript code. There are files packed with Webpack. They're not minified and pretty easy to follow. I even found a comment linking to https://github.com/gorhill/uBlock/issues/205 with the note "Do not handle added node directly from within mutation observer".
I run Marko on cloudflare pages for some of my clients and couldn’t be happier, it’s the perfect framework for people who like writing plain html, but still want the advantages of a UI library like react.
Not saying this is a bad thing. Svelte is universally loved.
But it does raise the obvious question of why not Svelte. (Or Solid or Astro or...)
I’d expect Qwik to be faster than any of the above, but it seems not quite production-ready enough.
[0] https://dev.to/this-is-learning/marko-for-sites-solid-for-ap...
[1] In the Reddit the author mentions that, despite focusing on Solid+Astro in the article, Marko is actually still more performant than those: https://www.reddit.com/r/javascript/comments/ubs6i9/marko_fo...
Hence this discrepancy is present
Same with HTML streaming. Marko has had it since 2014 and IIRC SvelteKit doesn't have it yet.
I absolutely love Svelte but if you need those features then Marko would be a better choice.
''' <tabcontainer> <tab> ... </tab> </tabcontainer> '''
So any markup technology these days needs that ability I think.
Then there's Content Security Policy to think of too.
Jokes aside, this does look pretty neat.
It looks like Marko v6 is going to perform incredibly fast, up there with vanilla javascript and solidjs, ahead of Vue, React, and Angular. https://dev.to/ryansolid/marko-compiling-fine-grained-reacti...
What's interesting is Marko and Solid are opposite in some ways: the first is HTML first, with sprinkles of interactivity; and the second is JavaScript first, in that it uses JavaScript and JSX primarily. Despite these opposite approaches, they are both iterating towards having very little runtime overhead.
Solid has definitely gained more traction recently and the syntax is close to react, but Marko is really closer to Solid + SolidStart, and the upcoming major version will bring resumability which only Qwik offers at the moment.
By definition, controllers must be imperative.
Would've been that better if you had some `increment(state)` that updated a ref anyway?
Very glad that we've got superb TypeScript datamodel, but jesus, it took a long time.
If you want a quick "why," give this a read [2].
[1] https://github.com/cheatcode/joystick
[2] https://github.com/cheatcode/joystick#what-distinguishes-joy...
"Trust me, this thing -- which is very new -- will be around forever".
The criticism is that it isn't React, and that nobody uses it but eBay.
There's nothing really wrong with it other than that there's no reason for it to exist when other frameworks work fine and have community traction. There's nothing special about eBay that requires it's own special UI framework.
And when we hire contractors to do anything they won't touch Marko so we have to use React anyway on a lot of projects.
Just not an efficient way to spend the companys money creating and maintaining a superfluous framework nobody asked for.
I am so tired of developers who are scared of learning new things.
What's the point of hiring contractors if they will show zero flexibility to work with your existing stack?
A consultant could make you reevaluate your stack (and that would be the point) but IMHO contractors should just focus on getting the job done.
Ebay is not your mom and pop e-commerce website.
If Ebay had used React the business would have suffered. That's why Amazon isn't using it either.
<h1>My favorite colors</h1>
<ul>
<cfloop item="color" list="red,green,blue">
<cfoutput>
<li style="color:#color#">
#ucase(color)#
</li>
</cfoutput>
</cfloop>
</ul>
<cf_SharedFooter/><!--- ColdFusion custom tag --->I wrote ColdFusion professionally for 7 years in the mid-'00s and I quite liked it back then. The issue, of course, was code organization and sprawl because you couldn't easily detach the logic from the view.
Still, <cfquery> blocks and <cfloop>s around the results were one of the fastest ways to get something up on a page and working, in the days before very mature frameworks existed yet.
It also forced everyone to know everything, so you could point to any dev on the team and they mostly understood the HTML, the CSS, the JS on the page, and the backend.
I think the industry trend toward specialization is useful in some cases, but it has made organizations and products almost intolerably complex in many cases where it isn't strictly necessary for the product itself.
I do find it interesting that client-side frameworks are "rediscovering" patterns from 25+ years ago :-)
https://news.ycombinator.com/item?id=15057371 (276 points | Aug 20, 2017 | 148 comments)
I can hear a million souls googling in unison for the "for" html elements in vain.
Logic and elements must be a separate syntax. When I see something between <>, that's an html elements.
In frontend engineering where there is a separation of logic and presentation you end up with flimsy, broken code. We used to write websites in html and then add some js that targeted specific elements and that was impossible to maintain.
Component based frameworks do away with all that because it doesn’t work. In react you’re mixing logic with your html too through jsx and this framework (and others like vue/svelte) go a step further and put everything related to a fragment of html in a single file.
This works really well, it means your styles don’t leak unless you want them to, your js usually only affects the html in the same file it’s written and you can build robust apps.