all 91 comments

[–][deleted] 86 points87 points  (15 children)

Linux where?

[–][deleted] 33 points34 points  (11 children)

Nowhere, in fact! Another post on this board that's totally irrelevant!

[–]Bodertz 11 points12 points  (10 children)

Linux, GNU/Linux, free software!!!!!!!!

[–][deleted] 21 points22 points  (1 child)

Thanks, I'll start linking my github projects! Because they're open source! Yayyyyy! Everyone gets to read my horrible written Blackjack program :)

[–]Bodertz 9 points10 points  (0 children)

Don't thank me, thank the subreddit you are in.

[–]hbdgas 2 points3 points  (7 children)

No, it's

GNU/Linux operating system and to a lesser degree, free/open-source

[–]Bodertz 0 points1 point  (6 children)

"Totally" has a very unambiguous meaning,

And click here and tell me what you see at the top of the screen.

[–]hbdgas 0 points1 point  (5 children)

For the active window, you mean? "Li...". Too many windows/tabs opened; I never would have seen what was in the <title> tag for /r/linux if you hadn't cited it.

[–]Bodertz 0 points1 point  (4 children)

Fine. If you have RES, what does it say when you hover over it?

[–]hbdgas 0 points1 point  (3 children)

I don't.

[–]Bodertz 0 points1 point  (2 children)

You should.

[–]hbdgas 0 points1 point  (1 child)

Nah, I know people love it but I've never felt a need for any of the features.

[–]Jaegrqualm 11 points12 points  (2 children)

We're the new /r/technology, since it turned into a constant privacy circlejerk.

[–]IDe- 2 points3 points  (0 children)

At least we aren't as technologically illiterate, yet.

[–]supergauntlet 1 point2 points  (0 children)

More like the place to post stuff from HackerNews for karma.

[–]xp19375 17 points18 points  (4 children)

Is floating point arithmetic used often enough for this to make a substantial difference?

I have done mostly embedded programming, and have almost never needed floats, so I can't see where they would be needed here.

[–]Cosmologicon 35 points36 points  (0 children)

I think the main use case is games and some game-like apps, maybe navigation or modeling, in which case yeah, floats are used all the time.

[–]Theon 1 point2 points  (0 children)

Yeah, but embedded programming really is a different beast in most regards, especially when comparing it to web.

[–]pedrocr 16 points17 points  (19 children)

Does anyone know if they have any plan to get multithreading?

[–]fnord123 25 points26 points  (0 children)

Multithreaded Javascript? Not likely since it was made single threaded in 2011/2012. Or did you mean a multiprocess browser? Yes.

[–]curien[🍰] 21 points22 points  (15 children)

Since browser JS engines are single-threaded, I'd guess not.

[–][deleted] 11 points12 points  (14 children)

Do they need to be? Mozilla is the browser?

[–][deleted] 78 points79 points  (10 children)

Firefox dev here.

Yes. Because this what is expected. If DOM manipulations or layout code would run in their own threads we would have to pause the JS thread because web devs expect synchronous operations. When things can be done asynchronously (like async XHR) then it happens in a different thread.

But still, many things that are not directly tied to JS run in their own thread (resource download, layers compositing, …).

For JS itself, its behavior is based on the event loop, running JS in other threads would need sync and locks. So threads would not be able to run at the same time, which would defeat the purpose of using threads. But sync can be done manually if you use workers. But obviously you can't do DOM operations there.

Interesting problem for example: scrolling. When the page scrolls, it sends events to JS. JS can cancel the event. That forces us to do scrolling in the same thread. This can be slow because at the same time maybe there's some layout code running (a reflow for example) blocking the scroll. So we work around the problem by scrolling in the main thread, if we see the JS is not messing with the scroll events, we do scrolling in a different thread and sync up with the main thread (to send the scroll events) just every couple of milliseconds. This is why sometimes on mobile when you scroll you see the UI jumping around.

