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

Oh come now, there are good reasons to compile to JS if you are doing things in a browser.


Not direct technical reasons, no.

The only indirect technical justification is in maintaining compatibility with existing browsers, but that falls over pretty fast when you're a browser maker (Mozilla) and refusing to work with another browser maker (Google) on jumping over that compatibility hurdle.


"Maintaining compatibility with existing browsers" is like saying "emitting machine code for CPUs that actually exist".


Introducing a browser bytecode and/or sandboxing is not anywhere near the scale of complexity and expense of inventing a new CPU architecture.

It's a policy decision, not a technical decision.


Replacing JS may not be technically difficult, but practically it's extremely difficult (IE6, anyone?). Plus JS has got so fast, it's becoming hard to see the point anyway.


> Plus JS has got so fast, it's becoming hard to see the point anyway.

Native is faster. A lot faster. And that's what browser apps are competing against.


asm.js ? It's essentially almost typed intermediary language which can be directly/easily translated to CPU instructions.



Getting your bytecode working in shipping in all browsers has proven to be impossible; there's a reason people compile to Javascript, it's the only practical choice.


It's impossible because Mozilla won't work with Google, not because it's actually impossible.


Even if they did, that's not enough, you have to get it into all popular browsers, not just two. JavaScript works everywhere, you have to match that to have any hope of replacing it.


Two browsers is more than enough to shift the industry, and there's still nothing stopping you from supporting JS as a legacy compilation target.


No it isn't; if you can't get Microsoft and Apple on board, it won't shift. It'll take more than Mozilla and Google cooperating to replace JS.


Ah, so it will lose because it will lose. So we can't implement it because we won't implement it.

That's ridiculous. Mozilla is willing to stick their neck out there implementing a mobile phone operating system, but trying to deploy a sane runtime environment to replace JavaScript is just too risky?


It is ridiculous, but it's also reality.


It's reality because Mozilla makes it a reality. See how this is a circular argument?

Meanwhile, native mobile and desktop keep growing, and growing, and the web as an application platform loses out, because none of the native platform vendors are quibbling about whether they can convince themselves to ever do something different than what they were doing before.


For my company, this is exactly what's happening. Like Facebook, we found HTML5 to be insufficient for our app, so our resources have shifted to iOS and Android development. Native gives much better and consistent performance and UX, and the idea of write once-run anywhere on the web is still a pipedream. Cross-browser compatibility is still terrible.

The problem with HTML5 is it was designed by committee for displaying documents not dynamic apps. While JS has come a long way to closing the gap with native performance, it's the other HLML5 tech that's holding the web back. CSS is ill-suited to be hardware acceleration and DOM is a performance sucking hack that kills the UX on mobile platforms.


> Mozilla makes it a reality

No, the situation makes it a reality; Mozilla doesn't control Apple or Microsoft.


That didn't stop them from trying to launch a mobile phone platform in competition with Apple, Microsoft, and Google.

If they're willing to accept that risk, by comparison, how large of a risk is trying to push through a better standardized browser execution environment, with Google's cooperation?

God forbid they succeed, and we finally have a competitive application platform.


I see; you're the type who thinks he's smarter than everyone in the industry and just has all the answers and ignores anything that doesn't fit your idea. Never mind that no one has been able to replace JS, just listen to you and all those problems will evaporate. Goodbye.


> I see; you're the type who thinks he's smarter than everyone in the industry ...

You mean, like Google, who continually pushes to do exactly what I've described here, only to be stymied by:

- Apple, who has no reason to support the web as competitive to their native platform.

- Microsoft, same.

- Mozilla, who refuses to consider that there might be a world beyond HTML/CSS/JS because they believe those specific technologies are intrinsic qualities of the web, and thus central to their mission of supporting the web.

Looks like the only people I disagree with are the Mozilla camp. Microsoft and Apple have different priorities, and Google is continually frustrated by exactly what I've described here.


Every major browser vendor has pushed for some stuff and resisted other stuff. Only extremely rarely does anything new make it to 'cross browser compatible' status.

There are far far worse systems for evolving widely used platforms.


> There are far far worse systems for evolving widely used platforms.

That's fine, but perhaps it would behoove Mozilla to not participate in dooming the web as a competitive application platform simply due to a misguided belief that the web is defined by HTML/CSS/JS?


Agreed, CSS/DOM/JS need to be replaced, before the web can truly be an application platform.


> only to be stymied by:

Reality. Imagine that.


Yes, the reality is that proprietary application platforms are taking over the application market, and that the web is slowly losing one of its major market advantages: a huge brain trust of web-only engineers and web-only engineering organizations.

Imagine that.


LMAO. No such thing is happening, the web isn't losing anything nor does the rise of apps on mobile threaten the web.

> the reality is that proprietary application platforms are taking over the application market

That doesn't even make sense as proprietary application platforms have always owned the application market.


> No such thing is happening ...

You're asserting that there hasn't been a significant management and hiring shift in engineering departments over the past 5 years, moving away from what became a web monoculture in the post-90s environment, from roughly 2000-2005?

> That doesn't even make sense as proprietary application platforms have always owned the application market.

So you admit the web is ill-suited to serve as an application platform, and is failing to acquire traction in that space despite considerable but ill-focused efforts to the contrary?


You can't even stay on topic without constantly moving the goalpost.

> You're asserting that there hasn't been a significant management and hiring shift in engineering departments over the past 5 years, moving away from what became a web monoculture in the post-90s environment, from roughly 2000-2005?

I asserted no such thing, learn to read.

> So you admit the web is ill-suited to serve as an application platform, and is failing to acquire traction in that space despite considerable but ill-focused efforts to the contrary?

I admit? What kind of stupid opening is that? Show me where I said anything about the web serving as a great application platform over native apps.

You know what, never mind; you're an argumentative ill tempered child who doesn't know how to have a discussion properly. Have a nice day.


> You know what, never mind; you're an argumentative ill tempered child who doesn't know how to have a discussion properly. Have a nice day.

One of us has stuck to discussing the topic, the other, discussing the person. Good day.


You're joking, right?


No. As someone intimately involved in startup hiring, there's been a massive shift in the make-up of technology organizations.

Mobile has gone from a side-show farmed out to consulting organizations to a mainstream in-house development effort, and the organizations themselves have shifted management and priorities accordingly.

It used to be that almost everyone had a web engineering organization in-house, even non-technology companies. That is changing. Companies like the NYTimes have gone from being grossly unable to manage mobile efforts and farming their work out to subpar contractors, to straight-up building a top-quality team of mobile developers.

Here's the tricky thing about that, too. Those developers, by the nature of where they work in the technology stack, are already quite versatile, and can choose technology solutions outside of the web stack. The problem that most organizations faced originally was that their web departments were a mono-culture and couldn't adapt.

So now you have companies that can and are building technology outside the web, and that means that the network effects that existed before are being torn down. The web tried to leap onto the application bandwagon, and the web failed. Now other technologies are taking over that space.


I've been developing for proprietary and web platforms for a long time too. I really don't see that the rise of mobile is in any way coming at the expense of the web.

Who are these development organizations who truly enjoy maintaining five different apps for all the major desktop and mobile platforms and who are aren't going to make the jump as soon as HTML5 delivers everything they need?

Obviously there will always be applications (antivirus, encryption, etc.) for which a browser is poorly suited. But this percentage will never be bigger than it is today.


> ... who are aren't going to make the jump as soon as HTML5 delivers everything they need?

When will that be, exactly? The promise has been a long time coming, and in the meantime, the constitution of the industry is shifting away from a web myopia.


He's not; he thinks he's being insightful.


What's your excuse?

Mobile is growing hand-over-fist and web apps developers are still arguing about whether they're fast enough to compete, and whether we could possibly maybe actually move past HTML/CSS/JS sometime in this decade.

It's ridiculous, and you claim it's "reality". Fine, your reality sucks, and there's no inherent reason why it has to win ... and it might not.


There's only one reality, that's rather the point of the word. Web app developers and mobile app developers are different fields, they aren't competing. The web is and will likely remain HTML/CSS/JS because it works: EVERYWHERE, and it doesn't look like that'll be changing anytime soon.

Browser plugins are dead and they're not coming back.

Yes, really.

It's time to move on.


Nobody is proposing that.

Neither NaCL, PNaCL, nor asm.js are 3rd-party browser plugins.

I agree that it's time to move on. It's time to treat the web as a real application platform, instead of as document model with a JavaScript scripting interface.


NaCL, PNaCL aren't plugins because they're features of one specific browser. I don't know of any 3rd party developers using them.

I think asm.js is brilliant and I hope it does turn out to be the way forward. But it's also a poster child for maintaining compatibility with existing browsers through standard Javascript.


Can you explain specifically what you mean by a "direct" vs. an "indirect" technical reason?


Direct: Constraints/requirements directly related to implementing a maximally effecient runtime architecture.

Indirect: Market constraints that drive technical limitations.

When it comes to browsers, Mozilla both creates and exists within market constraints that drive indirect technical reasoning.

Lashing your industry to JS for another 10 years as a bytecode target is clearly not an optimal long-term solution as compared to the current state of the art, but it might make sense as a legacy support mechanism given the indirect technical constraints.


I'm just not convinced that something like CoffeeScript would benefit technically from compilation to a different target than JS. When the purpose of a language is simply to have all the features of another language, but with nicer syntax, what is to be gained from rebuilding all of those features from scratch?

The one quasi-counterexample I can think of in that subset of languages is Objective-C which essentially just adds sugar on top of C and can be transformed relatively simply to C (there are library functions you can use to build classes and objects and call methods from scratch, using no actual Objective-C syntax). My understanding is that Objective-C compilers don't go through C as an intermediate, but this is merely to reduce compiling time, not to improve efficiency at runtime. If Objective-C did target C instead, the end result would be identical.


So in other words, you are defining away most of what drives technology decisions.

That makes it totally uninteresting to try to meet your constraint.

We pretty much never try to implement a maximally efficient runtime architecture, cost or resources be damned.

By this argument, there's no direct technical reason why we should not spend 20 years hand writing machine code and proving the code sequence optimal for each target architecture.


> compared to the current state of the art

What do you consider the current state of the art?


JVM, CLR, Mono AOT complation, NaCL/PNaCL.

A future in which we wind up with architectural support for NaCL-style sandboxing intrinsics, in the same way we saw them be developed for VT-(x|d).

Sticking us with JS for another decade and expecting us to compete against better application runtimes? No.


Those examples are all very different. What is your goal - speed? Code size? Portability? Security? Those examples don't all achieve those to the same degree, and I would argue that modern JS VMs are competitive with them in many respects.


> What is your goal - speed? Code size? Portability? Security?

That depends on the target. I selected them because they represent different aspects of the state of the art.

> ... and I would argue that modern JS VMs are competitive with them in many respects

But not all, and in many places, not even close. JS VMs make trade-offs that we don't need if we abandon JS, and on top of it all, you have Mozilla insisting against shared-state multi-threading supported and exposed by the VM, which discards enormously important optimization opportunities) -- and that's just the tip of the iceberg.

Get rid of JS, get rid of Mozilla's self-enforced constraints on the browser, and look very seriously at something like NaCL which blends native execution performance (including being able to drop to SIMD instructions) with security sandboxing.

Let language authors target the low-level machine, and target your high-level general purpose bytecode.

Once you've built a runtime in which I could implement a JS runtime that's as performant as yours, we will no longer be operating in a two-tier universe in which browser makers think that JS is good enough for everyone but themselves.


JS VMs make tradeoffs, yes. Regarding your specific examples:

1. Shared-state multithreading. This has been proposed by various people in the past, and is still being debated. There are people for it and against it in various places. It might happen, if there is consensus to standardize it.

2. SIMD: PNaCl (which I mention since you mention NaCl in that context) does not have SIMD. But of course it can add SIMD, just like Mono and Dart have, and there is a proposal for JS as well, hopefully that will get standardized.

So even those limitations are in principle resolvable. They do depend on standardization, of course, but so would any VM you want to run on the web.

> Let language authors target the low-level machine, and target your high-level general purpose bytecode.

asm.js is meant to get performance similar to a low-level machine. It's already very close to native on many benchmarks.

> Once you've built a runtime in which I could implement a JS runtime that's as performant as yours

I don't follow that. You can't make a fast JS runtime in your previous examples (the JVM, PNaCl, .NET, etc.).


> I don't follow that. You can't make a fast JS runtime in your previous examples (the JVM, PNaCl, .NET, etc.).

I included ones you could, such a NaCL. And I should probably have also included the native platforms (Apple, MS, Google), because they're the competition, even if their sandboxing or runtime environment isn't what one might call 'state of the art'.

At the end of the day, it's the two-tier universe that bothers me the most. You're content to foist the JS runtime on everyone but yourselves. Once you implement Firefox entirely as an application running in a JS VM, the argument that JS is good enough might carry some weight.


The point is that NaCl is not portable, just like a native platform such as Windows.

Nonportable native platforms are there, you can write apps for them. They are even the dominant platforms on mobile.

But the web's entire purpose for existing is to be portable. So you do need something like JS or PNaCl or the JVM. And all of those, due to being portable and secure, impose limitations, such as limiting the native operations that you perform. That's unavoidable. But again, if you don't like that, develop directly for a native platform.


> The point is that NaCl is not portable, just like a native platform such as Windows.

So provide fat binaries. Maximize performance on ARM and i386, with fallback to PNaCL for future platforms that are neither.

> They are even the dominant platforms on mobile.

For a good reason. Adopting their strengths while eschewing their weaknesses (proprietary and single-vendor) would benefit the entire industry greatly.


Fat binaries are limited, and people will simply provide the parts for the platforms they currently care about, without care for future platforms.

That's fine for most things, but web content is something that we do want to always be accessible.

It is hard to adopt the strengths of native execution using all the lowest-level tweaks specific to one platform, because that inherently limit portability by definition (and often also security).

I share your goals, but don't think there is an obvious better compromise than the one we are all already making on the web.


The teams at Mozilla and Google have done an amazing job of improving JavaScript performance. But, I also have to agree with PBS, that Mozilla has a knee-jerk reaction to many of Google’s promising technologies like WebP and PNaCl. Like many HTML5 technologies that are being shoehorned into areas they were not originally designed for, JS was never meant to be a bytecode and likely will never be able to achieve the performance possible with PNaCl.

If W3C and WHATWG were competent and delivered a viable web application platform, we wouldn't be hiring Android and iOS developers now. Mozilla needs to be more open to new technologies like PNaCl that enable the web to be competitive.


I don't think "knee-jerk" is a fair description. Consider the collaboration between Google and Mozilla on WebM, WebRTC, and countless others.

> JS was never meant to be a bytecode and likely will never be able to achieve the performance possible with PNaCl.

LLVM IR was also never meant to be a bytecode. But in both the case of JS and LLVM IR, the question is the final result, not the original intention, even if the two are often connected.

> Mozilla needs to be more open to new technologies like PNaCl that enable the web to be competitive.

PNaCl is not even shipped, so it is too early to evaluate it. But the last benchmarks I saw for compilation speed and performance were mixed.

(NaCl is much more proven, but NaCl is not portable.)


> JS was never meant to be a bytecode

Neither was LLVM IR, if you mean "portable bytecode".

Both asm.js and PNaCl are using the technologies in ways they were not originally designed for.


> I included ones you could, such a NaCL.

You cannot do it in NaCl, as being able to map pages rwx would break the security model.


All you need to do is perform NaCL validation of pages before marking them executable; this is what NaCL already does.

You can either do this through a high-level "JIT API" that generates safe machine code from a validated IR (aka PNaCL), or through a fancier version of mprotect() that validates the actual machine code (aka NaCL).

In a wondrous hypothetical future where processors support a NaCL restricted operating mode, you wouldn't even need to validate; just set the processor state to thumb^Wnacl mode, and define a syscall instruction that switches to direct execution (without actually requiring a context switch to the kernel, just flip an execution flag).

This is why NaCL is so damn interesting, and JS/asm.js is not. NaCL has the possibility of turning our design of restricted execution environments on its head, in a very good (for performance) way.


You can already do that with NaCl - or even asm.js with eval, I bet it wouldn't be that much slower. But current JITs apparently gain a significant amount of performance with inline caching, which expects code to be able to be rewritten very quickly.

Edit to respond to your edit: although it would be cool to be able to have a "sandboxed mode" that can somehow be switched out of more cheaply than an interrupt, the whole thing seems like a massive hack to me. After all, NaCl does not take advantage of its pseudo-ability to do so: NaCl code runs in its own process and already incurs a context switch whenever it communicates with the browser, so there is no inherent hardware reason NaCl couldn't just run directly under the kernel and have the kernel provide the same level of sandboxing as the NaCl runtime currently does. It's just an issue of getting such an approach to work portably with existing kernels... hardware support might be able to make it easier to get that to work, but it's probably unnecessary.


> In a wondrous hypothetical future where processors support a NaCL restricted operating mode

If we speculate wildly, why not an "asm.js restricted operating mode"? Not saying that's a good idea, but I'm not sure why a NaCl one would be either. Both PNaCl and asm.js should reach pretty much native speed anyhow.

Btw, the L is not capitalized in NaCl.


> If we speculate wildly, why not an "asm.js restricted operating mode"?

Because we already had Jazelle, and it sucked, and we learned our lesson. A Jazelle that operates on ASCII-encoded bytecode with traps for unsupported JS constructs? No thanks. :)

> Not saying that's a good idea, but I'm not sure why a NaCl one would be either. Both PNaCl and asm.js should reach pretty much native speed anyhow.

Pretty much native and actually native are very different things.

I've had to sit down and hand-optimize critical paths that would not have been viable otherwise, and would have meant discarding a feature, or introducing a significant impact on usability -- and that's on platforms where similar investments in runtime library optimization were already made by the platform vendor, too.

If we're going to throw away performance, it has to be for a good reason. As someone who doesn't spend all day on platform development (as interesting as it might be), my focus is in providing the best possible user experience.

I'd love to do that on the web, but the web needs to punting throwing away solid technology decisions because of the bad technology decisions made in the early 90s when none of us knew what the hell we were doing.

> Btw, the L is not capitalized in NaCl.

Whoops. Thanks. Now I will look less stupid in front of software engineers AND my chemistry buddies. :)


> If we're going to throw away performance, it has to be for a good reason

I agree.

We are losing performance in return for: portability, security and standardization. The web runs everywhere, has a good outlook for continuing to do so (no fat binaries of current archs), and anyone can build a new web browser based on standards.

None of the other options proposed give us portability, secutiy and standardization right now. Perhaps with more work they might, and perhaps JS VMs will get closer to their speed as well. It's good to try to from both sides to improve things, and people are doing so.

I don't think anyone is overlooking some obvious better solution - that fits the requirements - that is before us. PNaCl (NaCl is not portable, so not relevant here) is interesting, just like the JVM and CLR, but they have major hurdles to pass if they want to be standardized, and that effort has not even begun in the case of PNaCl.




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

Search: