Live data from Hacker News

Imba – A new programming language for the web

imba.io

11–20 of 180 posts

Re: Imba – A new programming language for the web

#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. I've been struggling to use React on teams with designers because small design changes can cause rather huge changes in how the code is structured.

Other than that you can think about it as indentation based JavaScript with implicit method calling (`foo.bar = 123` calls the setter `setBar`) and saner handling of `this`.

Re: Imba – A new programming language for the web

#17
post #6

"if Ruby and React had an indentation based lovechild, what would it look like?" Let me guess!... CoffeeScript?

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 as a property with name `_bar` on the object.

- Variables must be declared with `var` and they correctly shadow previously defined variables.

- `do` provides a syntax sugar for the pattern "function as the last argument"

- Optional arguments work together with block parameters

    def timeout(amount = 0, &cb)
      cb(amount)
Compiles to:

    function timeout(amount,cb)
      if(cb==undefined && typeof amount == 'function') cb = amount,amount = 0;
      return cb(amount);
    };
- `self` is a keyword which is a saner `this`, and instance variables are automatically looked up using `self`:

    def end
      @client.on("end") do
         @server.end
Compiles to:

    function end(){
      var self=this;
      return this._client.on("end",function() {
        return self._server.end();
      });
    };

Re: Imba – A new programming language for the web

#18
As someone who has been developing using Javascript for 10 years and has seen many frameworks comes and go (including authoring one), this looks refreshingly good on first impressions. Far better than coffeescript or React. Congrats!

Plus, I love the fact that the syntax looks Pythonic :)

Re: Imba – A new programming language for the web

#20
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.…

I would really like to see React do something like this as a shortcut to having to do map. It would be SO helpful.
Post reply on HN