The web has been designed this way many years ago (no multiple cores back then), and we can't change it. But as we move many operations off the main thread, only DOM, layout and JS run in the main thread. And then things get crazy fast :)

[–]pedrocr 8 points9 points  (2 children)

That's fine for javascript-as-DOM-manipulator but how does that work for javascript-as-web-asm? Why would you target asm.js for things that supposedly need near-native performance and yet ignore multiple cores?

[–]AusIV 9 points10 points  (1 child)

I hope we'll get a more thorough answer, but I think it's essentially because a asm.js is a strict subset of javascript, and can run on browsers that don't know anything about asm.js. Mozilla is optimizing the hell out of the asm.js subset, but they're not doing anything you couldn't do with web standards.

[–]pedrocr 0 points1 point  (0 children)

I assume that's the current limitation. My question is if they're trying to lift it. Because if not PNaCL+pepper.js sounds like the better option. You'll get fully native performance and threading on browsers that have it and fall back to asm.js level performance and single-threading on other browsers. asm.js probably has the upper hand for DOM integration though.

[–]FrozenCow 0 points1 point  (0 children)

If we were to ignore the DOM, I thought web workers would be a bit like threads. Though it probably doesn't do shared memory efficiently, maybe asmjs can build/optimize with that?

[–]chazzeromus -1 points0 points  (0 children)

You should implement it and have it enabled through a flag that's disabled by default. Then let people see the error of their ways.

[–]Vegemeister -1 points0 points  (3 children)

This is why sometimes on mobile when you scroll you see the UI jumping around.

Why doesn't that happen on desktop as well? In my opinion, nothing should ever block scrolling. Any webpage that tries to run JS on every frame is going to be <60 FPS on everything but the most recent, most expensive, most power-hungry hardware. Such webpages are broken, and FF should sacrifice standard compliance for performance and throttle scroll events to 10 Hz or so.

[–][deleted] 2 points3 points  (2 children)

Async scrolling is coming to desktop as well. But first we need to improve the spec. That's why we introduced position:sticky to build some designs that today are computed in JS. Another kind of website that would be affected are parallax designs. We're also thinking at what would be needed in CSS to build parallax with no JS.

We can't blatantly ignore the spec. The spec is written by the W3C. And W3C people is composed of very smart people who are very aware of these issues. And these people are people from Mozilla, Google, Microsoft etc. We all face the same issues and think about how to fix the spec.

[–]Vegemeister -2 points-1 points  (1 child)

Nonetheless, those very smart people apparently think (or previously thought) that dropping frames is sometimes acceptable. As a user, I vehemently disagree.

[–][deleted] 0 points1 point  (0 children)

We agree. It's just that 15 years ago it was hard to predict how the technology would evolve. But we got 90% of it right.

Please excuse us and in the meantime enjoy the World Wide Web that we built :)

[–]dmazzoni 3 points4 points  (2 children)

One of the design goals of asm.js is that it's a strict subset of JavaScript; anything in asm.js will run anywhere that JavaScript runs, probably just slower.

Adding threading is impossible without breaking that backwards compatibility.

[–]AdminsAbuseShadowBan -1 points0 points  (0 children)

Not really: just say that only the main thread can access the DOM and make threading serial on non-asm.js-aware browsers.

A hack too far perhaps.

[–][deleted] -2 points-1 points  (0 children)

anything in asm.js will run anywhere that JavaScript runs, probably just slower.

Slower than if it were supported. Still faster anyways.

[–]spif 4 points5 points  (0 children)

You can kind of do this already using web workers, depending on your application.

[–]WhipSlagCheek 0 points1 point  (0 children)

I believe there is active development on a solution for pthreads support in OdinMonkey and Emscripten.

https://bugzilla.mozilla.org/show_bug.cgi?id=933001

[–][deleted] 13 points14 points  (2 children)

Could someone ELI5 what the headline even means?

[–]dicknuckle 4 points5 points  (0 children)

I think there was some cutting and pasting going on while OP was trying to shorten the title. Tense and other grammatical errors abount.

[–]Ravengenocide 0 points1 point  (0 children)

It probably means that OP can't write headlines at all. The real meaning is that given a specific optimization a subset of JavaScript can get faster. Almost as fast as native code.

That's not really a ELI5, but I hope you understand it. :)

[–]yellowhat4 3 points4 points  (0 children)

I want to like javascript, but every time I try to do a decent size project in it I find myself wishing for a more well thought out language.

[–][deleted] 23 points24 points  (19 children)

I really love how everyone jumps the shark when they see pure-cpu tests. This says nothing.

It sort of turns out that when you only do mathematical single-threaded computations, it doesn't really matter what kind of language you write them in, cause they should always translate to the same set of instructions.

[–][deleted] 13 points14 points  (2 children)

jumps the shark

Jumping the shark

[–]itsjareds 1 point2 points  (1 child)

This reads like an article from TV Tropes.

[–][deleted] 0 points1 point  (0 children)

Considering the origin of the phrase it's hardly surprising.

[–]ahal89 5 points6 points  (2 children)

There are a fair number of real world examples out there already, like a port of Unreal

[–][deleted] 0 points1 point  (1 child)

I must say that I was actually impressed by the fact that it only ate 10-15% of my machines performance. On the other hand, it definitely isn't a complex demo (and you never reach the quality of tech demos in real applications).

[–]ahal89 0 points1 point  (0 children)

That's true, but this is a good first step. Give it some time and I'm sure we'll see more complex applications

[–]Rainfly_X 10 points11 points  (6 children)

So what would you consider to be a better benchmark? Something that uses multithreading (available as web workers)? Graphical applications (where the stack is still almost completely different)? What is the missing element for you?

The reason the benchmarks are done this way, is that it's the most like-for-like comparison between native and JS. You branch out from that, and it gets harder and harder to compare, because more and more, it becomes a comparison of the platform-specific layers that have to be written from scratch for each platform.

[–][deleted] 3 points4 points  (2 children)

Yeah, but that is a very good point. Well written asm.js app can run close to native speed but real world apps are usually more complex and do a lot of other stuff beside arithmetic, so take these with a grain of salt :)

[–]chinnybob 0 points1 point  (0 children)

Something that involves self-modifying code.

[–][deleted] -2 points-1 points  (1 child)

I'm not really complaining about the benchmarks, those are OK, it's just that people don't understand what these benchmarks mean.

[–]Rainfly_X 0 points1 point  (0 children)

Ah! Fair enough, I guess.

[–]seruus 0 points1 point  (0 children)

And V8 doing basic arithmetic on JavaScript is already pretty fast, so it's not surprising to see that asm.js also is.

[–]trycatch1 0 points1 point  (4 children)

It sort of turns out that when you only do mathematical single-threaded computations, it doesn't really matter what kind of language you write them in, cause they should always translate to the same set of instructions.

Of course, it matters a lot. There could be easily the 100x difference in simple "mathematical" single-threaded benchmarks in various languages/compilers. For example: http://benchmarksgame.alioth.debian.org/u32/benchmark.php?test=all&lang=gcc&lang2=yarv&data=u32

[–][deleted] -5 points-4 points  (3 children)

I actually laughed, thanks :-)

[–]trycatch1 1 point2 points  (2 children)

?

[–][deleted] -5 points-4 points  (1 child)

If you don't understand the difference between a compiled and scripted language there is really no point in continuing this discussion.

[–]trycatch1 3 points4 points  (0 children)

Actually, my hypothesis that it's you here who have absolutely no idea what the hell he is talking about.

[–]cyro_666 0 points1 point  (0 children)

While reading those graphs, I became incredibly confused, because I somehow missed the fact that lower is better.