views:

260

answers:

8
+1  Q: 

HTML and Compilers

This question is a more discussion oriented one that a simple problem specific question. Writing basic HTML is simple but writing fast light standards based, SEO best practices complaint, all browsers compatible HTML pages is hard and very time consuming.

But why it hard ?

In my opinion it hard because of the hundreds of different rules what need to be followed, rules what are hard to remember and even if you remember it hard to merge them together in not contradicting form and the only way to validate you work is by loading it in every browsers you support and validating every scenario.

But it really looks like a problem we had in the past in other areas of programming, previously before inventions of high level languages writing program in assembly is looks a lot like writing HTML files, you was forced to remember hundred of different rules for performance, correctness security and so on and the only way to validate them was by executing the program.

In other fields this problem was solved by compilers of high level languages what make a syntax simpler, make performance optimizations, check program syntactic correction before execution.

Don’t you think we need a different simpler language for writing web pages and compiler what could produce browser specific, standard complaint size optimized HTML from this language ?

Do you think it possible to create such languge and compiler ?

+3  A: 

What you are describing is a domain-specific language to describe HTML pages.

John Saunders
Yes it is a domain specific language, but do you know if this is something that was tried already, and do you think such domain specific language could help?
MichaelT
I started to edit my answer, but I think the DSL may already exist - it's called "HTML".
John Saunders
HTML is the most productive thing we can achive ?
MichaelT
In general, yes. In more specific circumstances, I think we can do better. But HTML is very general and describes a very large variety of pages. I have the feeling (just a feeling, no math behind it) that such a DSL would be equivalent to HTML - one to one mapping.
John Saunders
A: 

The whole browser compatibility issues and its ramifications are tied to wars between companies, which by all chances doesnt give any shtick to the developer's pain because its all money and market share for them.

Its not easy to move away from it easily by corporate users and non-tech users.

Pradeep
+5  A: 

Personally, I believe that with a decent amount of preparation, there is very little difference in writing 'basic' HTML and standards compliant HTML. Even starting from scratch, I don't think it's any harder.

Similarly, once you've developed a few sites, any rules regarding validation, etc will become second nature

