JavaScript is Assembly Language for the Web: Sematic Markup is Dead! Clean vs. Machine-coded HTML
UPDATE: Some folks think that saying "JavaScript is Assembly Language for the Web" is a totally insane statement. So, I asked a few JavaScript gurus like Brendan Eich (the inventor of JavaScript) and Douglas Crockford (inventor of JSON) and Mike Shaver (Technical VP at Mozilla). Their comments are over in this follow up blog post.
I was talking to Erik Meijer yesterday and he said:
JavaScript is an assembly language. The JavaScript + HTML generate is like a .NET assembly. The browser can execute it, but no human should really care what’s there. - Erik Meijer
This discussion started because I was playing with Google+ and, as with most websites that I'm impressed with, I immediately did a View Source to see what was underneath. I was surprised. I saw this:
Let's just say that this went on for about 1300 lines. It is tight and about 90k. This is just the first half. It's mostly minified JavaScript. The middle part of the page is all spans and divs and generated class ids like this:
Oy. The whole page is a big GUID.
However, I see this on http://msn.com, http://www.bing.com, http://www.facebook.com and on and on. Even http://www.twitter.com is starting to "tighten" up a bit. All large sites appear to care not one bit about the aesthetics of their markup. So why do we?
It works, and it works great. Many of Google's best properties have GWT behind them. Would you be more impressed if you did a View Source and found that it was not only pretty on the outside but also inside?
This seems a little ironic because it was just a few years ago when ASP.NET Developers were railing against ViewState. "It's so heavy" really means "I don't understand what it does." ViewState was (and is) a powerful enabler for a development methodology that gets folks developing on the web faster than before. This is not unlike other toolkits Google Web Toolkit (GWT). GWT isn't completely unlike Web Forms in its philosophy. From the GWT website:
Google Web Toolkit (GWT) is a development toolkit for building and optimizing complex browser-based applications. Its goal is to enable productive development of high-performance web applications without the developer having to be an expert in browser quirks, XMLHttpRequest, and JavaScript.
That seems like a very admirable philosophy, no? You could even say (with apologizes and tongue in cheek):
"ASP.NET WebForms" is a development toolkit for building and optimizing complex browser-based applications. Its goal is to enable productive development of high-performance web applications without the developer having to be an expert in browser quirks, XMLHttpRequest, and JavaScript.
The intent of this post isn't to shine a light on WebForms or be a WebForms apologist. It's great for certain kinds of apps, just as GWT is great for certain types of of apps. What I want to focus on is that working with server-side toolkits could be argued as going against the alternate philosophy that the real joy of developing on the new web comes from clean jQuery JavaScript and clean, clear markup ala Razor or HAML. It all comes down to what level of abstraction you choose to play at.
Semantic markup will still be buried in there and things like http://schema.org are still very important, just don't expect the source of your favorite website to read like a well indented haiku anymore.
To be clear, minification and compression are orthogonal optimizations. I'm talking about simply not caring if the markup and script emitted to the client are pretty. If you don't care about the markup sent to the browser, only the result, how can this free us to develop in new ways that aren't confined to slinging markup and JS. Ultimately, if it works great, who cares?
My question to you, Dear Reader, is why do you care what View Source looks like? Is HTML5 and JavaScript the new assembly language for the Web?
UPDATE for clarity:
The point is, of course, that no analogy is perfect. Of course JavaScript as a language doesn't look or act like ASM. But as an analogy, it holds up.
- JavaScript is ubiquitous.
- It's fast and getting faster.
- Javascript is as low-level as a web programming language goes.
- You can craft it manually or you can target it by compiling from another language.
If the tools - as a developer OR a designer - give you the control and the results you want, what do you care? I propose that neither Rails, nor ASP.NET nor GWT is 100% there. Each has their issues, but I think the future of the web is a diminished focus on clean markup and instead a focus on on compelling user experiences combined with languages and tools that make the developers work enjoyable and productive.
What do you think, Dear Reader...Do you want your HTML and JavaScript abstracted away more? Or less?
UPDATE: I want to say this again to make sure folks really understand. There's two separate issues here. There's minification and general obfuscation of source, sure. But that's just the first. The real issue is JavaScript as a target language for other languages. GWT is a framework for writing Web Applications in *JAVA* where the resulting bytecode is *JAVASCRIPT.* GWT chooses a high level designed language (Java) over an organicaly grown one (HTML+JS) and treats the whole browser as a VM. The question - do we write assembly language or something higher level? Also, I realize now that Google+ was written with Closure, but the point remains valid.
About Scott
Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.
About Newsletter
Jon - So you're saying Applications != Sites? Is that a delineation that can be made so simply? When do you move from Site to App?
So I guess if those things - modifying style, flexible JavaScript, searching and working with content - are important, it's a document. If those things are unimportant, it's probably an application. Twitter/Facebook/Google+ show a rapidly moving stream of information in an HTML shell that's really just a client for webservices accessed over AJAX and is indexed via external services, so not a document.
WebForms caused us great joy circa 2002 by giving us state and cleaning up a mess of spaghetti ASP. WebForms caused us pain circa 2006 when the Web started accelerating again and all of the cool kids began using CSS to make dropdown menus and start doing fun things with Prototype, and we wanted to start incorporating these techniques in our Web sites.
These Ruby & Firefox hipsters (bah! get a job!) took a step back to simplicity while we were doing voodoo sacrifices to page event lifecycle charts and chain smoking black box controls that spewed out markup in tables and mangled ID names and built up control trees that got confused by dynamically added elements. Not to mention our huge table-based layouts that designers shot out of Photoshop export that were hard to maintain because there was no equivalent design tool that worked well enough to maintain them.
So then came along CSS adapters and updated markup and ID naming options and control customization, but at some point we sat back and said "hey wait a minute--all of this nonsense just to get and send a string! WTF are we doing?!" It was suddenly easier to get fast results for many types of Web sites if we just typed the stupid HTML that we wanted ourselves. So we became a little (over) disillusioned with WebForms.
Now we're at the "plateau of productivity" stage of the Gartner hype cycle in regards to this type of technology. Web sites are becoming more complex than ever, so maybe a state-based Web model is beginning to make sense again, especially coupled with the app-like APIs coming with the HTML5 bandwagon. The browser is becoming a runtime.
WebForms was a good idea and continues to work well for many people, but perhaps the concept was just a smidge ahead of its time. After all, we wouldn't have dreamt of using this much JavaScript in 2001--if MS had introduced a GWT equivalent then our eyes and processors would have melted. This is the second round of the stateful paradigm--and the second attempt at any paradigm usually does end up working a bit better, hindsight being 20/20 and all.
As a side note, do you know about Lift (http://www.liftweb.net) ? There is also a demo site http://demo.liftweb.net/ which shows many of the neat things you can do with it and how simple and clean they are. Honestly, I have been using that framework for a while and everytime I need to go back to ASP.NET or even Rails, I found myself less and less willing to put up with all the work it requires.
Unsemantic HTML = NOT OK. Tends to results in maintainability, seo and accessibility issues.
Also, bear in mind that the above GWT produced HTML is horrible for SEO. The ratio of HTML to content is awful.
I agree with the statement that the browser is becoming the runtime shell. In such that applications or functional sites should do everything they can to minimize the content going down the pipe. Frankly if the entire page could be gzip'd and unzipped on the client on the fly fast enough to not incur a performance penalty for the user that would be idea and who cares what the layout of the markup looks like to the humany eye as long as it works. From a maintenance perspective though the markup needs to be human readable so I can jump in anywhere and not have to spend brain cells trying to decipher a complex tag heiarchy.
Also recall the web tenet that the end-user's wishes should override the designer's, one motivation for semantic markup: a user should be able to say things like "I want all lists to appear in reverse order." That's why we want to write ul and li tags and leave the rest up to the browser, instead of rendering a bitmap. Of course there has always been a tension here, with designers winning over time (minus some exceptions, like the Readability bookmarklet).
Complexity seems like a natural enemy of this user-first viewpoint, because even if the markup makes it possible, the more complex a site is, the less likely any user will be able to make meaningful changes to it.
Re: ViewState, I think it's a great example of how a technology can get a bad reputation that it can't shake. Nothing really wrong with the idea, but a couple of design decisions ended up causing too many headaches to ignore. Java in the 90s falls into this category too.
PS, I wasn't able to post with name/email/url, had to create an OpenID.
Still, I don't like sending out those overweight HTML pages even to regular users, although once it is minified and gzipped it probably makes little difference.
To put it another way, the benefits of HTML and JavaScript compression and minification only kick in after your reach massive scale. For most of us, it's premature optimization.
I also have an ideological attachment to view source. The fact that anyone and everyone can see the source code makes HTML and JavaScript the easiest programming environment to learn -- examples are everywhere! It also means that anyone and everyone can verify that the code does what it's meant to. Compiled binaries and obfuscated scripts don't provide these added benefits.
Still, your larger point that web programming is moving away from a scripting language towards something compiled is hard to argue, and I think is unavoidable. With increasing complexity there is also increasing opportunity to optimize, but doing so makes further development hard - necessitating the use of a compiler or minimizer. Additionally, if the network is one of the key bottlenecks in delivering your content, optimizing for size will be a natural reaction.
Matt Davis - Sounds like you have a very cool system in the works using script# - would love to hear from you and chat about things some more. Mind contacting me over at nikhilk.net AT gmail.com?
And Firebug makes the markup look perfectly readable.
It's probably safe to say that this is the future for the very large, corporate sites. And with tools like Firebug, we needn't worry about code being indented properly on corporate sites. They can just publish the compressed version and should we want to take a look, Firebug will make it readable for us.
I think that private websites and such have no real reason to go to these lengths to lower bandwidth use and load times. It'd be said if even the smallest of sites gave up on semantics like this. But for those huge websites with millions of visitors, it's simply a must.
Rails goes even further and if you have a :cache => true directive on your CSS or javascript files, it will lump them completely into one file. I don't know if they get minified (maybe).
The idea here is that production is a whole different animal than development. In development you WANT your HTML properly formatted so you can see your way around. No doubt the same is true for Javascript and CSS.
As for WebForms - I seriously had to check the date on this post :).
Works effectively for obsfucation, too!
Put another way ... let's assume a 100k non-minified JavaScript file becomes 10k after HTML compression. Theoretically, an 80k _minified_ version of the same JavaScript file will _also_ be 10k after HTML compression. So, minification is not really gaining you anything.
I guess the moral of the story is: use the best tool for the job. In this case, that would be HTML compression, not minification.
We are writing code for machines, not people. If a software can allow us to write clean code in a single language, and translate it to server and client code, why fight it. Unfortunately, we are not there yet. All we have is ton of unnecessary code being sent to the client, just in case (webforms), or useful, but not cached reusable code (GWT)
But as far as that layer of abstraction offered by Webforms and GWT goes, I think part of it has moved on to the javascript layer with libraries such as jQuery, prototype, mootools, backbone.js, etc. Obviously they aren't functionally equivalent, but a lot of the same functionality can be gained from those javascript libraries and is easy as or easier to code. Not to mention that you can take those javascript/html/css client side skills and apply it to any technology you happen to be using on the server side. The other big reasons those sites are going with the client side code is performance and scalability, for example client side validation is a lot faster than doing a postback in web forms and if you have enough traffic you can potentially knock your server out with the postback approach. Anything you can get running on the client side takes that much more stress off of your servers. If your working on a high traffic site where performance is an issue, this is the way to go right now.
There was a time a programmer with no knowledge of C wasn't going to get anywhere. Then we created C++, VB, C#, Ruby, and a plethora of other languages that serve to put more layers of indirection between you and the assembly. These layers of indirection introduce performance costs, and occasionally you lose the ability to make a really killer optimization. But most applications have tighter schedules than performance requirements so the higher-level the language the better. When you need something to run fast and don't care about maintenance, C's still the shining star.
You can use HTML/CSS/JS in the same way. Google+ and Facebook are high-end web applications. It's more important that they deliver a cutting-edge experience and as lean a download as possible than that they remain readable for their developers. Using HTML this way is choosing C or assembly. What about your blog? It was important for the blog developers and your theme developer to ensure end users could understand and maintain the code. So it looks more or less readable, and the code isn't as lean as it could be. Using HTML this way is choosing C# or Ruby.
I don't think computers are the sole intended audience of all websites, but the developer is free to choose.
Application developers' choice of language isn't coincidental. Assembly and C are close to the metal. The programs are harder to understand and harder to write, but the developers are able to squeeze every ounce of performance out of the machine. Ruby and C# have many layers between the developer and the metal. These applications pay a performance penalty and occasionally aren't able to perform a required task (.NET shell extensions were a no-no for a long time!) But the higher-level languages are easier to understand and help meet aggressive schedules.
HTML can be wielded the same way. Google+ and Facebook are web applications used by millions; their developers chose to aggressively optimize their HTML at the cost of readability. Your blog and its theme was intended to be edited; the HTML was optimized for readability at the cost of performance. Developers have to choose the right tool for the job.
The only sad part is my memory of self-learning HTML by viewing the source of nearly every web page I visited. I wonder how many people will be curious about web development but turned off by minified source? I don't think it's an argument for abandonment, but it's still a concern.
I think the future of semantic markup is great and has only continued getting brighter with HTML5.
The importance of human-readable JS/HTML is an interesting question. If you'd asked me a decade ago, it would have been a no-brainer to say that it was very important. The web could never have evolved as well as it did without meaningful view-source.
Even with the excellent in-browser tooling we currently have, I do spend quite a bit of development time loading pages and immediately hitting Ctrl-U to see what the heck was actually rendered. Digging through the markup tree in Firebug/Chrome is an alternative to that, but no where near as quick/easy and doesn't provide the same high-level overview of the size/structure/layout of the document. In my own development, minified markup would definitely add unwanted friction.
Once you factor in gzip/deflate HTTP compression, I'm skeptical that the difference between human-readable and minified markup is worth the obfuscation on any but the most heavily trafficked sites.
Many of us don't write those sorts of sites but write the content-rich personalization-light sites they are discovering and linking to.
We don't need tons of JavaScript, AJAX and hash fragments because we're writing rich content that needs to be search indexed and perma-linked open to wide audiences.
[)amien
However, having built a large system using Nikhil's Script#, there are incredibly benefits and yet still some challenges.
One of the biggest problems with such tools, whether Viewstate, GWT, etc is that you have to debug in the browser. This means that you have to set breakpoints and map the generated code back to what you wrote. Same with HTML and perhaps even CSS. So the more the tool does the bigger the gap. Which is why Less, SaaS and CoffeeScript seem more palpable for many, they are more like macros over their respective abstractions, much like C++ was over C originally.
Could you imagine writing C# and debugging IL? It's possible sure, but doesnt like a good time.
Once debuggers are created and a few other tooling problems are solved, then Javascript+HTML can truly become the assembly language.
Are you cunningly preparing us for a Silverlight to HTML/Javascript compiler? So if I say: "yes, I don't care about what is downloaded to the client, it is all about abstraction layers" I can't go back because I said so? :-)
The sheer amount of jQuery plugins proves it is all about abstraction. At times I teach jQuery, Javascript and HTML but it does feel like teaching assembly: basic stuff, unhelpful editors and debugging, low productivity, repeating the same constructs...
I've had to deal with lots of unwieldy code created by great developers who felt their only responsibility was the server-side code. Hard to maintain, difficult to plug in other components, etc.
Let's face the truth - HTML and JavaScript were created to be a document language and not an application language. So now developers are using the wrong tools to create web apps. Developing apps in HTML/DOM/JavaScript is like developing apps on top of Word or PDF. In other words - does not make any sense.
Just to make a web app people have to use a lot of javascript libraries (which essentially are hacks around dysfunctional DOM to make it a little bit useful). For example jQuery - Scott in some blog was praising how nice and easy he can do some DOM manipulations with it - but compare jQuery code with some Silverlight code - the difference is enormous. Silverlight is much more readable, maintainable, and much more easy to understand.
It is about time for developers to understand that hacking on top of dysfunctional DOM/HTML/JavaScript will not make an evolution on the WEB. It is counter productive. It makes developers forget about strict code, about Gang of Four, about readability. What kind of new generation of developers are we making? Is using "$" shortcut for development really such a big achievement?
Web needs a new thinking - it needs a new platform. For example Silverlight would be a much better platform for the web than HTML in all aspects of development. Obviously Google will never implement Silverlight, because they are so anti-Microsoft. And that is not good - because Google is one of the primary forces that could drive WEB platform forward and not backwards. Microsoft created Silverlight with good intentions, but Microsoft can not be alone in defining the new WEB - and others just do not care about developers to really drive the change (and probably are not smart enough).
Google is even trying to make a browser as an OS (Chromebook) and god help developers if that will pick-up a steam.
IMHO, the server response will become like an executable code to the browser, only when developers are capable of checking a bigger part of their work server-side, like some form of compilation (or at least the checks involved) of the JavaScript. And this is where the WebForms and ASP.NET in general, isn't that developed, yet. Google's Web Toolkit provides a "Java API", which makes compilation, syntactic and semantic (through server testing of the client code) checks possible.
The HTML and css are not that problematic - we already control rendering through compiled code which can easily be tested and at the client side all the browser developer tools display the code indented and properly colored.
In other words, if it's a machine code - why do we still write in it? Shouldn't there be a higher abstraction? :)
Regards,
Nikolay Tsenkov
(http://stackoverflow.com/questions/1621403/what-happened-to-project-volta)
So it goes with the Web. Heck, maybe the "big Surprise" at the Build conference about Silverlight is that it's going to target HTML5 + JavaScript + node.js + jQuery as a first-class runtime for Silverlight output. That would be in keeping with this trend.
Thinking about the difference between Web Apps and Web Sites, I tend to define it like this: "A web app is made up by pages that do something even when you don't provide any input, and tend to modify their DOM a lot. A web site is made up by pages that don't change after they're loaded".
If you leave Facebook or Gmail pages open, and you go away, when you get back you see very different pages, with new posts/alerts, new open chats, and new Mails in the inbox.
If you do the same thing with Wikipedia, after loading the Superman page, when you get back, you still see Clark Kent's glasses, and you don't see any alert that says that you may also be interested in Batman.
That said, I spend quite some time to make my HTML markup clean... and I usually fail :-P
My personal opinion is in line with Nicholas and Jon above. If you are creating an application that is using the web as an API, fine, use a framework that sits on top of JS and HTML and generates things as needed, in a semi-unreadable clump. But then keep in mind that you are no longer looking for a web developer for your site maintenance, but a very specialized (insert frameworks here) developer who might have some web development experience but probably isn't using it much.
If you are creating a site that doesn't need every last byte of space squeezed out of it just to fit across the wire, then write for maintainability. I'm on the fence on minimization of HTML, now that we have developer tools for all the major browsers, but the original HTML/markup needs to be readable as does the original JS. And it needs to be clean,well formatted, and well described.
I like HTML, I like JS. Maybe it's because I've been using them for over a decade and I'm getting set in my ways, but I'm not ready to slap a compiler on top of them and forget playing with them.
Unfortunately I think that is exactly where we are going. I think we are going to be asked for more and more complexity and our two options are going to be either frameworks that generate everything for us or updating browsers standards, And given the historical ability of browser groups to implement standards in a timely fashion and get people to upgrade to newer versions of browsers...
There is definately a difference between web app and web page. For your site you want clean semantic html. Does it need to be readable? No. I don't care if its minified. But, if you take away semantic clean minimal html and incorporate a huge mess of machine code you rob search engines of the capacity to understand your site.
Actually, on second thought - tell all my competitors they should build their sites like this :)
Even the purists are adopting "compiler" solutions like CoffeeScript and Sass to make their JavaScript and CSS more serviceable, and it's standard practice to minify these resources in production, so why should the HTML itself be a special case?
As for abstractions. it would have been difficult or impossible for a human being to, say, code Angry Birds directly in javascript in any reasonable length of time. So why bemoan that you can't easily understand the code that GWT produced? If GWT hadn't produced it -- it most likely wouldn't exist. Instead, try to understand GWT, if that interests you.
One of the people in the audience (Dion Almaer) brought up the point that you make on this blog and even said "the new view source is on code repositories rather than in live code, because most of our websites are actually rendered according to performance standards or actually rendered for different browsers".
I wonder what the ramifications of this would be. As long as there are plenty of open source projects where people can actually view the source code in code repositories this might not be a big deal but only time will tell :)
You can the video (and a transcript) here: http://developer.yahoo.com/yui/theater/video.php?v=yuiconf2010-panel
se·mat·ic (s-mtk)
adj.
Serving as a warning or signal of danger. Used especially of the coloring of some poisonous animals.
Maybe not?
:)
I'll not be surprised if Javascript eventually turns out to be a form of intermediate code, where people code in other languages, run it through a compiler/translator, and it becomes HTML/JS. Javascript depends so heavily on libraries to be cross-compatible, and its syntax is so lacking, that a more advanced wrapper language will definitely boost programmer productivity.
And this is possible because the JS engines are all getting faster, and JS needs to evolve much faster if we don't want to end up with a wrecked state of web with lousy JS.
Build Script - http://html5boilerplate.com/docs/#Build-script
- Combines and minifies JavaScript & CSS via YUI Compressor
- Optimizes JPGs and PNGs (with jpegtran & optipng)
- Basic to aggressive html minification (via http://code.google.com/p/htmlcompressor)
- Runs your JavaScript through a code quality tool (optional)
- and much more...
The idea is to keep the development code as clean and formatted as possible with good variable names, class names, etc... but when you are ready to go to production there is a build process that will compress all your work down into something very small so it can be delivered at an optimal speed. As for the HTML minification you can argue that it may or may not help you due to gzip compression, but I would guess it doesn't hurt. In some cases the minification step also deters people from stealing your work as easily. It is still possible of course, but makes it harder.
Interesting article and I've had somewhat similar thoughts. Therefore I do agree with you ;-) When we write native apps do we care about the readability of the output? We became accustomed to viewing the markup and js in our sites in part because there has not been as great of a separation between build (design, code, debug - especially debug)-time and run-time as there has been when building native apps. In fact, we have often used the run-time container (browser) as a debugging tool. These facts seem to have contributed to why we have cared about readability in output. And of course we view markup to see how others do things :-)
As UX continues to become richer in browser-based apps there will no doubt be an increase in the amount of client code required - whether that code is in the form of native browser capability, js libraries, or app-specific code. I expect that we will care less and less about readability in the final output.
I will say though that we will continue to care about performance, and tight, fast code will be preferred by developers and users over bloated output. That makes it still useful for developers to at least have some sense for what is going on under the covers as levels of abstraction rise. Just as it has always been.
Are you trying to leak the September BUILD contents here? Or you are 'testing water'? :)
Best,
dong
The code generated by third parties is a mess, but if I trust it, then I trust it. Even though something might be Open Source, or I can view the code and see what I think the problem is, I will rarely, if ever modify the code that generates the code. I know that the people who wrote it have solved problems that I don't even know exist, and me jumping and mucking with things is likely to end poorly. Go read Ray Chen's blog about how people misuse(d) the win32 API, "fixing bugs" that were "caused by Microsoft."
My code needs to be debuggable. Theirs does not. Mine will be pretty. Theirs will be whatever they want it to be.
But the readability of the development copy of the site is paramount. It is second only to "works" in the measures of software quality, especially in a situation where different developers work on it from day to day.
The HTML and CSS on the other hand is a different story. Browser differences still pop up and not having the same control over HTML and CSS makes it harder to deal with them. Twice, and in different ways, we've had the IE issue outlined here bite us: http://codebetter.com/kylebaley/2011/03/31/how-to-strip-away-the-super-powers-of-borders-in-ie-2/
With the HTML and CSS being generated, it's harder to play around with the HTML and figure out: a) what's wrong, then b) how to fix it.
Larger concern for me is testing. With GWT, unit testing these applications is much easier but UI testing is more difficult. With some other entity taking over generation of the HTML and CSS, it's more difficult to use HTML IDs and CSS selectors to locate elements on the page for UI testing frameworks.
"Working software is the primary measure of progress." If you deliever what the customer wants, and it works and performs, who cares how... and "view source" can be as ugly as it appears... if the customer is happy.
The second issue is JavaScript, etc. are the assembly of the web. Well we're already seeing languages being built on top of JavaScript (CoffeeScript, Script#, etc.). The issue at present is the tooling. It's rather difficult to go back to the original language (CoffeeScript, etc.) and debug from that. Until then, they're not that useful to me. But as far as HTML/CSS, if a tool can come along and generate decent markup based on some layout mechanism (I don't care if it's drag/drop or whatever), I'm all for that. The issue currently is that the vast majority of those tools suck... And not in a good way. However as things move along I would hope that we can abstract away the underlying languages a bit.
I wonder if Google will come to regret GWT.
I mean, Google makes it living by parsing HTML and indexing it.
What if in the future all web pages are nothing more than JavaScript that renders a view using HTML5 canvas?
Is Google gonna be able to cope with that?
Maybe GWT spits out different HTML for robots.
However, this article made me reconsider Microsoft's new found interest in HTML5 for Windows7.
Maybe M$ is making the switch to JS-driven HTML5 as a strategy for cutting off Google's air supply.
One of the best things I've liked while working heavily with Monorail some years ago, was that, it had lots of documented extension points, but if you needed you could even switch in customized (or totally new) versions of the core pieces to be able to achieve what was demanded. In retrospect we see that being open source helped a lot to that end.
So I want some tooling that evolves fast enough to catch with changes in the "assembly language" behind it (HTML X/ Js Y), and that allows to replace or add new pieces to the "composition/ optimization pipeline", easily tailoring it to the needs of each project we will be working on.
In the future, please file only one issue per ticket/blog post. ;)
- automatically optimization, minification and compression what is send to the browser,
- detect and make the necessary changes to control "events-handlers" to take advantage of latest technologies (jquery/ajax/json/htm5/css3/etc).
without sacrificing the developer side.
IL->decompiled back to JavaScript. It's a clever concept and works with compiled assemblies. That site above shows the XNA SDK Samples running on a browser as HTML5/Canvas/ECMAScript5 code. Calls out to native externals (PInvokes if you like) are fixed-up to javascript code, so in the case of XNA these are redirected to Canvas calls in HTML5.
After that show, maybe a follow-up show about "whatever happened to Volta" from the cloud programmability team....
If you review the history of html and the web, I think you could have logically deduced that browser was going to become a "vm" and "HTML + JS" was going to become your "bytecode". Early on html and the web was used to share documents. Eventually, WYSIWYG applications became sprouting up because they made life easier and faster. Some time there after, the web began to explode and someone made the bold decision to build their application on the web using html. Sadly, html was created to support documents and not applications, and when push came to shove and eventually javascript won out as a tool to help support html for applications on the web. And what do we want now? Tools to make our jobs easier and faster. This is what John Resig did with jQuery. This is what Google created in GWT, except they didnt create their own language, they used an already popular one.
We have become so dependant on HTML and JS that it is near impossible to scrap it and use something more supportive of web applications. It would be nice to see Microsoft change Silverlight and make it more like GWT, make it something that builds HTML and JS (with the help of C# of course). I don't mind having my JS and HTML abstracted away from me. Do I care that C# is compiled into MSIL? Or that MSIL is compiled to ASM? Not one bit, as long as it works! :)
We really need better tooling and debugging and if this helps us get there it will be welcome. Another advantage for some might also be the ability to gain a little more consistency in programming at the various layers - maybe why node.js has gained a certain interest. But we do also have to keep in mind other factors such as some that made Rails and ASP.NET MVC so popular so fast - some abstractions actually make building real applications harder rather than easier.
A search engine should be just that, a search engine, and not an excuse to plaster advertising on every square inch of surface area, as in the movie Idiocracy.
Our tools can and should generate one big, long string of optimized code that the the browser (interpreter) can execute. There will someday be some new means of allowing users to find applications, sites and information (I refuse to call it "content") without us having to develop so that everyone in the search engine/SEO/web advertising ecosystem gets fed. Have you had your SEO snake oil today?
When I came up, page markup and any language that ended in "script" wasn't considered programming or application development. If my controls generate JavaScript when the code executes server-side and gets served, so what. I don't write JavaScript. I don't need to.
In my not humble at all opinion, HTML, JavaScript and browsers are the biggest kludge ever to exist in the world of information technology. And thanks, MS, Firefox, Safari, Chrome, et al. for building so many versions of a better "standard" mousetrap. Really, thanks a effing lot - I'm looking at you, IE.
It's been over 10 years since I needed to View Source to teach myself some new browser UI trick. There's nothing I can't do with web forms and Telerik or Infragisitc or any number of third party controls.
Building apps is building apps. Software is software. Web sites are software. There is nothing new under the sun. Plus ça change, plus c'est la même chose.
</manifesto>
------------------------------
1) JavaScript is not an evil language, it's not a poor language, it's not a weak language. These are issues people have with it because it is sometimes difficult to understand, and people attack and fear what they do not fully understand. Treating JavaScript as an assembly language by having a compiler that takes another language and boils it down to the JavaScript can be handy. This can also be a very bad idea if that compiler does not develop effective JavaScript. Exactly as if a C++ compiler compiled assembly code in an inefficient manor.
2) There is no definitive difference between a website and a web application. It is still a dance of HTML, JavaScript and Cascading Stylesheets that presents information. It was in the 90s where we defined these, when ASP PHP and JSP were born. After systems started becoming something more then just a few little static documents and becoming a more organic and dynamic object there was no difference anymore. Yes I can still write a Classic Web Page. Yes I can still write a Classic Application. However, for the most part the point is nostalgia and not the technology. I can write a Website with all the latest and greatest and make it look and feel just like those pages too. So there is no more division of the page or application definition.
3) Viewsource is a legacy web browser feature that today is used more and more by developers to harvest features that they want to add to their page, debug the webpage if they want to view the received file the browser has received, and for hackers who want to find a vulnerability. Hackers aside since the resourceful people of that world will never be hindered completely. Also, There are plenty of other reason that viewsource is used, these are just three that I often see.
Messy Source can be semantic. A semantic web means that information is represented in a contextual way. Menu content is identified as menu content, headers, body content, subjects, etc are all marked accordingly. Clean source can NOT be semantic, just because it is human readable doesn't mean it properly represents the information. This goes for JavaScript, HTML and CSS. When was the last time you opened the hood of your car and said OMG that is the most beautifully set of hardware, in reference to how things appeared? While the car guy part of me would say, "all the time good sir", It still looks like a tightly wrapped package of wires and pipes and other hardware, much like a tightly compressed HTML file.
4) Viewstate was the worst idea ever. I am sorry to say that, but it is true. There is never a need to send the USER content that can be exposed to harmful application and then presented back to a system that claims to be secure. ViewState was the end-all-catch-all data center for many ASP-WebForms pages. Containing data that if modified between the client and server could reek havoc on secure systems. We got along well with out it before ASP-WebForms, we get along well without it now with ASP-MVC. As I see ViewState, it was the solution to make web development feel more like VB programming and provide a state to a stateless environment. At least the web as defined in 2002, which was claimed to have a stateless model.
I see websites as a very stateful environment. It has a beginning, a middle and an end and even after a page has been received by the user, we can use AJAX to dynamically request content outside of that standard stateful pattern, each with its own stateful behaviors. This does not differ in the slightest when you examine any application. It has a beginning, a middle and an end. While the end of an application can imply that the application has completed, go a little farther and think of the states of the application as these same events of a webpage. Startup, loading, moving from state(screen) to state(screen), exiting, etc all can be inferred as the statefulness of a website.
5) Clean markup is important. Important for maintenance reasons. Development purposes. Overall this is how it works, purposes. I know for a fact that my C++ application does not have 800MB of whitespace characters in it after I compile it and send it to someone to execute. Why should I send my user of a website all this whitespace that means absolutely nothing to them?
I shouldn't. Effective developers will develop clean code, semantic markup, and deliver efficient user experiences. This means that the HTML file has all the proper markup it needs to correctly represent the content it is presenting. This means that the JavaScript code is written and delivered in an efficient and concise manor. This means that my CSS is also efficient and delivered in a concise manor.
------------------------------
We need to focus on creating excellent user experiences, while maintaining effective clean code. Effective code should also adhere to a "simple is, as simple does" technique. That means you should not have to have 80 technologies to present three to an end user. You should never confuse the difference and purpose between any of your technologies. If you write ASP-MVC, you should never have to write a ASP-WebForms page just to present some dynamic behavior. ASP-MVC is just as good as any of the PHP or Java MVC frameworks, and somewhat weaker since it is younger and tied more to a business direction instead of progressive technology advancement that is common in the OSS community.
Twitter: @itanex
Web Developer
JavaScript Developer
ASP-MVC Developer
Advocate for sustainable technology and code
The fact that tooling is lacking is the one of the reasons we are using other tools like Java with Google Web Toolkit and .Net with Script Sharp to generate the script. The languages available in Java and .Net aren't much different than JavaScript. However, it is the frameworks and the Integrated Development Environments that make them the developer's choice.
Think of something as easy as creating a data structure with properties in C# using Visual Studio and how much more difficult the same task is in JavaScript. Part of this issue is that everything is in the global namespace by default in the browser, so we have to rely on frameworks like JQuery. However, JQuery isn't a standard either and there is no intrinsic support for it in the IDE.
One of the reasons for the lack of tooling is that the browser was essentially a document reader that was hacked into an application platform (Thank you Microsoft and IXmlHttpRequest). I imagine this is why I feel like the JavaScript support in Visual Studio was hacked in as well. Some vendor needs to rethink what the "browser as a platform" is and design the proper tools to support it.
You mentioned Webforms + Script type of thing. While I don't know what exactly what you're thinking, I might think of it backwards, just to stir the pot for you:
Script + Webforms. Oh no he didn't. Yeah, I put the "Script" first baby. Boom!...Well, all I mean is the scripting world needs to take a higher priority in our minds as we build a framework. I think that you're thinking we need to let the two play nicer together...as in "stop touching me" (I have little kids). That would be great. Let script live happily and let webforms use it's power. How about the whole thing though. Script/HTML/CSS + Webforms. Separate them all out as much as possible. Maybe it's like View + Webforms. Sorry, I'm thinking out loud...or writing out thought...typing as I think...whatever. Got it...View + C#. Simple concept. Just separate script/html/css/everthing-front-end from the chaos of webforms but allow some c# to "bind" or give it stuff. No implied single form or viewstate or fo-html with runat="server". Just real markup that allows C# to script it...if it's nice. Really, if you just took the simplicity of classic asp, suggested a separation (via code behind-like setup) but didn't enforce a structure, but allowed developers to choose to implement specific components that webforms brought us. No drag and drop, "it just works" crap. But show me how and where things go to have something like a viewstate setup, with only the deeper object pieces not in my face. Everything in and out of the page is revealed and implemented by me, the developer. All the niceness of the membership works if I want it, but I implement the front end, completely and tell the back-end to make the membership calls myself. A blank canvas framework for .Net. Yes...
Stuff like that only works if you guys trust the developers more. I'm trying to trust you guys. We do need to strip out a lot of stuff. So my request: Please prune the framework, and leave the front-end to us. And I'll choose the events, thank you. If you have or know of a project or solution like that, please let me know.
I can imagine a new webform that used json and ajax to make the webforms inner workings more transparent.
Practically, only startups that find a way to survive without SEO can get away with this. So be it. As web dev and good internet citizen, I couldn't care less what these private walled-gardens are doing on their property. Their client stacks and frameworks and enigmatic HTML machinations won't affect the broader SEO/public-driven webdev culture at large.
Exactly.
a) easier to debug our own crap. (Don't lie... you all know this is true)
b) easier to say "hey... how the f* is Facebook doing this?" Look at their code, manipulate, and use on our own code so I can go play my next round of Mario Cart with my sons.
To others points, yeah, we've done this to shave time off the download, we use GZip compression at the server side to do more. But thankfully, bandwidth gets cheaper and wider, so eventually it doesn't matter.
And it wasn't viewstate was unreadable, but sometimes if you used the same user control over and over in a page, you ended up generating a 4MB viewstate. Works fine internally, not so well in Argentina.
4) Viewstate was the worst idea ever. I am sorry to say that, but it is true. There is never a need to send the USER content that can be exposed to harmful application and then presented back to a system that claims to be secure. ViewState was the end-all-catch-all data center for many ASP-WebForms pages. Containing data that if modified between the client and server could reek havoc on secure systems. We got along well with out it before ASP-WebForms, we get along well without it now with ASP-MVC. As I see ViewState, it was the solution to make web development feel more like VB programming and provide a state to a stateless environment. At least the web as defined in 2002, which was claimed to have a stateless model.
1. I don't think it was the worst idea ever. You apparently never used Windows ME.
2. It's fairly secure. There were a number of safety mechanisms in place to prevent the type of attacks you are referring to. It wasn't meant to replace SSL nor give excuses for irresponsible programming. That and if such attack happened, there was usually more than one cause than just the viewstate.
3. We got along because it didn't exist. We got along without internet, MP3's and Blu-Ray too.
4. It feels more like WinForms programming. not VB itself.
5. When did HTTP itself become stateful? Last I checked it is still request/response/end. We use tools to communicate via sockets over web interfaces, but they themselves to not use the HTTP protocol to keep a persistent connection unless you hack it and never end the response. That has it's own short comings.
As for viewstate I think it got a bad rep because of its misuse, it was left enabled by a lot of people on all their pages and controls when not required. .NET 4 makes the situation much better because you can have the viewstate disabled by default at page level but just enable it for a single control within the page.
Most source-to-js compilers are incomplete or lack tooling. GWT is probably the most advanced out there, for .Net guys theres Script# in the works but is missing lots of language features. Also there is the pretty nice Websharper(F# -> js) framework.
I actually think the web should be all based around the CLR, so we'd have security and language independence. Maybe Google Native Client could help solving the problem.
But most immedeately we need much better tooling, I want Visual Studio to integrate with some core js libraries that provide things like namespaces, requiring js files, some form of widgets, client + server html templating, data binding... which should be powered by great tools for developers and designers, like Blend for Silverlight.. I like jQuery for hacking, but not for something *professional*, as this always tends to get hacky.. (I think I have not ever seen a cleanly written js application)
Javascript+DOM has pulled off a powerful enough platform for distributed computing that the underlying OS/runtime/machine instruction set/microarchitecture is now largely irrelevant for most web app/site developers. At some point, someone will bld a new paradigm on top of it and it will be abstracted away. Only developers need pretty code and markup. Better not to rely on reverse engineering other peoples private code to learn how to build for the web. Look to open source instead.
I suggest Microsoft recommend the CIL standard for this purpose when the time comes, seeing as it's already a standard anyway. Some people say that javascript engines in some browsers are already competitive with the .net vm, but I guarantee if you had five browser teams competing for the fastest CIL vm, the fastest vm in the group would be orders of magnitude faster than the fastest javascript engine is today.
It is abhorrently slow, and being script requires translation, which is part of the problem. The "optimization" of putting it all on one line is like someone saying how great their optimizations of BASIC were by omitting comments, using single letter variables, and other crap optimizations to make the wrong choice of language run something like 30% faster.
Use Java! or create a new language using a byte coded VM that will actually do the jobs that are needed without all the verbiage.
My take on this whole Javascript thing is that the programmers don't want to learn how to choose the right tool for the job. Maybe I'm wrong. YMMV!
ExBASICProgrammer.
Comparing WebForms to GWT??
WebForms: The FrontPage of the 00's. That is, Microsoft tells developers: who the hell need to be a web-developer. Just point and click and you have a full-featured site. You all know how _that_ ended.
GWT: Something that MSFT doesn't have yet (we'll get to script # in a moment), and all the dotnet shops are screaming for.
RE script#, please compare the GWT team (and development time invested) with the script# team.
What that potentially leaves you with is the opportunity to work at multiple levels of abstraction depending on the need.
I've heard a lot about the whole "js is the IL of the web" lately, and it's not an altogether absurd idea. Ideologically, however, it seems like a messy workaround. I suspect that getting "the world" to adopt an efficient, consistent and uniform intermediate language that all browsers implement is all but impossible. So in that regard, the idea is phenomenal.
Then again, I do little-to-no web development... so wth do I know?
From personal experience, the most obvious reason to hate ViewState is that it's per-view and cannot be cached on the client the same way that a .js file can be. I don't mind big, complicated Javascript because no matter how big it is, I know it will be cached after the first request.
I've seen 20MB (yes, MB) ViewState being used by developers using a grid control who didn't know any better. They simply thought the page was slow because of the amount of data and not because they were sending 20MB back and forth with each request.
More importantly, ViewState enables a sort of weird emulation of event driven programming but for a platform that's inherently "client-server".
Fast forward to today and now I am an independent contractor, so spending 1 hour on something to could be done in 20 minutes, really makes a huge difference, so I quickly started using GWT, since I can do more in less time and personally, I agree, I see the Javascript result as assembly or some other lower level language, my higher level language is java, and not only that, the components available in GWT really speeds up my development, and that is really important when you get paid per deliverable and not being paid to just warm the seat. If I don't deliver, I don't eat, so the faster I can build applications, the better for me. Also note I have a full SLA on the deliverables, so no amount of corner cutting will help me, so I need higher level languages to speed up my development time while still keeping the quality high.
I came across this article & thought it was interesting, so thought I'd share:
http://www.infoq.com/news/2011/07/Google-Plus
2. Yes I think Html5 + Javascript is the new low level language for the web.
3. I want the full control on the low levels but I don't expect it to be very easy. But it's very nice to support many common scenarios as default behavior easily. The abstraction is more important to me.
3. Yes I want my Html & Javascript abstracted away more. But of course I want to be able to create controls/components which they can use all of the low level web features. They should be able to inherited/inherit by/from other controls/components easily.
As you said, (Html + Javascript) = Web Low Level Assebmly. Althogh I like to know anything about the low level languages, I don't like to create even an average web app with these low level languages. I think we need more high level languages and tools. While these tools give us the full control on the low levels (As a low level component developer) they should observe the abstraction. Especially I like the real component oriented development which we can easily reuse the components in new projects or upgrade a single part of the software without change in other parts.
What do you think, Dear Reader...Do you want your HTML and JavaScript abstracted away more? Or less?
More please!
So in other words, perusing web sites with gobbligook when invoking "View Source" has ABSOLUTELY NOTHING to do with developers' insistence upon clean markup and code. Very seldom do developers debug a site running in production.
Right now though, I still think that writing HTML + JS offers more flexibility. It's more deliberate too. WebForms doesn't have a "compiler" that converts C# into HTML+JS the same way C is compiled into assembly. It works with server control components, and you end up having to work within the boundaries of such components. The second you want to break those boundaries, I believe it's much easier and straightforward to write HTML+JS than to write yet another server control that "ends up as" HTML+JS.
I also use ScriptSharp instead of writing JavaScript, and it sounds like my style of development is very similar to what Matt Davis describes, above.
This, in turn, gives me compile-time checking, refactoring, and everything else a modern IDE has to offer.
Markup is not dead, but it is so easy to ignore. Have been a server-side programmer for years but underestimating power of markup is a common mistake.
In fact HTML5 is coming back to the markup semantics: dropping div and adding footer and header are just examples of it.
The current situation is a coping mechanism and in no way ideal or "good".
The real issue is that HTML+JS have not kept pace with how they are being used.
Semantic HTML is a great idea. Unfortunately, the vocabulary we're working with is far to limited. We should not be forced to resort to extremely complex machinations to bend HTML and JS to our will. The basic things that we use every day should be simple and easily expressed through the declarative markup. JS is there to compensate for all the things that you can't declare in HTML.
HTML needs to be able to declare more.
Taking this further, I cannot see any legitimate reason why tiny grammars are not built specific to narrow situations that generate JS. This is different to generalised, broad frameworks like GWT which cater for general purpose programming needs. Even in my example above, and with hindsight, I could well have written the post-processor in any language that was convenient.
Lastly, treating JS as an output also changes testability. In my limited experience, the generation phase is the smallest effort compared to the getting the grammar for the input language designed and built. Testing the grammar may well be simpler but I guess it depends on the grammar itself. In any case, if testing the JS is important in itself, I'd consider generating the equivalent JS tests from the generator itself.
No JS for the masses is certainly the way of the future, IMHO.
Troubleshooting in firebug would be difficult I'd think because the output and the written source would be different. That is actually the reason I've held off plunging into Coffeescript
Imagine a client side debugger that converts the js back to the coffeescript while debugging :)
Now these same companies want us to use their code generating controls/plugins/CMS.
I prefer to use RAD tools like JQuery which allows developers to have a compatible event-driven environment for developing web applications with minimal code.
I think the analogy/point is well made that JavaScript (in modern, responsive web implementations) is realling starting to feel like alien machine-code and the browser more like a "runtime".
I agree with both Jon and Nicholas on the whole App != Site comparison for the same reasons. I often find myself stuck for a moment here, as it is sometimes hard to decide on an appropriate approach because my project's content is somewhere between the two paradigms... where some chunks are simply document-like and a carefully crafted bit of semantic markup makes a lot of sense. Other parts (CMS-like functionality, animated and/or same-page UIs) seem to fit the App approach better.
It would certainly be nice to have some higher level abstractions available to program easier and compile down to something like JS, but it becomes yet another platform/approach for developers to consider - paralysis stemming from vast opportunity.
And (cheeky), wouldn't that get the hipsters and corporate coders all up in a fit, knives out, if we all wrote .Net C# that compiled down to Node.js and client-side JS anyway? Scary.
Interestingly enough, John Resig is taking an entirely different approach - at the Khan Academy they are starting to teach JavaScript as a First Language, which is an intruiging concept I was speaking to Scott Allen about a bit. Just like back in the college days of learning assembly language and C+ before ever touching anything else.
Is it better to learn the guts and gristle then in the name of better understanding and good craftsmanship? Or do we just provide people the tools to swiftly weave a larger web, without worrying about them knowing what is underneath the sheets?
As a code-on-sleeve nerd who likes to know the heart of stuff, who often spends a rediculous amount of time learning rather than getting 'er done, I am undecided yet.
What about allowing us to distrpute a compiled script over http that will make thinks faster for download time and execution too :)
Comments are closed.
And with the frameworks that are available today, the days of using View Source to learn how to do something on the web are quickly fading away.