Live data from Hacker News

Imba – A new programming language for the web

imba.io

51–60 of 180 posts

Re: Imba – A new programming language for the web

#51
post #35

I have to admit I was really not excited to see this: var answer = if number == 42 The language looks shockingly pleasant in a number of ways, but everything being an expression seems odd. Would somebody mind helping me understand the value (semantic, performance, etc.) of such a choice?

CoffeeScript (which this is forked from) has some parts like this that I strongly dislike, such as using the unless keyword after an action. For example: doSomeThing() unless person.present For me that utterly destroys readability - in my mind, when I see a (), that function is being called there and then. The fact that you can invalidate that later in the line confuses me deeply - and it doesn't really provide any b…

The unless keyword is very useful for when you're testing an exit condition, e.g., return unless...

Re: Imba – A new programming language for the web

#52
post #33
post #17

Earlier quoted context omitted.

Imba was actually forked from CoffeeScript three years ago. After the fork there's been a bunch changes, both in terms of adding tags, but also when it comes to the object model and variable scope. - Implicit calling: `foo.bar` calls `foo.bar()` and `foo.bar = 123` calls `foo.setBar(123)` - Objects have instance variables that's separate from the methods. Well, technically the instance variable `@bar` is just stored…

- Implicit calling: `foo.bar` calls `foo.bar()` and `foo.bar = 123` calls `foo.setBar(123)` Wuhh. Why wouldn't you use JS defineProperty here?

There's one historic reason (it wasn't widely available when Imba was started). Another reason is performance: the last time we benchmarked this `defineProperty` was slower than regular function calls. Maybe it's improved now.

Semantically the biggest difference is that you don't need to do anything special for marking a method as a property:

    class List
      def length
        # …
In this case `list.length` just works. The disadvantage of this is that if you want to get the function itself, there's a separate syntax (`list:length`). Other than that, this is mostly about taste/style.

Re: Imba – A new programming language for the web

#53

Earlier quoted context omitted.

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

Hi. We actually do a different kind of diffing - which turns out to be substantially faster than React: http://somebee.github.io/todomvc-render-benchmark/index.html . The language has just been released, it is still very lacking when it comes to documentation. Working on it :)

Can you give some details about Imba's diffing?

Re: Imba – A new programming language for the web

#54
post #35

I have to admit I was really not excited to see this: var answer = if number == 42 The language looks shockingly pleasant in a number of ways, but everything being an expression seems odd. Would somebody mind helping me understand the value (semantic, performance, etc.) of such a choice?

CoffeeScript (which this is forked from) has some parts like this that I strongly dislike, such as using the unless keyword after an action. For example: doSomeThing() unless person.present For me that utterly destroys readability - in my mind, when I see a (), that function is being called there and then. The fact that you can invalidate that later in the line confuses me deeply - and it doesn't really provide any b…

That's not specific to 'unless' – it's the general postcondition style that's is derived from Ruby. Indeed, for single-line if statement bodies in Ruby, it's the recommended style.

It fits the style of Ruby to try and cut down on syntax noise where it's not needed. Contrast:

  save! if !record.persisted? && !record.invalid?
  save! unless record.persisted? || record.invalid?
Though I do appreciate it's a bit unusual compared with most other languages – CoffeeScript does owe a lot to Ruby's syntax.

Re: Imba – A new programming language for the web

#56
post #35

I have to admit I was really not excited to see this: var answer = if number == 42 The language looks shockingly pleasant in a number of ways, but everything being an expression seems odd. Would somebody mind helping me understand the value (semantic, performance, etc.) of such a choice?

CoffeeScript (which this is forked from) has some parts like this that I strongly dislike, such as using the unless keyword after an action. For example: doSomeThing() unless person.present For me that utterly destroys readability - in my mind, when I see a (), that function is being called there and then. The fact that you can invalidate that later in the line confuses me deeply - and it doesn't really provide any b…

Well just don't use the unless keyword then. I've used CS for years and I don't use it.

Re: Imba – A new programming language for the web

#57
post #43

Earlier quoted context omitted.

1. Because the semantics are quite different. See my other post. 2. It's still nice to separate the attributes from the content: "Foo" Why use a new syntax when everyone knows HTML/XML? 3. The lack of `var` in CoffeeScript is its worst feature ever IMO! Every time I write `someVariable = …` I'm terrified that I will accidentally overwrite a previous variable. Imba improves on JavaScript here and will correctly shadow…

People also know CSS query selectors... Some Text Might be nicer than actually spelling out the attributes and properties, if you're taking an already wrist friendly language and bolting on tags, then taking that a step farther would probably be a nice idea as well.

Imba supports the syntax for IDs and classes:

     "Label"
compiles to:

    ti$('label','foo').flag('bar').flag('baz',this.isBaz()).setText("Label").end()
where `flag` is a method which adds to the class list (unless the second argument is falsey).

Re: Imba – A new programming language for the web

#58

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 nic…

Mithril author here.

It does appear to have a React-like engine here: https://github.com/somebee/imba/blob/master/src/imba/dom.sta..., but from a quick glance, I can't tell if the quality of the engine is any good (e.g. whether it supports lifecycle methods, efficient sorts, jQuery plugins, etc) because there are no docs and I don't really have time to read the whole codebase right now. Same goes for the speed claim: can't tell if it's actual speed or "cheating" by batching multiple redraws on rAF while not batching them in the React demo. I'm guessing the latter.

Also, I'm not sure I agree with claim of readable output js: http://somebee.github.io/todomvc-render-benchmark/todomvc/im... (look at tag.prototype.render). It's not exactly clean, although it's not terrible either.

With that being said, the language does look like it has some improvements over Coffeescript. The lack of docs is a showstopper for me, however.

Re: Imba – A new programming language for the web

#59

I have to admit I was really not excited to see this: var answer = if number == 42 The language looks shockingly pleasant in a number of ways, but everything being an expression seems odd. Would somebody mind helping me understand the value (semantic, performance, etc.) of such a choice?

This comes directly from Ruby via Coffeescript.

It's aligned with a general approach of reducing syntax noise, and it can result in some really nice, clean code. It leads to a whole class of syntax possibilities, like implicit returns.

There are probably some performance arguments against this in the case of Coffeescript, especially wrt constructing expensive return values that are immediately discarded. The consistency is nice, however.

Re: Imba – A new programming language for the web

#60

This is good! Now take away all the unnecessary references to that pile of junk that is ruby and it'll be great.

This tool is forked from Coffeescript, which is deliberately designed to resemble Ruby. There's a good reason for that – some aspects of Ruby's syntax are well-loved.

It might be more effective for you to use your time understanding why these aspects are important, since you apparently feel this project is good, and less time being a bit of a dick about it.

Post reply on HN