Live data from Hacker News

Imba – A new programming language for the web

imba.io

21–30 of 180 posts

Re: Imba – A new programming language for the web

#22
post #3

I don't think of react as a language, but rather a virtual DOM + JSX. This looks like a nice modern syntax which is both an ES6 focused minimal JS (removing unnecessary tokens) with HTML building included.

It's confusing they made a whole nice language that doesn't speak about react VDOM diffing which .. was the whole point right ?

Re: Imba – A new programming language for the web

#24
This isn't a competitor to react; its a competitor to ES6/typescript/coffeescript.

React is a template library, not a language.

JSX is a way to write templates, but that's not react, and its not what react does. It's just a shortcut to writing XML.

You could say this is a competitor to JSX, perhaps; but anything more is hyperbole.

People aren't using react and angular because they have a nice syntax, that's just nice, they use them because you can build applications with them.

How do you build ui components using imba? Use react? :P

Re: Imba – A new programming language for the web

#25
post #14

Disclaimer: I've been following the development of Imba while it's been a private project (for six years now). Lately I've been helping out fixing bugs and improving smaller parts of the language. Having tags as a proper part of the language is very nice. This just works in Imba: for event in @events if event:type == "like" elif event:type == "comment" In React I'd have to use `map` and refactor parts into variables.…

The React API would be much nicer if it could use Javascript generators.

Re: Imba – A new programming language for the web

#26
post #12

Thank you for not saying "transpile".

Yup. "Transpile" is "compile" for those who're too young to ever have worked with a compiled language.

I suppose the idea is that 'compile' implies a low-level target whereas 'transpile' suggests translating to another high-level language. I can see some sense in making this distinction.

Re: Imba – A new programming language for the web

#27
I actually think this looks really good, but 3 things:

1. Why differentiate it from CoffeeScript so much? Why not call it DOMCoffeeScript or something? Are there any core language changes from CoffeeScript other than the tag features?

2. I'm not sure how I feel about the mixture of XML tag characters with HAML/Jade-like indentation. My gut instinct is to always look for a closing tag with XML/HTML. Why not use some kind of sigil like % or @ or ! to represent a tag, since clearly the requirement for both a left and right caret is now obviated?

3. Why require the `var` keyword instead of making it the default? That's one of my biggest pet peeves with languages like Javascript and Lua. Local-by-default always makes the most sense.

Re: Imba – A new programming language for the web

#28

Is there more information about how the 'very efficient rendering' part works?

There's two parts of the "very efficient rendering":

1. It store the previous rendered tag and does a diff. (Just like React).

2. Every tag is compiled to JavaScript that's easy for the optimiser.

    tag event 
           "Hello world!"
Compiles to:

    // Setting up the tag-object. Then:
     tag.prototype.render = function() {
       return this
         .setChildren(Imba.static([
           (this.$a = this.$a || t$('h1').setBar("123")).setBaz(bar)
         ], 1))
         .setText("Hello world!")
         .synced()
    }
While React passes an object of props around, Imba will instead call setters. These setters are very easily inlined by modern browsers. Also note that it caches directly on the tag object itself which gives another additional boost. Since it caches the objects themselves it can also compare everything with `===` and/or `indexOf`.

The `Imba.static`-call marks an array as static which is a guarantee that the structure of the array won't change. In this case Imba will not do the full diff-algorithm, but instead compare each item element-by-element.

And yes, once you've achieved the minimal amount of DOM changes needed (like React), the next step for performance is all of these little tweaks. Does it matter? It all depends. Imba is capable of rendering bigger applications than React when you use the "render everything over again in the animation loop".

TLDR: The tags are more integrated into the language. The language is also designed around features that's easy for the optimiser.

Post reply on HN