dxbmatt
Did you know what exactly same thing was said by assembly programmers ? :)
MichaelT
I really struggle to see any comparison between HTML and assembly. HTML is a markup language - it only describes how a page/document should appear. Any performance issues that could be directly related to the HTML are performance issues in the rendering of the content. In the case of browsers, this is down to the specific rendering engine.
dxbmatt
First of all rendering performance affected by size of the DOM smaller html document will render faster , it something compiler could optimize for to produce most compact form of HTML from user markup that it self don't nesesery need to be compact it self. Also compiler reside on a server it could produce version of HTML what is best for some particalar version of the browser
MichaelT
@dxbmatt: HTML doesn't define how a document should appear, that's CSS. HTML defines what the document *means*. (That's kind of the most important rule to keep in mind when trying to write standards-compliant HTML.)
Ms2ger
A: 

With all due respect I am under the impression that you are comparing apples and oranges. Why? You are stating that modern programming languages take the burden of writing good code from the developer (by applying optimizations). IMHO, this statement is not quite correct: No optimizing compiler can compensate for a developer implementing an O(n²) algorithm where an O(n) implementation would have also been possible.

Back to your original question: I understand your need to build standards-compliant cross-browser web applications with less effort than is needed today. Probably somebody will (or already has) come up with a meta-language, which abstracts some of the complexity of writing HTML, but on the other hand this is already possible today with many of the template frameworks / CMS available. Of course, you still have to create the blueprint of your web site in HTML once so that it can later be used as a template, but that's something a meta-langauge also will not allow you to get rid of (even modern compilers make use of hand-crafted assembly language in some areas).

tg
Sorry but i did not get why HTML and assembly compilers are different ? Compilers don't change algorithms this correct but they do help you optimize code by following best practice rules what usaly hand writen. Optimizing HTML is more like method inlining and placing variables into registers instead of main memory and not like algorithm selection.What is a best solution for this problem from the ones available ?
MichaelT
+6  A: 

There is some confusion about, I fear. The fact of the matter is that writing good HTML is easy. Very easy. Writing bad HTML is also very easy, but that's neither here nor there.

What is difficult, I think you'll find, is writing good, cross-browser, beautifully rendered CSS. Very difficult, in fact.

And no amount of abstraction will solve that. Only efforts to improve all browsers will help this; and that is no small feat.

Another issue, and this is a bigger one, is that recently HTML is being abused for things it was never meant for; applications that would benefit greatly from being implemented as "proper" desktop applications are being implemented in HTML and JavaScript because it is "easier" for developers on some level (which, as your post highlights, is a filthy rotten lie).

Compatibility issues cannot be defeated easily; and by implementing things on the wrong "platform" you are setting yourself up to fail. Miserably.

The web is not a platform; it's a tangled weave of danger and despair. And, of course, tubes.

Williham Totland
The 90s called, they want their mindset back
micmcg
We can't solve browser inconsistences, but it possible to make the procces of fixing your HTML/CSS to compensate for them automatic
MichaelT
Well, yes and no. Unfortunately, browser vendors keep finding new and exciting ways of being inconsistent.
Williham Totland
+2  A: 

Let's answer this in a way that's fair to what you want, but respects the ubiquity of HTML.

If what you wish is a high-level language for HTML, they already exist. Any good wiki system has a simplified syntax that abstracts away the "<html><head>...</head><body>...</body></html>" plumbing from the user. This is what PHP was made to do, and most popular blogging and wiki systems use it.

A separate problem entangled in your complaint is that a markup language (HTML) is used as an intermediary in the transmission from application (server) to renderer (client). The intent of the application may be lost, because markup is not code but rather a document description language.

What you propose is a method for the web application to direct its execution on the client-side. There are a lot of historical arguments against this -- freedom of browser/platform choice, need for a standard, privacy/security concerns, and possibly breaking MVC by agglomerating code as the transmission interface.

There is work being done in this area however. Look at XUL, which seeks to solve the problem on Mozilla browsers; also Prism, which is a very early applications framework. Also look at Google's GWT or NaCl, which facilitate the safe integration of "native" code on the web. The problem with all of these imho is that they assign work to the client. My belief is that the only good way to safely have true client-server interaction is either 1) a trusted cloud mediator or 2) virtualization.

Overflown
In theory, GWT provides a means for write-once, run anywhere app development where your original Java code is compiled to the best available, most compatible javascript possible on demand.
Overflown
WIKI language is not exactly what I am after, in wiki language you can produce only wiki articles it very spefic to one purpose I would like to have something what is much more general purpose, I also don't want to transfer any logic to the client I want browser to recive just plain HTML , it just be the beter cleaner HTML.
MichaelT
A: 

The real problem isn't with writing standars-compliant HTML. The problem is that HTML+CSS is an extremely complex system without a reference implementation, which makes the standard essentially worthless since you can't test against it.

Yeah, you can test your HTML and CSS for syntactic correctness, but unlike programming languages, the rules for what effect a syntactically correct program will have are not unequivocal. The actual rendering rules are subject to interpretation, and so it's guaranteed that there will be browser incompatibilities for the foreseeable future. To cite Joel:

you’re pretending that there’s one standard, but since nobody has a way to test against the standard, it’s not a real standard: it’s a platonic ideal and a set of misinterpretations

Michael Borgwardt
I don't want just to produce standart complient HTML. I want compiler that is aware of all browser specific quirks and produce HTML that is correctly displayed in all browsers this a tedius part in HTML production and what that could be automated.
MichaelT
No, it could not be. You'd have to define a meta-language that desribes webpages and a it and the "compilers" that converts it to HTML would suffer from exactly the same problems that currently HTML and browsers suffer - with the additional complication of a nextra layer that makes debugging harder, and which is necessarily always out of date in catching up with browser quirks.
Michael Borgwardt
I am sorry but I probably missing something in you post, the problem with current state of HTML is what standard is not implemented equally in all browsers, but people are capable to produce HTML what is viewed correctly in all browsers relevant to them, they do it by using accumulated knowledge about different browsers behavior. Why we can't take this knowledge and make a automatic compiler from it ? I see it as following flow meta-language = > Compiler => quirksAwareHTML , why it will encounter the same problems ?
MichaelT
Apart from debugging and the catching-up-with-browser quirks problem: the HTML/CSS standard is not *interpreted* the same in all browsers. How would you ensure that this fictional meta-language is interpreted the same in all compilers (or different versions of the compiler)? Humans don't produce quirks aware HTML by following strict rules, they do it by trial-and-error and seeing if the result "looks OK" after each change. The fundamental problem of HTML is that "looks OK" is not a formally testable condition.
Michael Borgwardt
If meta-language is well defined and has a reference implementation it actually relatively easy to produce compilers what interpret it in the same way,.HTML having ill defined standard so every browser interprets it differently but other programming languages avoid this problem. Humans rely on the trial and error because set of rules is too large for any one to hold it in his head , but actually such strict rules do exist some of them listed in QuirksMode sitecompiler don’t need to relay on trial and error, it possible to evaluate all rules what are available and produce correct result
MichaelT
Your meta-language will have either no, or a worthless default implementation, since its target are ultimately the quirky browsers. Other programming languages are better defined than HTML+CSS because their target's behaviour is, while HTML describes layout, which is NOT well-defined because it involved aesthetic judgements.
Michael Borgwardt
A: 

GWT, Dojo and ExtJS do exactly what you describe. Yes, they require javascript, but they do allow you to avoid remembering many of the "rules" (to a greater or lesser degree depending on the technology).

GWT especially is a good example, because it doesn't even require you to concern yourself with HTML, CSS or JS at all. You live in pure java land, cross-compile to a web app, and it just works.

Joeri Sebrechts