News for hackers. Stuff that matters.
Re:Imba – A new programming language for the web by creamyhorror on Thursday August 20, 2015 @02:39PM (#10093762)
I find the structure of an Imba app rather intriguing; the view+rendering (i.e. tags) almost looks like an upgraded HTML/HAML (possibly akin to EnyoJS).

http://imba.io/#/examples/todomvc/app.imba (this annotated app is illuminating, and ought to be put upfront on your site if possible)

The methods are clean and readable:

  tag #app

    def dirty
	      persist
	      render

    def add title
	      if title.trim
	        TodoList.push(TodoItem.new(title.trim))
	        dirty
	      self
And the view+rendering (literally the whole "upgraded-HTML" of the app) is so compact:

    def render
		var all    = TodoList
		var active = all.filter do |todo| !todo.completed
		var done   = all.filter do |todo| todo.completed

		var items  = {'#/completed': done, '#/active': active}[hash] or all		

		<self>
			<header.header>
				<h1> "todos"
				<new-todo-input.new-todo type='text' placeholder='What needs to be done?'>

			if all:length > 0
				<section.main>
					<input.toggle-all type='checkbox' :change='toggleAll'>
					<ul.todo-list>
						for todo in items
							<li[todo]@{todo.id} .completed=(todo.completed) .editing=(todo.editing) >
								<div.view>
									<label :dblclick=['edit',todo]> todo.title
									<input.toggle type='checkbox' :change=['toggle',todo] checked=(todo.completed)>
									<button.destroy :tap=['drop',todo]>

								<edit-todo[todo].edit type='text'>

  ($$(.todoapp) or $$(body)).append #app

I'd enjoy being able to code a SPA like this, I think - nice work! If something this clean is already possible in some other language/framework/library, I'd love to hear about it (since I haven't been following recent JS developments closely).

edit: @judofyr, the Scroller example app doesn't work for me on Firefox 40.0.2 on Win 8. It works in Chrome.

Re:Imba – A new programming language for the web by gosukiwi on Thursday August 20, 2015 @02:52PM (#10093855)
How does it handle data binding?
Re:Imba – A new programming language for the web by creamyhorror on Thursday August 20, 2015 @03:03PM (#10093924)
It looks similar to React's one-way data flow - that render method produces the whole app view, and refers to all the necessary variables. When an event occurs [e.g. the user types text to add and hits enter]:

- the appropriate method is called [e.g. add]

- which mutates the state [e.g. TodoList.push(TodoItem.new(title.trim))]

- and then render is called, which updates the view/DOM

So in a sense it's not really data-binding, IMO - instead, the render method contains the entire view + view logic, and it gets called each time the state is changed.