Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

There are no end of alternatives out there today, from mobile platforms to research languages exploring a myriad of aspects of computer science.

Just let me know when browser vendors are going to break down the two-tiered system, and let us run the legion of alternatives alongside -- instead of under -- JavaScript.

Or, they could take their own medicine, and try and write the browser in JS.



> Just let me know when browser vendors are going to break down the two-tiered system, and let us run those myriad of alternatives alongside -- instead of under -- JavaScript.

The complexity of doing that would be needlessly high compared to just improving JavaScript. Having to integrate a C++ DOM with a JS DOM is hard enough. Think about how you handle cross-language cycles…

> Or, they could take their own medicine, and try and write the browser in JS.

You mean like Firefox?


>> Or, they could take their own medicine, and try and write the browser in JS. >You mean like Firefox?

This is a very strange comment, especially coming from you.

Everybody knows that the bulk of Firefox is not written in JS. You personally have spent years of your life working on a new programming language precisely because JS is not suitable for writing a web browser.

I'll take your position on JS seriously when you abandon Rust and begin writing the bulk of Firefox in JS.


It would actually be a very interesting experiment to try running Servo Emscriptenified (with SharedArrayBuffer, of course). I wouldn't want to write a browser in the full JS language, but that's precisely what asm.js is for.

"You should abandon Rust and write in JS" presupposes exactly the kind of strawman I've been arguing against. You don't have to abandon your favorite language!


Works on OSes. We have a choice.

In browsers, the OSes of the web, nope, just a bad language designed in 10 days that resists all attempts to make it not bad.

It doesn't really matter if you like javascript, there's so many people who don't.

Why do you get to dictate whether we can or can't develop on the web? You leave us with a horrible choice, use what we consider to be one of the worst modern languages, or not develop. Why do you get to make our professional lives miserable?


> Works on OSes. We have a choice.

The kernel doesn't have a DOM. On the Web, the number of GC'd objects that every "process" has to deal with exceeds the number of file descriptors by an order of magnitude.

Also, you do have a choice: you can compile your favorite language to JS, even low-level ones via asm.js.

> Why do you get to dictate whether we can or can't develop on the web? You leave us with a horrible choice, use what we consider to be one of the worst modern languages, or not develop. Why do you get to make our professional lives miserable?

That's not the choice: you can compile your favorite language to JavaScript. That's what source maps, asm.js, and the like are for. And JS is being improved all the time; it's not static.

Trying to add another language has been tried multiple times and has always failed, because having two languages that both interact with the DOM is much more difficult than just improving JS.


Semi-serious question: Other than backwards compatibility, do browsers need to have a DOM? It seems like many web app devs spend more time fighting against the DOM than working with it. Why not just make the browser expose a generic GUI model? Let web devs interact with Webkit or QT directly?


Generic GUI toolkits are very often worse than the DOM. I've worked with Swing, MFC, SWT, Android, and iOS, and all of them are significantly more complicated than the DOM is. They do function at a higher level of abstraction, and the two really nice things they give you are components and a sane layout system (solved by WebComponents and Flexbox, now if only all the major browser vendors would just adopt WebComponents...), but in general I've found that iOS development is about 1.5x-2x slower than web development and native Android development is about 3x slower, roughly on par with Swing or SWT. MFC was a clusterfuck, I wouldn't even go there.

The way frontend devs for other platforms deal with it is to specialize in the nuances of the platform and effectively build your app around the capabilities that Google/Apple/Microsoft/Sun provide. That's fine, and makes for a fairly uniform, polished experience if you have good devs, but it significantly restricts the set of apps you can build. The reason web developers like developing for the web is because it doesn't make you a sharecropper in Google/Apple/Microsoft's world, while building a full-featured GUI framework into the browser would.


I've found JavaFX's scenegraph approach rather neat. Effectively it borrows from HTML, but where the basic node set is designed to be UI elements rather than co-opting a set that was designed for text documents. It seems to take a surprisingly small amount of code to sketch up an interface.

React's not bad on the web side (especially with Scala.js) but fudging around layouts in components with divs and Bootstrap still feels clunky.


I still remember how super easy and fast was to make a GUI in Delphi/C++ Builder - what took a month in MFC/Swing took about an hour in Delphi. Even Qt feels like a massive step back from this...


