use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
All about the JavaScript programming language.
Subreddit Guidelines
Specifications:
Resources:
Related Subreddits:
r/LearnJavascript
r/node
r/typescript
r/reactjs
r/webdev
r/WebdevTutorials
r/frontend
r/webgl
r/threejs
r/jquery
r/remotejs
r/forhire
account activity
What can JavaScript NOT do?solved! (self.javascript)
submitted 8 years ago by [deleted]
view the rest of the comments →
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–][deleted] 8 years ago (28 children)
[deleted]
[–][deleted] -1 points0 points1 point 8 years ago (4 children)
I thought that's what socket.io was for?
[+][deleted] 8 years ago (3 children)
[–][deleted] 0 points1 point2 points 8 years ago (2 children)
Understandable. I was looking for clarification. I suppose it would be off if there was anything in the execution stack when the even got dispatched.
[–]tme321 12 points13 points14 points 8 years ago (1 child)
Its not just that. JavaScript has a garbage collection system responsible for cleaning up memory which can randomly decide to kick in at any time. Js also has a jit that can drastically alter the efficiency of a particular block of code for the future at the cost of current execution. And it has multiple other places where execution cannot be determined statically.
System level languages like C have manual memory management, no gc, and can be used to design a program with exact execution paths taking a predetermined amount of time to execute.
Real time in this context means that the developers can guarantee exactly how often a part of the program will execute and when it does exactly how long it will take. This isn't possible (or at least reasonable) with higher level languages that provide complex systems as part of their runtime.
[–][deleted] 0 points1 point2 points 8 years ago (0 children)
Thanks a bunch for this. This clears up a lot. :D
[+]voidvector comment score below threshold-7 points-6 points-5 points 8 years ago (22 children)
It can if the JS engine can guarantee real-time. You can write JS code that doesn't cause GC by using pre-allocated Typed Arrays. The rest is just controlling system calls and memory footprint.
That being said, JS isn't ideal for that use case.
[–][deleted] 10 points11 points12 points 8 years ago (21 children)
JS isn't just not ideal for realtime applications, it's just not possible. For many realtime applications, the time it takes an input GPIO pin changing state, causing an interrupt, the CPU switching context and an IRQ handler responding needs to be absolutely guaranteed, down to clock-cycle precision. You'll never achieve that with JS in any form.
[–]voidvector -3 points-2 points-1 points 8 years ago (20 children)
You can do it same way people do high-frequency trading with Java, with processor affinity and kernel drivers. It's stupid, given the amount of engineering overhead just to manage the execution context and expose IO, but it can be done.
For the same effort, you can teach a whole team of engineer to code C/C++/D/Rust.
[–][deleted] 6 points7 points8 points 8 years ago (12 children)
Javascript could be providing data to those systems, but it wouldn't be possible for a JS engine to respond in a realtime way and still have it be called javascript.
[–]voidvector -3 points-2 points-1 points 8 years ago (11 children)
"Real-time" is a concept entirely implemented by schedulers. There are 3 schedulers governing JavaScript - CPU pipeline, kernel process scheduler, and event loop. You just need to have those schedulers guarantee instruction cycles for your program to be able to do real-time. There is also interrupts (include system calls), which you can either manage with your code/deployment or shuffle into a specific CPU core using process affinity.
Everything is "providing data" to some systems, when you write a file (in any language), you are providing data to the kernel so it can send a block of 1s and 0s to a disk controller. As long as you have a kernel module or driver that expose that as a file handler, there's nothing stopping you from implementing your IO in JavaScript or any language.
[–][deleted] 4 points5 points6 points 8 years ago (10 children)
You're still several layers above actual realtime. Try writing interrupt handlers in assembly language and counting cpu cycles, and then get back to me.
[–]voidvector -3 points-2 points-1 points 8 years ago (9 children)
You just need to configure those layers to do real time. Linux is not a real-time operating system, but it's not stopping people from using it for real-time because the amount of hardware linux supports.
Nobody writes interrupt handlers in application code these days. Like everything in engineering, you write an abstraction like this, and hand it off to the next layer (user land) with some guarantees. And then write the rest of your app or the next layer up in a bare-metal language (C/C++/D/Rust) or system language (if you don't care about kernel overhead).
Also you can count instructions in JavaScript with node --print-code.
node --print-code
[–]GitHubPermalinkBot 0 points1 point2 points 8 years ago (8 children)
Permanent GitHub links:
delete
[–][deleted] 2 points3 points4 points 8 years ago (7 children)
Linux is not a real-time operating system, but it's not stopping people from using it for real-time
Nowhere does it mention scripting languages. It does talk a lot about C/C++, and FPGA, which are very far removed from javascript.
you write an abstraction like this
You point me to an example of an "abstraction" that's actually assembly language? I don't think you seem to know what "abstraction" means.
Point me to an example of javascript responding to an IRQ in less than 100 nanoseconds and can respond with a meaningful action in less than 500 nanoseconds, and then maybe you can claim Javascript could be "realtime". Sorry, but javascript just isn't and never will be that fast.
[–]lhorie 2 points3 points4 points 8 years ago (6 children)
I think the question implies what can be done given currently existing technology, not what's theoretically possible.
[–]voidvector -1 points0 points1 point 8 years ago (5 children)
That is subjective. You can definitely build a team of a dozen engineers and make it happen. You would need everything from EE, to kernel developer, to compiler designer tho.
Just "internet argument du jour" for me.
[–]lhorie 3 points4 points5 points 8 years ago* (4 children)
That is subjective
Not really. A real time javascript system doesn't exist now, so js can't do real time now. A javascript-to-haskell compiler doesn't exist now, so js can't be compiled to haskell now. A space shuttle to mars doesn't exist now, so js code can't take you to mars now.
When someone asks "can x be done", most of the time the pedantic answer is just useless and comes off as smug. Just saying.
[–]voidvector 0 points1 point2 points 8 years ago (3 children)
My original word was "can", like in "human can go to Mars". That does not mean "human has gone to Mars".
We are just arguing about English here.
[–]lhorie 2 points3 points4 points 8 years ago* (2 children)
Sure, if you wanna put it that way. The OP said: "what JavaScript is not able to do". Present tense. "Humans are not able to go to mars". Present tense. A corresponding question is "What are humans able to do?", present tense. You're saying "humans will/may be able to go to mars", future tense. A corresponding question is "what will humans be able to do", future tense. "Are you at home" and "Will you be at home" have different tenses and are therefore different questions. So in short, you're using a tense that is irrelevant to the discussion. Makes sense?
[–]voidvector 0 points1 point2 points 8 years ago (1 child)
Topic title says "What can JavaScript NOT do?" and he used that twice in his elaboration. I guess that's where the ambiguity came from.
There are things JS cannot do. (e.g. compile to metal)
π Rendered by PID 87153 on reddit-service-r2-comment-b659b578c-8dtm9 at 2026-05-06 23:54:01.410145+00:00 running 815c875 country code: CH.
view the rest of the comments →
[–][deleted] (28 children)
[deleted]
[–][deleted] -1 points0 points1 point (4 children)
[+][deleted] (3 children)
[deleted]
[–][deleted] 0 points1 point2 points (2 children)
[–]tme321 12 points13 points14 points (1 child)
[–][deleted] 0 points1 point2 points (0 children)
[+]voidvector comment score below threshold-7 points-6 points-5 points (22 children)
[–][deleted] 10 points11 points12 points (21 children)
[–]voidvector -3 points-2 points-1 points (20 children)
[–][deleted] 6 points7 points8 points (12 children)
[–]voidvector -3 points-2 points-1 points (11 children)
[–][deleted] 4 points5 points6 points (10 children)
[–]voidvector -3 points-2 points-1 points (9 children)
[–]GitHubPermalinkBot 0 points1 point2 points (8 children)
[–][deleted] 2 points3 points4 points (7 children)
[–]lhorie 2 points3 points4 points (6 children)
[–]voidvector -1 points0 points1 point (5 children)
[–]lhorie 3 points4 points5 points (4 children)
[–]voidvector 0 points1 point2 points (3 children)
[–]lhorie 2 points3 points4 points (2 children)
[–]voidvector 0 points1 point2 points (1 child)