All Projects → tailhook → khufu

tailhook / khufu

Licence: other
A template language for incremental-dom or DSL for javascript views

Programming Languages

javascript
184084 projects - #8 most used programming language
Vim Script
2826 projects

Projects that are alternatives of or similar to khufu

Splain
small parser to create more interesting language/sentences
Stars: ✭ 15 (-21.05%)
Mutual labels:  template-language
nolimix86
LLVM-based x86 emulator with support for unlimited virtual registers, used before the register allocation pass
Stars: ✭ 19 (+0%)
Mutual labels:  virtual-machine
PhantasmaChain
Blockchain with native storage and smart contract integration.
Stars: ✭ 74 (+289.47%)
Mutual labels:  virtual-machine
jaws
Jaws is an invisible programming language! Inject invisible code into other languages and files! Created for security research -- see blog post
Stars: ✭ 204 (+973.68%)
Mutual labels:  virtual-machine
hematita
A memory safe Lua interpreter
Stars: ✭ 118 (+521.05%)
Mutual labels:  virtual-machine
Lubuntu-VirtualBox
Lubuntu Bionic 18.04.5 Minimal and Full virtual machines. VirtualBox OVA files less than 400 MB and 1GB respectively
Stars: ✭ 25 (+31.58%)
Mutual labels:  virtual-machine
RVM
Rcore Virtual Machine
Stars: ✭ 59 (+210.53%)
Mutual labels:  virtual-machine
Breath OS
An OS for breathing? My DIY OS
Stars: ✭ 17 (-10.53%)
Mutual labels:  virtual-machine
ModSecurityCRS
Implementation of ModSecurity, Core Rule Set (CRS) on Apache server. ModSecurity, sometimes called Modsec, is an open-source web application firewall. ModSecurity was installed and configured on an Ubuntu VM using Virtual Box
Stars: ✭ 24 (+26.32%)
Mutual labels:  virtual-machine
lust
A parser, compiler, and virtual machine evaluator for a minimal subset of Lua; written from scratch in Rust.
Stars: ✭ 120 (+531.58%)
Mutual labels:  virtual-machine
X11Basic
X11-Basic BASIC programming language.
Stars: ✭ 42 (+121.05%)
Mutual labels:  virtual-machine
sourcery-templates
Building Vapor projects using meta programming with Sourcery ✨
Stars: ✭ 24 (+26.32%)
Mutual labels:  template-language
birsh
virsh replacement in bash
Stars: ✭ 14 (-26.32%)
Mutual labels:  virtual-machine
vein
🔮⚡️Vein is an open source high-level strictly-typed programming language with a standalone OS, arm and quantum computing support.
Stars: ✭ 31 (+63.16%)
Mutual labels:  virtual-machine
virtnbdbackup
Backup utiliy for Libvirt / qemu / kvm supporting incremental and differencial backups.
Stars: ✭ 62 (+226.32%)
Mutual labels:  virtual-machine
vm-automation
VirtualBox automation using Python
Stars: ✭ 1 (-94.74%)
Mutual labels:  virtual-machine
Windows-11-VPS
😎😘 Free Windows 11 VPS for 4 Hours ! Easy Method!
Stars: ✭ 70 (+268.42%)
Mutual labels:  virtual-machine
Zen
Zen is a general purpose programming language designed to build simple, reliable and efficient programs.
Stars: ✭ 24 (+26.32%)
Mutual labels:  virtual-machine
tsharkVM
tshark + ELK analytics virtual machine
Stars: ✭ 51 (+168.42%)
Mutual labels:  virtual-machine
azure-vm-pricing
Mass-pricing of VMs on Azure based on CPU cores count and memory.
Stars: ✭ 14 (-26.32%)
Mutual labels:  virtual-machine

Khufu

Documentation http://tailhook.github.io/khufu/
Demo http://tailhook.github.io/khufu/demo.html
Status beta ¹

At a glance, Khufu is a template-engine for incremental-dom.

But more characteristically I call it is a domain-specific language (DSL) for view-driven single-page applications.

The boring list of features:

  • Nice, compact, indentation-based syntax, designed for readability
  • Rich-enough subset of javascript is allowed right in the template
  • Styles in the same file as view (HTML), properly namespaced
  • Avoids separate code to compose redux stores (kinda auto-generates it)
  • Supports webpack hot module replacement (aka hot reload)

[1] More verbose status: I feel that the language itself (the syntax) is 90% complete (thanks to it's predecessor). There are ugly edge cases of the compiler here and there. And the server-side render is not implemented yet. Otherwise, the project is small enough to just work.

Installation

npm install [email protected] --save-dev
npm install [email protected] --save

Why?

  1. JSX is ugly. Mixing javascript and HTML is ugly
  2. Conversely, I want to mix CSS with HTML and enough dynamic features ²
  3. I'm tired of composing views and stores independently ³

[2] Indentation-based syntax is a bonus.
[3] Sure, the model proposed here doesn't work for everyone.

So What Is It?

It's mostly a DSL around HTML, that looks a lot like just a template language similar to Jade, that compiles into Incremental DOM. Additionally Khufu:

  1. Reuses incremental dom diffing algorithm to diff redux or flux-like stores
  2. Allows to write styles in the same file which are properly namespaced without long ugly prefixed like in BEM

So What is "View-Driven"?

It means when you design an application you build a single powerful view. And all server-side data are fetched when a user enters some subview and is disposed when user leaves the view (of course, data can be prefetched and cached, but that's optimization orthogonal to what we're discussing here).

For example:

    import {search, set_query} from 'myapp/search'
    import {image, load} from 'myapp/util/image_loading'
    import {select} from 'myapp/action_creators'

    view main():
      <div>
        store @results = search
        <form>
          <input type="text" placeholder="search">
            link {change, keyup} set_query(this.value) -> @results

        if @results.current_text:
          if @results.loading:
            <div.loading>
              "Loading..."
          else:
            <div.results>
            for item of @results.items:
              <div.result>
                store @icon_loaded = image | load(item.img)
                if @icon_loaded.done:
                    <img src=item.img>
                else:
                    <div.icon-loading>
                <div.title>
                    item.title

This example displays a search box. When some search query is typed into the input box, search request is sent to the server immediately. This displays "Loading..." stub and replaces the stub with the results when they are loaded from a server. There is also the code to download images asynchronously.

Some explanations:

  1. Nesting of elements is denoted by indentation, hence no closing tags
  2. div.cls is shortcut for <div class="cls">
  3. store denotes a redux store
  4. link allows to bind events to an action (or an action creator)

The store thing might need a more comprehensive explanation:

  1. Stores are lexically scoped
  2. More so, on each loop iteration we get new scope
  3. Diffing algorithm of incremental-dom drops unused stores automatically
  4. They provide lifecycle hooks, so can dispose resources properly
  5. Store is prefixed by @ to get nice property access syntax

[4] Sure, you can delay requests by adding RxJS or redux-saga or any other middleware to the store
[5] Yes, we attach resources (such as network requests) to stores, using middleware
[6] Otherwise would need to call getState() each time. We also cache the result of the method for subsequent attribute access

Isn't it Like Good Old HTML?

Right. You do a Khufu view, add events and everything works. Just like you have been doing HTML page and add jQuery plugins to make that work.

There are few crucial improvements, however:

  1. All your variables are properly namespaced (and styles too). So there is no global identifiers which prevent composing and reusing things
  2. This plays well with javascript module system (every template is a module, imports work, and so on)
  3. The updates of fragments are much better using virtual DOM

You can also think of each view function being a component similar to what you find in react or angular. Have I said that syntax is much more readable?

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].