Imba

The friendly full-stack language

README





Imba

Join the chat at https://discord.gg/mkcbkRw install size Downloads PRs Welcome License

Imba is a friendly full-stack programming language for the web that compiles to performant JavaScript.
It has language-level support for defining, extending, subclassing, instantiating and rendering DOM nodes.


Get started


  1. ```sh
  2. npx imba create
  3. ```

Documentation


To get started with Imba, we recommend reading through the official guide.

Why Imba?


Minimal syntax


Imba's syntax is minimal, beautiful, and packed with clever features. It combines logic, markup and styling in a powerful way. Fewer keystrokes and less switching files mean you'll be able to build things fast.

  1. ```imba
  2. import './util/reset.css'

  3. global css html,body m:0 p:0 w:100% h:100%

  4. tag login-form < form

  5. css input rd:md bc:gray3 h:20px fs:md
  6. css button rd:md c:white bg:gray4 @hover:blue4

  7. <self @submit.prevent=api.login(name,secret)>
  8.   <input.username type='text' bind=name>
  9.   <input.password type='password' bind=secret>
  10.   <button> "Login as {name}"

  11. imba.mount <login-form[pos:abs d:grid ja:center]>
  12. ```

Runs on both server and client


Imba powers both the frontend and the backend of Scrimba.com, our learning platform with 100K+ monthly active users. On the frontend, Imba replaces e.g., Vue or React, and on the backend, it works with the Node ecosystem (e.g., npm).

  1. ```imba
  2. import express from 'express'
  3. import services from './services.ts'
  4. import html from './index.html'
  5. import image from './confused-cat.png'

  6. const app = express!

  7. app.get '/404' do (req,res)
  8. res.send String <html> <body>
  9.   <img src=image>
  10.   <h1> "We could not find this page!"

  11. app.get '/' do (req,res)
  12. res.send html.body
  13. ```

Integrated styling


Inspired by Tailwind, Imba brings styles directly into your code. Styles can be scoped to files, components, and even parts of your tag trees. Style modifiers like @hover, @lg, @landscape and @dark can be used for extremely concise yet powerful styling.

  1. ```imba
  2. # global styles
  3. global css button
  4. position: relative
  5. display: block
  6. background: #b2f5ea
  7. @hover background: #b2f9ea

  8. # tailwind-inspired shorthands
  9. global css button
  10. pos:relative d:block bg:blue5 bg@hover:blue6

  11. tag App
  12. # scoped styles
  13. css item bg:blue4 m:2

  14. <self[d:grid pos:relative]> # inline styles
  15.   <ul> for {type,title} in items
  16.    <li.item is-{type}> title
  17. ```

Blazing fast, Zero config


Imba comes with a built-in bundler based on the blazing fast esbuild. Import stylesheets, images, typescript, html, workers and more without any configuration. Bundling is so fast that there is no difference between production and development mode - it all happens on-demand.

  1. ```imba
  2. # importing a worker
  3. const worker = import.worker './analyzer'
  4. const analyzer = new Worker(worker.url)
  5. # import an image
  6. const logo = import './images/logo.png'
  7. console.log "logo size: {logo.width}x{logo.height} - at {logo.url}"
  8. ```

When you run your app with the imba command, it automatically bundles and compiles your imba code, along with typescript, css and many other file types. It provides automatic reloading of both the server and client.

Typing and tooling


The tooling is implemented as a typescript server plugin giving us great intellisense, diagnostics, and even cross-file refactorings that works with js/ts files in the same project. You can import types just like in typescript, and annotate variables, parameters and expressions. Like the language, the tooling is still in alpha, but improving every day.

  1. ```imba
  2. import type { CookieOptions } from 'express-serve-static-core'

  3. def flash res\Response, body\string, settings = {}
  4. let options\CookieOptions = {
  5.   ...settings
  6.   maxAge: 86400
  7.   secure: true
  8.   httpOnly: false
  9. }

  10. res.cookie('flash',body,options)
  11. ```

Community


For questions and support, please use our community chat on

License



Copyright (c) 2015-present, Sindre Aarsaether