From JVM to JS: Implementing Math Functions in ClojureScript
summary
Builds a ClojureScript reimplementation that aims for parity with Java's Math, implemented Java's Math in ClojureScript and handling tricky cases like subnormals and NaNs. Uses ArrayBuffer/DataView bit fiddling to extract high/low 32-bit words and IEEE 754 64-bit parsing via ArrayBuffer/DataView to reproduce JVM behavior. Rewrites libc fdlibm routines like IEEEremainder, runs generative testing against the JVM across wide ranges, and lands the code in ClojureScript after community review and performance tuning.
AI-written summary · about
chapters (11)
- 0:00The need for portable math
- 2:58JavaScript math limitations
- 6:03Understanding IEEE-754
- 12:04Safe integer representation
- 14:46Bit manipulation in JS
- 19:01Reimplementing math functions
- 22:28The challenge of IEEEremainder
- 27:10Testing on the JVM
- 32:03Community feedback
- 33:55Cross-platform testing
- 39:31Merging into ClojureScript
related talks
29mExtending JavaScript Libraries from ClojureScript
34mClojureScript: The Essence of Alchemy
32mClojureScript: Lisp's Revenge
27mBuilding functional Front-ends with ClojureScript
42mScala.js Semantics - and how they support performance and JavaScript interop
39mClojureScript
17mJavaScript and mathematical computing across servers and clients
29mAn adequate intro to ClojureScript