> The kernel doesn't have a DOM.

Also, the kernel's written in C (maybe Rust in part, soon). So much for language choice!

Sure, in userland, many languages compile to assembly. Hmm, where have I heard that word lately?


It doesn't actually work on (GUI) OSes - there is a strong incentive to write your app in the language and framework that is native to the platform, because you're asking for a lot of pain and a substandard customer experience otherwise. You write your Windows apps in C# and .NET. You write your Android apps in Java. You write your iOS apps in Objective-C, and now Swift. You write your Gnome apps in C with Gtk+, and your KDE apps in C++ with Qt, and your Eclipse plugins in Java with SWT, and your Emacs extensions in Emacs Lisp. In all these cases (except Apple), you can write your apps in a different language, but virtually nobody does, because you end up fighting the platform.

Servers and command-line tools are an exception because your interaction with the host platform is limited to a few dozen syscalls that can be easily bound to a number of different languages. Not so with most GUI software.


(Including Apple; the rule to the contrary didn't last very long after its introduction a few years ago.)


> just a bad language designed in 10 days that resists all attempts to make it not bad.

This is unnecessarily inflammatory. I've been writing JavaScript since back when it was called LiveScript and while it's certainly not my vision of the perfect programming language, it's come a long way. The code I write now is considerably cleaner, easier and more reliable than the code I was writing in 2005, much less 1995.


> Works on OSes. We have a choice.

No, it doesn't work on OSes. OSes only handle one language: the native machine code of that platform. Everything else must be compiled to it.

This is exactly the same as browsers.

Edit: At least two people disagree with me (-1 points) - would you mind elaborating why?


Your point is irrelevant, then difference then becomes the fact that at an OS level I can choose what code I compile into machine code and in the browser I can't.


No, for OS you decide which compilator to choose. As is with browsers. There are several languages (e.g. TypeScript, CoffeeScript, Dart) which can be compiled to JS.

That is not what I personally like (the processes of compilation and deployment I mean), but if you develop for OS then you have to compile before you run... In most OS.


> Your point is irrelevant, then difference then becomes the fact that at an OS level I can choose what code I compile into machine code and in the browser I can't.

Uh, what? You do have a choice in the browser. I don't understand.


The web consists of untrusted code. Thus it needs to run in an a sandbox. Creating a secure and fast sandbox is an incredible undertaking.


I think the web is getting better in this regard. Since the introduction of emscripten and asm.js there have been some improvements to the tooling and runtime to make it so you can just write your app in C or C++ without really thinking about JavaScript.

It's only a matter of time before other languages can have the same level of support.


I think you are onto something ;-).


Chrome was trying to do this: https://developer.chrome.com/native-client

However, cries of foul "vendor lockin" erupted. So I dunno what to tell you, man.


