Imba v2 Alpha - a New Age
Tags: imba, javascript, ruby
Published: 2020-01-06 15:12:47

All of the Imba v2 alpha changes just got merged into the master branch 😋 @somebee has been hard at work at the end of 2019 to get a new version of Imba out. Exciting times are ahead with lots of improvements to the developer experience 🛠

With change comes some disruption and there will be a few breaking things. The v2 version has not been officially released yet, but you can install the latest build with

`yarn add imba@pre # npm install imba@pre`

There is also an example project available at 

{% github imba/imba2-hello-world %}


Imba will see more changes before the actual release happens. Bugs are also expected but this is a great way to start of 2020. If you are interested in seeing all of the changes there are more than 230+ commits in the [pull request](https://github.com/imba/imba/pull/258). I have extracted the description below for your convenience :wink:

---
We've been working on version 2 of imba for some time. To speed up the process we've decided to move development to master and actively encourage new users to start with v2, despite the fact that it is not _quite_ ready for primetime.

We will write more extensively about the changes in the coming weeks before the official launch, but v2 includes a huge number of changes. The breaking changes will make migration from v1 very painful (until
migration tools are in place).

The reasoning behind all these changes will be discussed in the Imba Changelog casts on scrimba.com in the upcoming weeks.

## Improvements

- Future-oriented syntax changes
    - Template strings
    - Object destructuring
    - Decorators
    - Iterators (for of)
    - Class fields
    - Private class fields
    - ES6 classes
    - ESM import/export
- Tag improvements
    - Support for slots
    - Support for fragments
    - Compiles to native web components
    - Consistent and performant mount/unmount
    - Dynamically named tags `<{object.type}>`
    - Functional tag components
    - Memoization everywhere
    - Improved event handling with modifiers++
    - **Insane** performance (details to come :P)
- Much smaller standard library

## Breaking changes

- Implicit self removed - use `self.identifier` or `@identifier`
- Implicit calling removed - use `()` to call methods without arguments
- Removed prop syntax - see new class field syntax and behavior
- Symbols `:symbol` are deprecated - use strings instead.
- Keyed tags are now set using $key=mykey instead of @{mykey}
- Use `def constructor` instead of `def initialize`
- Use spread `...` syntax instead of splats `*`
- Use `static def method` instead of `def self.method`
- Class bodies are no longer executable

## Current limitations (to be rectified)

- Limited support for extending native tags
- No support for extending svg tags
- No support for server-side rendering
- Custom tags must be lowercase and include dashes
- Tooling even worse than with v1
- Advanced tag loops with multiple children are flaky
- Cannot define event listeners as methods like `def onclick`
- Touch support (`ontouchstart/update/end`) removed (to be replaced)

{% github https://github.com/imba/imba/pull/258 %}