calculang is a language for calculations, It aims ...
# linking-together
m
calculang is a language for calculations, It aims to be: • shareable, communicable 💬 💌 • transparent, verifiable 🕵️‍♀️ • understandable, concise 📖 • flexible, reusable ♻️ only for calculations ⇔ numbers ⇔ workings calculang doesn’t ‘do things’ (“side-effects”) like regular programming languages 💥 This serves to simplify, permitting the aims above for calculations, numbers, and their workings https://calculang.dev/
👀 3
k
There are many good ideas in there, but also some rather bad ones. In particular the choice of JavaScript as the language for doing calculations. JS isn't exactly known for its excellent number stack. I don't see it stated anywhere, but I suspect that calculang uses JS maths. rather than implementing something more robust and complete on top of JS (as XXX-to-JS compilers do).
d
Hey Konrad - I'm Declan, I make calculang! I'm glad you looked! I think JS is an implementation detail - a small one in fact, because implementing calculang is absurdly simple e.g. I have a new 500 line compiler that runs in the browser; only missing modularity. There are no millions of LOC; just simple rules that we can implement anywhere or for different language targets. The rest of it is just about not making a mess! The main thing I want to draw attention to with calculang now is about separating numbers from programming. I think we should have higher expectations about numbers: about our ability to see their workings and interact with them to understand them. Also manipulate/develop them in flexible and expressive ways (not locked to layout - not a spreadsheet). So, we need to separate things. Another important part is about sharing workings and numbers. For many of these bits JS is quite ideal. But the execution model is incredibly naive due to recurrances (call stack pressure). This is the same for many language targets. When I know a really good target, it might lead to a new implementation. But in the meantime it means thinking carefully about if a problem can be solved or simplified sufficiently. Lots of practical stuff can't, but I'm deciding - at least for a while - to embrace this fact and focus on simple things. Like simplified things for teaching about a thing (things for teaching happen to be simple already! <3 ), or like important financial things like mortgages or pensions - but for 1 individual and not for 10M customers. In this space I haven't often rubbed against barriers in JS Math stack. An example of when I did is when last Pi day I wanted to calculate 17 significant digits of Pi, but then I was able to break free by using... a JS library :) https://observablehq.com/@declann/its-pi-day
k
@Declan Naughton Thanks for all those details! I have played a bit more with calculang yesterday on a bus ride. Lots of nice examples, and overall it looks like a great playground for exploring and in particular visualizing numerical relations. The background of my comment about JS math is my professional background in computational science. JS math is definitely not good enough for working with complex numerical algorithms that risk becoming unstable. Nor for applications where the distinction between integers and floats really matters.
d
Cool, for many applications in your field I don't have something appropriate. One thing I'm interested in doing next is integrating with Python and Julia models. e.g. letting them do heavy lifting for some problem like NN training or something else interesting, but in calculang being able to call, do some analysis, and visualize results for different scenarios (also things like see workings for key outputs, but in this case with a black box in the middle)
❤️ 1
There is a tc39 proposal here that may widen JS usecases for math: https://github.com/tc39/proposal-decimal?tab=readme-ov-file#tertiary-use-case-numerical-calculations-on-more-precise-floats QuickJS is an engine with mathematical extensions; so I just tried it via numcalc.com to improve my PI calculation precision 🙂 (🗒️ https://gist.github.com/declann/eabc81b36f18acc47dd5882ea903229c)
k
TC39 looks interesting! As for QuickJS, at first sight this looks like a niche project. Who writes JS for one specific JS engine?
s
If you fancy trying an implementation with a nice compiler you might try https://racket-lang.org
d
@Stephen De Gabrielle different Quicks I think?? @Konrad Hinsen if it's a trivial conversion and if it unlocked key current problems then it would be an easy target engine - and via emspriten (just as on numcalc), nobody might even notice (this also true of many targets too). But I agree V8 etc. treatment of the issues is far more interesting!
👍 1
thanks for the discussion Konrad.. Im thinking about a way to indicate good and bad (or workable/not workable) applications for calculang on the homepage; probably by emphasizing simple things. I don't want it to be too self-deprecating because the unboundedness (in concept!), and possibility to target other languages, is also something that I want people to consider. I'm working on a new gallery and website now, so I'll be thinking about how to do this! The current website is very scant on anything to actually ground the project and that's a big issue, so hopefully I'll be able to improve that