...no they weren't? They let you embed native code (platform-specific) or LLVM IR (vendor-specific) into a webpage. I don't see what that has to do with support for other languages. Anything NaCl can do, asm.js can do too, but one of these has multiple implementations, is backwards-compatible, is truly cross-platform, is well-specified, and is standardised. (Hint: it's not the first one.)


14paninta's comment is dead again - shadowban? Anyway, I'll repost and respond:

> asm.js doesn't support threading.

asm.js supports threading, actually, through Web Workers and SharedArrayBuffer.

> it can't run native code.

This is true, but asm.js is relatively close to the metal. It's not very far from assembly language.

> it doesn't support meaningful debugging.

This is a tooling issue. While the situation is bad at the moment, it'll surely improve.

> it doesn't have a post-DOM API surface like pepper.

Why do you need a "post-DOM API surface"? If you just want to blit stuff to the screen, the DOM is actually no less efficient than Pepper: you can directly pass it pixel buffers, or call OpenGL routines.


Asm.js could be considered close to the metal if you were running on a Pentium 166. I'd consider it close to the metal if it had features modern processors have, like SIMD, operations on integers that have other than 32 bits, IEEE-754 compliance, etc.

With the threading issue, Web Workers are boxed up so tightly that there are a lot of operations, like passing objects between threads, or letting web workers have access to portions of the DOM, are impossible. Additionally, because everything's passed by value, there's a lot of copying that needs to take place; to expand on my prior example, sending a message to another thread would involve copying the object to send to the main thread, then copying it again to send to the destination thread. The alternative, transferrable objects, completely deletes the object being passed, and still can't be transferred between threads. Finally, there is no pooling control among threads, which means that there is a lot less control over what threads are running at any moment.

These problems all come back to the fundamental issue. There's no escape from javascript. Asm.js is fundamentally hung off of javascript with bailing wire and duct tape, out of fear of "breaking compatibility". Anyone that tries to experiment with a new language is immediately accused of trying to fracture the web. Thus, we stagnate, and everyone suffers for it.


I've never used web workers, but as a developer who has written a lot of multi-threaded code in C++, I'm kind of glad that as a user I don't have to suffer poorly written non-thread-safe JavaScript. I've seen some terrible multi-threaded code by developers who just didn't get it. I suppose that's why web workers are designed the way they are: to make it easier for developers who maybe don't quite get the intricacies of multi-threading.


> I'd consider it close to the metal if it had features modern processors have, like SIMD, operations on integers that have other than 32 bits, IEEE-754 compliance, etc.

It has all of these things. It has SIMD now, 64-bit support is improving, IEEE-754 is supported (though some of the checks aren't available yet, I'll give you that). Give it time.

> With the threading issue, Web Workers are boxed up so tightly that there are a lot of operations, like passing objects between threads, or letting web workers have access to portions of the DOM, are impossible. Additionally, because everything's passed by value, there's a lot of copying that needs to take place; to expand on my prior example, sending a message to another thread would involve copying the object to send to the main thread, then copying it again to send to the destination thread. The alternative, transferrable objects, completely deletes the object being passed, and still can't be transferred between threads. Finally, there is no pooling control among threads, which means that there is a lot less control over what threads are running at any moment.

Yes, but this stuff isn't applicable to asm.js. It shares a heap between threads, it's just like your old native code, and everything is triggering race conditions^B^B^B^B^B^B^B^B^B^B^B^B^B^B^B^B^B^B^B^B^B^B^B^B^B^B^B hunky dory.

> These problems all come back to the fundamental issue. There's no escape from javascript.

What's wrong with that? If you don't like JS, you can compile to it. It's an excellent compile target.

> Asm.js is fundamentally hung off of javascript with bailing wire and duct tape, out of fear of "breaking compatibility".

It's not just a compatibility hack, though managing to work on everything with no updates is a killer and awesome feature. It also avoids unnecessarily reinventing the wheel. It reuses as much of JS as possible. That's good.

> Anyone that tries to experiment with a new language is immediately accused of trying to fracture the web.

...well, yes, they're fracturing it. And usually needlessly. There'd be no benefit to a new language on the web. There's nothing a new language can offer which JS doesn't have.

> Thus, we stagnate, and everyone suffers for it.

What stagnation? Everything is moving rapidly. Things are improving all the time.


Simd.js is only supported on one and a half browsers, is only supported on a single platform, and only supports two data types. I'd hardly call that supported, more like being hacked together. Its current implementation requires you to waste quite a few clock cycles and bytes of memory if you want to do things like graphics operations. 64 bit support is at the, "hey, you can store numbers. Have fun creating all the operations for them" stage." Furthermore, it deviates from the IEEE-754 standard in things like number handling -- Math.max(5,NaN) should return 5, not NaN. This means that libraries written in other languages and transpiled using emscripten and the like will not behave as they should.

I'd say that the weaknesses of web workers is absolutely relevant. Though you see it as protecting the coder from themselves, there are design patterns out there, like publish/subscribe, that are useful in letting threads communicate, but not generating race conditions. DOM access and the like can be done sanely, but Javascript doesn't even give you that option.

Given the reasons described, it's a rather poor compile target. It's a plodding beast of a language that mishandles numbers, requires circuitous coding to handle basic concurrency, and otherwise behaves in ways other languages don't. Transpiling just barely hides its flaws.

I will restate that it is a hack, and a rather ugly one. Its attempts to maintain compatibility leave us with a virtual machine that is increasingly obsolescent. An "assembly language" designed in 2013 shouldn't be lacking support for 64 bit integers (or 8-bit or 16), should have good support for vectorization, and should provide some sort of register and/or stack model so that you can better clue in the vm as to what items are going to be frequently used in functions. The missing features could be handled much like JSON was early in its life, by including a library as a fallback. It would probably end up looking ugly as hell, but at the same time, it would work, and give a lot more long-term benefits.

Regarding alternative languages, Javascript isn't always the best language to describe a problem in. Sometimes your program's better written in C, or Lisp, or Fortran even. Why should you force your problem to fit the language?

Regarding stagnation, you can move quickly, yet not really go anywhere useful. COBOL had 7 major versions and several minor in 14 years. Does it mean that it's a useful language today? The stagnation comes in terms of how people think of problems, and how they try to wedge those problems to fit into Javascript. The web would be a much better place if we allowed more experimentation into languages and behavior.


I think you're right that they weren't trying to do this with NaCl. They really were trying to do this with Dart, though.


Well, Dart would've been one other language in the browser, sure. But it's a language not that different from JavaScript in actuality. The benefits seem few for the work needed to support two different languages. Compiling to JS, which fits Dart quite well (probably because it was designed to compile to JS well), seems more productive to me.

Some were excited Dart might lead to some sort of bytecode VM being added, but that didn't lead anywhere. And since then, JS has become more bytecode-like, so it doesn't really matter now anyway.


As more and more people write software in languages that compile to JavaScript instead of directly hand-writing JavaScript the demand for JavaScript becoming a better compile target grows.

In that sense adoption of Dart, ClojureScript, TypeScript, Elm et all will continue to accelerate JavaScript (language and runtime) improvements.


All part of the plan. I've been saying this since 2012, Dave Herman and Alon Zakai of Mozilla Research (asm.js creators along with Luke Wagner) said it before me:

http://brendaneich.github.io/Strange-Loop-2012/#/21

Love it when a plan comes together!


> but one of these has multiple implementations, is backwards-compatible, is truly cross-platform, is well-specified, and is standardised

None of these problems would be difficult to address if the four-member vendor cartel which controls web "standards" was willing to adopt NaCl. Of course they don't want to adopt it, but that is the real problem right there. Of the four, two members (at least—maybe now three) have an active interest in holding back the Web to protect their native app platforms, while one would rather reign in Hell (through its position of shared mastery over the Web hairball) than go broke in Heaven. As to support for other languages, I only have to point out that one of Mozilla's reasons for decrying Google's intended browser support for Dart was that Dart compiled to JS would not be competitive with the native Dart implementation.


Nope! (On everything you wrote, including "the" and "and".)

Also: loser talk is loserly. PNaCl (did you mean PNaCl not NaCl? NaCl was never proposed by Google for the Web) like Dart fell to physics. All else is stamp collecting.


So that others may judge for themselves: https://news.ycombinator.com/item?id=3092921


You didn't link to any of my comments, so let me help your reading comprehension.

My point then was that if Google had had MS's IE4-6-era market share and lack of scruples, they could have pushed Dart into Chrome and started using it in their web properties, and the lack of equivalent performance between DartVM and dart2js -- especially due to lack of bignums and other affordances in JS, which lack Google materially increased by choosing to invest in Dart over JS -- would have stunk. It would have verged on the monopoly abuse of which MS was in fact convicted.

My point was not that JS must be the only way to run Dart simply because I or anyone at Mozilla (or anywhere else, MS and Apple included) prefers JS. That would be dumb, and it's clearly not what I wrote.

Browser vendors have to keep JS improving. That's a given. Adding the extra costs of DartVM and the inter-heap GC and write barriers to glue it into the shared DOM client side is a huge tax, which would have helped kill Mozilla faster. MS and Apple wouldn't pay that tax. Why should anyone? Again it's not about JS being uncompetitive. "Competitive" is what browsers are when they run web content better and faster. Dart has very little to do with this.

JS is very, very hard to replace, for reasons I summed up as "physics" (apologies to Rutherford) and won't belabor here. Yet the Dash memo proposed to do just that, to replace JS, using lame assertions about how JS couldn't be fixed.

That was not just lame posturing and excuse-making for a Lars Bak retention program. Given Google's power, it was a disservice to the Web as a standards-based and ever-evolving platform, whose caretakers are obligated to keep working on it in the open, not try proprietary end-runs. (Yes, of course, many people at Google work hard to improve the Web. Good for them, but not relevant to what happened with Dash.)

I'm happy to say I was wrong to worry about Google succeeding in acting like MS did with ActiveX/VBScript. Not that some at Google didn't try (or won't again with other stuff), but they failed with Dart. I predicted that, too, as an ultimate outcome after wasting years and megabucks -- including real opportunity costs to V8 and JS. So too did many at Google predict this crater.

Dart's a compile-to-JS language now, not due to any preference for JS by anyone at any browser vendor.

Get it yet?


> My point was not that JS must be the only way to run Dart simply because I or anyone at Mozilla (or anywhere else, MS and Apple included) prefers JS. That would be dumb, and it's clearly not what I wrote.

I've never suggested that this is what you were saying there. Here I pointed to it as evidence that I was right that "one of Mozilla's reasons for decrying Google's intended browser support for Dart was that Dart compiled to JS would not be competitive with the native Dart implementation", where by "competitive" I was obviously referring to performance. Since we're agreed on that, the claim that everything I wrote above was wrong 'including "the" and "and"' goes out the window. (What I did point out to you at the time is that this was hard to square with the claims being made elsewhere for JS' wonderfulness as a compile target.) Your take on Google's intentions in proposing Dart is also completely in line with my argument that the vendors of major browser engines have huge power basically not constrained by anyone besides the other three vendors, as well as motives that don't always align with the public interest.


The "and" and "the" line was from Mary McCarthy in reply to Lillian Hellman. You're Hellman :-|.

You wrote:

"As to support for other languages, I only have to point out that one of Mozilla's reasons for decrying Google's intended browser support for Dart was that Dart compiled to JS would not be competitive with the native Dart implementation."

The empty rhetorical flourish ("I only have to point out...") aside, this is rank question-begging. You assume that JS as Dart target being too slow must mean DartVM should win because of "competitive" force. Wrong on at least two counts (I'll ignore market power abuse):

First, DartVM may be faster at semantics JS supports due to optimization problems on the JS engine side. V8 in particular lost its founding team to DartVM, except for some moonlighting. Therefore "competitive" does not mean that JS cannot improve to be as fast when compiled from Dart as when the Dart source runs in DartVM.

Second, DartVM may have types and optimizations that JS lacks, bignums for example. Again "competitive" does not mean JS cannot change, and in fact bignums have been on the ECMAScript Harmony agenda since 2010, before "Dash" leaked.

In any competitive market with deep tech, there are lots of ways to meet a set of developer-facing language support/performance requirements. Even with all Google's billions, Dart and Chrome decision-makers couldn't ignore the compile-to-JS alternative and continue to justify developing and shipping DartVM + OilPan + all else not fully in hand to support JS and Dart with no performance regressions. Compiling to JS is the sole path forward for Dart on the Web precisely due to competition.

Citing my argument about bignums is perversely wrong, unless you assume DartVM is the only solution to any DartVM vs. dart2js performance disparity.

Such an assumption, like the one you seem to have made about NaCl, is anti-competitive, uneconomic, magical thinking. It requires indefinite amounts of time and money to fund all the work to have two VMs, a super-GC to collect cycles, write barriers as part of that super-GC, and more optimization to overcome the performance regressions imposed by those barriers (if possible). It assumes JS can't more cheaply be extended to be a fast-enough target language. You offer no proof.

BTW, you started out with NaCl and I still think you're mistaken about something pretty fundamental. NaCl was never proposed as a Web standard. Ok, suppose you mean PNaCl. The problem remains that PNaCl required a big API, Pepper, to reach the guts of chromium/Blink (originally WebKit) and the underlying OS. The problem with PNaCl was always Pepper, and again: competition killed Pepper as a cross-browser API.

It takes longer (it would have happened sooner with more cooperation from Google earlier, instead of the malinvestment on these two big follies), but JS is getting SIMD and shared memory threads, which are among the last few bricks still standing in the Pepper wall.

So PNaCl is evolving with Emscripten/asm.js now -- precisely due to competition -- and I would not hold my breath for PNaCl to remain based only on LLVM bitcode (with fixes requiring years and millions, to remove unspecified behavior). But feel free to hold your breath and then blame the "vendor cartel" if you like.

On that "vendor cartel" point, there are more web engines coming along, Servo (an open source project with multiple paying companies involved) among them. There's no cartel, just a big compatibility hill for any new engine to climb.

Adding gewgaws like NaCl and Dash slows down that climb. It's uncompetitive for the would-be market entrant. Why you think this requires collusion ("cartel") or Satanic pride ("reign in Hell") is unclear. Do you get many billion-dollar free lunches where you live?


> Just let me know when browser vendors are going to break down the two-tiered system, and let us run the legion of alternatives alongside -- instead of under -- JavaScript.

Just let me know when Intel, AMD and VIA are going to break down the two-tiered system, and let us run the legion of alternatives alongside -- instead of under -- x86 assembly language.


14paninta replied to this, but their comment's dead (shadowban?) - anyway, I'll repost it here and respond to it.

> What does that even mean? It's nonsensical.

What it means is that the situation with browsers is not much different from the situation on native platforms. CPUs support one language, the browser supports one language. And yet I don't see anyone complain about CPUs only supporting one language, because you can compile anything to it. The same is true for JS, so why do people complain?

>Underneath x86 assembly language is the processor microcode, and underneath that is the actual hardware, and the two are intricately intertwined.

Underneath JavaScript is native code produced by a JIT compiler. It's not super-intricately intertwined with the underlying OS and hardware, but it's not incredibly abstract either.

>You can replace the hardware; C compiles, for example, to everything from ARM to x86 to Atmel's AVR harvard architecture.

>You can replace the language; everything from C to Swift to Rust can target almost any processor architecture, without externally enforced limitations.

You can also retarget stuff compiling to JS to compile to something else, like Lua.

>Microsoft can ship the CLR for ARM, x86, PowerPC.

> You can't replace JavaScript. Everything must pass through a JS JIT, and the JS JIT is written using functionality that 1) it requires, and 2) is totally unavailable to you.

Yes, everything must pass through a JS JIT... you don't have access to the underlying native code. But everything on a CPU must pass through its microcode translator. That uses functionality it requires which is unavailable to you.

> Microsoft can't ship a fully functioning CLR for JS.

This simply isn't true. You can write a CLR for JS that compiles to something like asm.js at runtime. Bytecode VMs with JIT compilation have been written in JS before, see Emterpreter for instance.


> What it means is that the situation with browsers is not much different from the situation on native platforms. CPUs support one language, the browser supports one language. And yet I don't see anyone complain about CPUs only supporting one language, because you can compile anything to it. The same is true for JS, so why do people complain?

Because we don't write assembly ourselves. Unless we are doing micro optimizations, we don't even have to look at it. We do however, have to look at your shitty JS.

JS is not the "assembly of the web". It's a high level language. Your comparison is idiotic.


If you write in Coffeescript or Clojurescript, you're not writing the "assembly" yourself. It's a perfectly valid comparison, and JS being a high-level language doesn't change anything.


> Because we don't write assembly ourselves.

Well, you don't write assembly because it's not pleasant to write in. JavaScript is actually quite high-level by comparison, so you can write in it, and many people do.

> Unless we are doing micro optimizations, we don't even have to look at it. We do however, have to look at your shitty JS.

You don't need to look at generated JS either. If the tooling sucks then you do, but that is only because we live in early days, and the tooling isn't quite there yet.

> JS is not the "assembly of the web". It's a high level language. Your comparison is idiotic.

It is a high-level language! But it is also a good compiler target, and contains a low-level language (asm.js) which is also a good compiler target.

It's not a poor comparison.


> Or, they could take their own medicine, and try and write the browser in JS.

Like Blink-in-JavaScript[0] ? ;)

[0] https://www.chromium.org/blink/blink-in-js


Internet Explorer had a pretty clean API for adding extra scripting languages.


And in practice, that separation layer lead to objects tied together across COM boundaries, and severe memory leaks for any significant applications.


Yes, the Windows Script Host. But I don't believe two languages could very effectively talk to eachother, right? Couldn't they only really interact with the native code stuff (DOM etc.), i.e. the easy part?


It wasn't too difficult to add an interface to COM from a new language, that seemed the easiest way to call "out" to something else.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: