4 ms·
"What are some things that you wish you had known before getting into JS?" You won't be able to program your hardware: 1. No SIMD. SIMD is becoming important
by jorangreef 8y ago
"What are some things that you wish you had known before getting into JS?"
You won't be able to program your hardware:
1. No SIMD. SIMD is becoming important for anything fast.
2. No instructions like `__builtin_ctzl` for counting the number of leading zeroes (essential if you're working with bitmasks).
3. No fast uint32_t. 32-bit integers in Javascript are much slower than 31-bit integers in Javascript because of boxing.
4. No fast uint64_t. It's nearly here, but whether (and when) it will be optimized remains to be seen. Say goodbye to fast hash functions for the next few years.
5. You won't be able to do Daniel Lemire's fast mod alternative: https://lemire.me/blog/2016/06/27/a-fast-alternative-to-the-modulo-reduction/ https://lemire.me/blog/2016/06/27/a-fast-alternative-to-the-...
6. Slow bridge to C, you can expect 20-25ns per call. This means that for things like implementing a fast hash table, you could try compensate for the lack of the above by using a native addon written in C. But even then, the calling back and forth will cancel any gains.
Basically, the hardware is moving ahead, and languages like Javascript are not keeping up.
You're going to be able to do a lot of these things in newer languages, however.
Apart from that, Javascript is a fantastic language.