Become a fan of Slashdot on Facebook

 



Forgot your password?
typodupeerror
×

Comment Re:Browser Apps are NOT desktop apps (Score 1) 195

The real underlying reason these apps feel flimsy is probably that Javascript is a single-threaded language.

The language is single threaded, doesn't mean it can't support "threads" in a message-passing way. The fact that my old Apple ][ can support threads by hooking 2 of them up through a serial interface doesn't make them "multithreaded". But if you want to look at it that way, then I apparently can't stop you :)

your assumptions simply don't match reality

Ok, so if a "for" loop is transformed so easily into an equivalent asynchronous structure, please enlighten me and show me how.
For example, take these simple nested loops, and I'm curious what code it transforms into.

function f(x)
{
    for(var i = 0; i < N; ++i)
        for(var j = 0; j < N; ++j)
            for(var k = 0; k < N; ++k)
                x = g(x, i, j, k);
}

where g is some constant-time function.

Comment Re:Browser Apps are NOT desktop apps (Score 1) 195

As threads are not an option in JS, it's a great opportunity for you to explore various alternative approaches.

Please don't forget that the whole point of my comment was that threads are broken in JS.

Go do some reading about asynchronous programming and event-driven programming.

The problem with event-driven/asynchronous programming is that it requires a lot of work, and makes your code look awkward. For example, a simple "for" loop turns into a monster of functions calling eachother, in order to break the inside of the for-loop into small chunks that can't lock the UI. Now imagine a doubly-nested for-loop. You'd need special compilers to keep your code clean.

Remember that Windows 3.1 was replaced by true multitasking for a reason.

Also, asynchronous code can only make use of 1 core of your CPU, which is also a waste.

Comment Re:Browser Apps are NOT desktop apps (Score 1) 195

A customer just called. He pressed "Ctrl+End" to go to the end of the document, while it was counting words. He complains that the user interface is frozen.

Just because you can't think of a way to solve a particular problem you've just thought of, doesn't mean that high-quality performant programs can't be written in the language.

Yes. But because of this problem of the (fictituous) customer, I now have to rewrite my 30.000 lines of code from web-worker style to single-threaded asynchronous style. Unless you have a better idea :S

Comment Re:Browser Apps are NOT desktop apps (Score 1) 195

The problem is that "threads" are supposed to be a solution to dividing work.
If you don't have threads, how will you divide work without ruining the nice hierarchical structure of your code?
You'll need a special compiler that does this for you. And the result will be *slow* (albeit perhaps more responsive).

Slashdot Top Deals

Force needed to accelerate 2.2lbs of cookies = 1 Fig-newton to 1 meter per second

Working...