jeudi 10 novembre 2016

Higher abstraction for html

I would like to get some opinions from experienced web developers.

For me html+css is a very low level language/system/standard. It's not that low level like that you have to draw the rectangles and texts and shades your self, but it's like assembly language. You just create there blocks of content over and over againg. You cannot build structures, functions, some more complex stuff you can then reuse. There is just copy+paste, some templating engines, and that's all.

I wish there was an higher abstraction language that will be translated to html. (like C++ used to be converted to C before compiling to machine code). We don't have to write assembly nowadays, because we have higher languages that have compilers that do it for us.

I didn't create many websites (partially because I hate html/css/js), but sometimes I have to do it, and that was terrible. Mainly I create backend or desktop apps. If you use an gui library (like Qt or GTK+), there are some basic widgets to use and you can define "custom" widgets, that are combinations of the basic ones. Classes can be defined, eg an CRUDTable class, that will have an tableview + an panel with NEW/EDIT/DELETE buttons and every time you create an instance from this class you have all this things there.

But in html I cannot define some complex structs, or embedding/inheritance. Maybe it is good, the web is an open platform and html isn't designed to be THE language you must use to create the web content (like no one is now writing machine code anymore and it isn't for the humans to write, we have higher level languages that are compiled to it). So technically we can choose in which language we create the website and then "compile" it to html.

But why people still writing straight html? The browsers must be ready for parsing crappy html (like when you don't close the html tag, or use elements elsewhere than they meant to be), because the html isn't written by machines, but humans. Imagine that the computer has to run crappy machine code and before running, it must think about how to interpret that code and what the programmer meant with this ...

I have started an little project by my self that compiles an new language to html (but ended it very soon). The language was inspired by QML and Go/Golang.

a ruff idea is like this:

package main

//Definition of a class, it inherits from base/builtin elements
MainSite:div {
    //the attributes of the element
    attr {
        id: main_div
    }
    //css
    style {
        width: 800
        hight: 600
        color: blue
    }
    //children
    img {
        attr {
            src="img.png"
        }
    }
    button {
         //InnerTEXT
         text: "meh"
    }
}

the classes can be inherited or reused later and you don't have to write it again. the attribute values were also declaratively set, so that when you write width: 10 + another_div.width your width will be changed also with the width of the another_div.

This is just an idea, but I think we deserve some higher languages (many to choose from) to create the web.

Did some of you think about something similar? Is there some higher level language that is compled to html? What do you think about this?




Aucun commentaire:

Enregistrer un commentaire