4 ms·
One of the endearing qualities of web design and development was how the source was open for everyone (HTML, CSS and JS). Developers could read the code, unders
by arocks 13y ago
One of the endearing qualities of web design and development was how the source was open for everyone (HTML, CSS and JS). Developers could read the code, understand and remix each other's work. This helped in its rapid growth from a design platform to an application platform.
Enter asm.js, where the source code is as readable as a compiler's assembly output. Once again we are back to code that is hard to hack and improve. Sort of similar to the days of Flash except that entire applications are being built on this platform.
It might be a great end user experience, but it is not the best way forward for web development.
- k__ 13y agoI know, there was a time when people took their scripts from different sites and included then into their own. But does this still happen? I mean most of the scripts are minified anyways :\
- jiggy2011 13y agoPeople still do that, when they want a rotating banner effect for their website or whatever. Once you get into more complex applications it doesn't really make sense to do that anymore.
- k__ 13y agoI see... maybe if you get fluent enough with JS, you're just faster hacking such little scripts than finding a page, copy it and reassemble it.
- jiggy2011 13y agoWell jquery-ui solves this problem to a large extent, if you want something like say a datepicker you can do $("#datepickerelement" ).datepicker(); and get the functionality you need in a nice reusable package without having to copy and paste giant chunks of code and pollute your global namespace.
- wwwtyro 13y ago> Enter asm.js, where the source code is as readable as a compiler's assembly output. What do you mean? Isn't it roughly as readable as C?
- jerf 13y agoNo, it's roughly as readable as decompiled executable, without even a symbol table to provide semi-readable names. John Resig has a somewhat reformatted example a couple of pages into this: http://ejohn.org/blog/asmjs-javascript-compile-target/ http://ejohn.org/blog/asmjs-javascript-compile-target/
- azakai 13y agoTo be fair, you can generate asm.js with quite readable names (use -g in emscripten for example). asm.js does not require that you also minify variable and function names (and whitespace), that is orthogonal, and done on all JS these days anyhow. If you do not minify the output, then asm.js's readability is somewhere in between x86 and C. It's far easier to understand than x86, but it is still definitely less readable than handwritten C because it's machine-generated and optimized.
- wwwtyro 13y agoI'm not following you. Are you referring to the minimized code that has been beautified? Of course it is not going to be particularly legible. Same for any minified code, asm.js or not. From the link you gave, the DiagModule function is asm.js, and every bit as readable as C.
- jerf 13y agoSorry, I was unclear. In this context, which if you follow back up to arocks' post is in the context of using "View Source" to learn how things are done, I'm referring to the sort of asm.js that comes out as a result of compiler output, not stuff written by hand. The Gist is what I was pointing at. There is no way you're going to read that and learn how, say, the Unreal Engine port does something. I think people may think I'm trying to be faintly critical, but I'm not. It's just the nature of the beast.
- jerf 13y agoDoes it matter anymore, though? Back in "the day", documentation was poor and nobody knew what they were doing. Document is massively better now. Javascript libraries abound, perhaps to a fault. Does anybody learn how to program the web by looking at other people's work now? In those rare cases I've done this in the last few years, the sum total has always been to find out which CSS property or JS function I didn't know about was being used, and then simply pop that into Google. I certainly didn't stare at their code for any longer than that.
- zampano 13y agoWow, I'm still a relative newcomer, but I constantly pull up the CSS and JS for any site that seems interesting. Considering how easy Chrome devtools makes it to play around with sites, I figured most enthusiasts/professionals were doing the same thing.
- mistercow 13y agoBut we already had arrived at the point of unreadable source code with the advent minifiers and tools like Closure Compiler.