Yep, Someone mentioned in another part of this thread that Vue compiles most of this out before production, so my remaning confusion pretty much stems from the DSL being a mishmash of html attribute context, vue custom syntax, and evaluated JS.
1,734 karma · joined March 10, 2021
Yep, Someone mentioned in another part of this thread that Vue compiles most of this out before production, so my remaning confusion pretty much stems from the DSL being a mishmash of html attribute context, vue custom syntax, and evaluated JS.
I guess my remaining alien issue is that the DSL for Vue is a mish-mash of JS, custom syntax, dom attribute context and possibly more?
To be clear, I vastly prefer Reacts approach of putting HTML into JS, rather than Vue/Angulars approach of putting JS into HTML.
v-for="x in console.log('hello world!') && fetch('/') && [1,2]"
(my syntax might be off since I don't use Vue, but the merit should still apply)My point is that when your templating language starts doing things like this (and inevitably, all of them do) - you've created a new programming language that is generally less thought out as one than deliberately made programming languages. Although the above for loop is evaluating JS, the syntax is decidedly not JS.
The lodash example is the main critique because that is not JS, but it involves evaluating JS - it's created its own programming language with its own rules -- when one was right there from the beginning!
This is the part I don't really follow, though. Technically:
<a href="print(1//3)"></a>
href here isn't a string, it's python, but it's stored as a string, representing python. In the :href example for JS, that's not JS - an engine isn't seeing that - that's a string that is evaluated as JS at some point in the vue lifecycle.Let's say we want to iterate over commits in reverse. A google shows that we can do something like this:
v-for="item in items | orderBy 'field' -1"
So, there's pipes now, and Vue has essentially re-invented a programming language inside HTML attributes. But then comes this example below it: v-for="item in _.reverse(items)"
And this line is terrifying! If this string is able to use lodash, then that means it's able to access the JS global scope, and therefore is very powerful - yet the resulting template is nonsense js, but still at some point involves JS evaluation?Maybe I'm missing something though - I don't use Vue and if something is this big with this approach, I'm definitely missing something.
EDIT: A search for *new Function(` calls in the vue github repository shows quite a lot of code that essentially evals strings.
The Github Commits[1] example on their documentation has a load of stuff that just doesn't sit right with me.
Things like
v-for="record in commits"
to loop over something is insane to me - this isn't code, this is a string inside a html attribute! How can you get any sort of good type analysis/variable checking/syntax highlighting inside this?Similarly, accessing properties like
:href="record.html_url"
has the exact same issues - what if there's a typo here? My IDE can't highlight that this is wrong because it's *not code* and is just a string.Maybe I'm just the odd one out here, but vue (and angular) love to use strings as a makeshift programming language, which to me is a major smell.
I always thought it was weird that npm didnt use a central store on your hard drive for your packages and instead just duplicated them everywhere, and i always thought it was even weirder that yarn didn't change this behaviour, but maybe i'm missing something.
.button {
background-color: $gray-100;
border: 1px $gray-200
/\* so on... \*/
}
i don't understand how these "micro" css classes actually help versus just setting the property.Isn't that just code?
I'm convinced that for sufficiently complex "no-code" solutions, you just end up with a poor mans programming language.
[1]: https://pnpm.io/
Whenever html attributes start containing logic is when the templating engine has just implemented its own programming language - poorly.
How? My understanding of it is that it's a JSON document that points to a URL (which is just some webserver 99% of the time).
How does this allow anyone to do anything novel that couldn't be done with a centralised database and an API?
And it depends on your definition of advertisement, I guess. A new version of $product coming out getting to the front page here is advertisement, but (in theory) organic, from people who are genuinely interested in $product.
If that's taken advantage of (like it is in reddit), then you can manufacture that organic "advertising".
From what other people in the thread are saying, it appears HN mods clamp down hard on this stuff, so it's probably not much of a concern here, but it's still interesting to see.
The website itself claims to be organic advertising, and it's certainly something that would work. This is actually used in practice on sides like Reddit[1].
[1] https://web.archive.org/web/20210126003211/https://upvotes.c... [2] https://web.archive.org/web/20210126003211/https://upvotes.c...
EDIT: looks like this hug-of-deathed the site, thats certainly one way to deal with this.
Is that really true? I can't think of much in terms of older nodeJS stuff that would break on modern node (and with N, you can just install an older version of node).
I do not understand why deno has gone for this route. It seems primed to produce a package manager eventually, and it seems like a bad idea to leave package manager creation down to whoever makes the first decent tool (which is mostly why npm is the standard for node.)
If something like that is needed, then I think deno should attempt to come with something for managing dependencies.
Eventually, developer convinience will win, and everyone will settle on some sort of package manager for deno. It'd probably be for the best if deno made it official as, personally, I think this is heading towards a second NPM.