Hacker News new | ask | show | jobs
by lilactown 3202 days ago
What's natural about them? Controlling behavior through attributes is one of the silliest ideas invented, IMO.

I've used Angular - frankly, its template syntax is horrendous. I had to learn a ton of new semantics (`whatever` `(whatever)` `[whatever]` `#whatever` all have different execution contexts), and ultimately they've re-implemented most of JavaScript and* Angular inside of this HTML template syntax. Vue is about the same AFAICT. There's a lot of good in these frameworks, but templates is not one of them.

I don't understand your comparison to Assembler. How is this more like Assembly than a high level language?

React:

    return (
      <div>
        <button onClick={onSave} />
        {heroes.map(hero =>
          <button onClick={deleteHero(hero)}>{hero.name}</button>)}
        <form onSubmit={onSubmit}> ... </form>
      </div>
    );
Angular template:

    <button (click)="onSave($event)">Save</button>
    <button *ngFor="let hero of heroes" 
    (click)="deleteHero(hero)">{{hero.name}}</button> 
    <form #heroForm (ngSubmit)="onSubmit(heroForm)"> ... 
    </form>
Think of it like this: in templates, you write a string that will be tokenized and compiled into an AST, which then get interpreted by the host language. In React (or whatever other vdom-building library you want to use), you generate the AST using functions in the host language. This is simpler, more powerful, AND (in this day and age) easier to use.

Here's something neat about the React example, too: since it's a pure function, it can easily be unit tested without rendering to a DOM or doing some weird string stuff.