Why Do We Write Html

No one writes a scientific paper using PostScript - the level of abstraction is too low. They use LaTex and let a program create the PostScript (or whatever) for nice printing.

Similarly, I have to think think that there's a better way to deliver applications into browsers than working directly with HTML and JavaScript. Isn't there a higher level of abstraction available?

Why can't I build a GUI in HTML by writing code like this:

 public class LoginScreen? extends HTMLPage {
   InputField? nameField;

public LoginScreen?() { Layout l = new FlowLayout(); l.add(new TextField("Name")); nameField = new InputField?() l.add(nameField); setLayout(l); }

... }

The system should generate HTML from this for me. I can even create add a TreeView widget to the page, and the system will generate the appropriate HTML + JavaScript to make it all work.

Maybe Swing is the wrong model. Maybe it should be more like SmalltalkLanguage. Or whatever GUI-building toolkit you prefer. But wouldn't this be better than dealing with HTML?

There must be tools out there that let you work like this. What are they?

ASP.NET provides such a programmatic interface and it works quite well. However, in practice, you'll still need to munge HTML if you want something that's complicated and pretty.

ThereIsNothingPerlCannotDo. You want CGI.pm:

 #!/usr/local/bin/perl

use CGI qw(:standard);

print header; print start_html('A Simple Example'), h1('A Simple Example'), start_form, "What's your name? ",textfield('name'), p, "What's the combination?", p, checkbox_group(-name=>'words', -values=>['eenie','meenie','minie','moe'], -defaults=>['eenie','minie']), p, "What's your favorite color? ", popup_menu(-name=>'color', -values=>['red','green','blue','chartreuse']), p, submit, end_form, hr;

if (param()) { print "Your name is",em(param('name')), p, "The keywords are: ",em(join(", ",param('words'))), p, "Your favorite color is ",em(param('color')), hr; } print end_html;

This and much, much more at http://stein.cshl.org/WWW/CGI/ .

There's a crossover point that's similar to the argument WhyDoesntWikiDoHtml. Originally, and even now if you restrain yourself, HTML is very simple to write. Anything additional is much more effort than the HTML. Your example seems more like an application and that is more complex and help is useful.

Yes, the use I have in mind is building Web *applications*. For simple *pages*, HTML is fine. But for building an interative application, solutions like JavaServerPages are (in my experience) poor. I'm coming from the experience of building an order entry application using HTML and JavaScript - the app is complex, many screens that capture various types of data, and the users want it to work like a Windows app as much as possible. We use JSP, and it's a mess. We can clean up some of it by building more tag libraries, but it occurs to me that perhaps there is a better way to build and use abstractions for constructing an HTML/JavaScript GUI.


What about ASP.NET? You draw out your GUI with a GUI builder (and can switch to the source text view if you need it.) This creates controls that you program against, similar to a VB form (er, VB.NET form). You code post-back handlers against these controls, and you don't need to hand-generate HTML for all this stuff.

-- AdamVandenberg


WingS does something very similar to this. There are a number of java web frameworks that take a more code oriented view of the world rather than a page oriented one. See some of the links off of the WaferProject? web site.

EditText of this page (last edited December 4, 2011) or FindPage with title or text search