Hacker News new | past | comments | ask | show | jobs | submit login
Show HN: NoteCalc (github.com/bbodi)
267 points by bbodi on Dec 21, 2020 | hide | past | favorite | 76 comments



This looks great! The README says:

> Honestly, it just tries to be a free Soulver alternative in your browser.

For people on macOS, Soulver is excellent and worth checking out: https://soulver.app . I almost always have a Soulver window open on my screen.


Just wanted to also drop a recommendation for soulver, but I have been split between it and Calca (http://calca.io/) which I think is _also_ worth checking out, if you like this kind of hybrid notes/calculator like interface.

The ultimate interface _for me_ would be somewhere in between Calca (which I think has superior support for functions/graphing/logical calculations) and Soulver (which I think has better usability/readability) and a graph-based note-taking system like Obsidian/Zettlr. I'm sure somebody will say "there is a Vim plugin that'll do that" but… yea.


Love Soulver and Calca looks great too, thanks for pointing that out! Personally I would love a tool like one of those but with built in unit handling/dimensional analysis capabilities equal or better to the Google search bar...


Calca does look like a really nice mix of note-taking and calculations. The screenshots made me realise I was missing variables in Soulver... until I looked at the Soulver docs and realised that it does have variables, I just hadn't thought to look. Thanks for the prompt!


A big plus for Calca is the mobile app and automatic syncing via iCloud on Apple devices.

Not sure if Soulver is newer or less “complete” than Calca, but it is being updated at lot more often. The updates for Calca are very sparse and leads me to think it’s more in a maintenance mode.


Link to the public instance: https://bbodi.github.io/notecalc3/notecalc

It took me a couple clicks to find, a link in the readme would be useful.

It's an awesome tool, I think I will use this a lot. It cover 95% of my WolframAlpha use, with an interface that's both more responsive and let's me keep track of context and streams of thought.


a link in the readme would be useful.

It's there, already. The direct link in the OP are to the release notes

https://github.com/bbodi/notecalc3/blob/develop/README.md


For those using note-taking apps, I've found that OneNote has a similar very useful feature. If you type 1+2= into a note and then press the space bar, it'll insert the answer. It can understand thousand separators and large expressions with brackets etc.


Wow, so this is rust compiled to JS? Or I guess WASM which is a subset of JS? Is this the future of the web?

Also I noticed the base64/deflate URL fragment storing the entire text content, à la flems.io ... nice!


Yeah it's Rust to WASM with JS for the startup.


Nice. What I really want, though is a CLI calculator (something like bc or ipython) that would be clever enough to handle stuff like 1000!/999! (increase the number of digits if python will be able to do that: I hope you get the idea). I cannot treat seriously a calculator in 2020 that actually tries to evaluate expressions numerically, while representing numbers as floats or int32.

Multiplying matrices and stuff is nice, but I don't think I really ever needed that. But simple combinatorics and other calculations that involve large numbers and lots of simple operations (like powers), but are perfectly calculatable without losing precision on a piece of paper — plenty of times. It's annoying that I can calculate on a piece of paper something my calculator cannot.

Other than that, maybe some operations over physical units/unit conversion and some embedded city/timezone DB, and I don't think I can ask more of a calculator.


Originally NoteCalc used a library for handling arbitrarily large numbers. Unfortunately, some operations were so slow that as a quick fix, I replaced the library with a lighter one without dynamic allocations (which is 96 bit integer with 28scale).

This serves well the primary goal of NoteCalc so I did not spend more time on it yet, but I am on the same page as you, and if NoteCalc will be feature-complete, I will give an other shot to arbitrarily large calculations/precision.


I actually started working on a CLI calculator a few days ago that sounds exactly like what you're looking for: https://github.com/Kevinpgalligan/ka

So far it just has variables and basic arithmetic. Other features on my roadmap: rational numbers, a type hierarchy, units, and lazy/smart combinatorics.

What do you imagine the timezone DB would look like? I'd love to hear your ideas!


Frink! https://frinklang.org/ sounds exactly what you want. It has built in bignum support and mathematical functions. It also does units and their conversation natively.

It runs on top of the JVM so there's an Android port also. The Android app appears as two icons. One as a simple calculator and the other as a simple scripting editor for more complex requirements.


Have you tried isympy? It handles your factorial expression easily.


Love this, but the lack of interpretation of prefixed currency symbols is absolutely maddening! That it simply ignores the number and operand with no indication that these elements are ignored could easily lead to problems. I don't think I could in good conscience trust myself or those I might consider to be the target audience of this app to notice parsing errors in every case. Consider:

"$400 / 20" => 20 (ERROR)

"$400 / 25" => 25 (ERROR)

"400$ / 20" => 20 $ (OK)

"400$ / 25" => 16 $ (OK)


In your case syntax highlighting helps. Everything which is not part of a calculation is rendered as a simple text (greyish): [image](https://trello-attachments.s3.amazonaws.com/558a94779b3b3c5d...)

But yes I admit it takes some time to get used to the colors and their meanings.

Currencies and exchange between them are on my feature list btw.


Awesome; this is great to hear.

An idea you might consider is to display some kind of warning symbol or message if the input contains digits or operands which are not interpreted as part of the calculation that produces the output. This would have made the semantic meaning of the syntax highlighting immediately more evident.


It would also be nice to support other currency symbols. In Europe there are € and £, for example.

https://en.wikipedia.org/wiki/List_of_currencies_in_Europe


Your comment made me realize that most unit notation I'm familiar with has the unit as a suffix, with currency being the only standout that comes to mind.


It depends on the currency / country, too. Lots of countries put the currency afterwards, even "¢" comes after. $ and £ come before, but € ends up moving depending on the language.

https://en.wikipedia.org/wiki/Language_and_the_euro#Written_...


Binary, ocatal and hexidecimal literals often are indicated with prefixes: 0b, 0 and 0x respectively. There are probably other esoteric cases that I can't think of off the top of my head. "Qty" is often prefixed, for instance. It's a complicated problem for a natural language calculator, to be sure. Here are a couple examples of ways to represent four thousand Canadian dollars that you might encounter and have no trouble interpreting as a human. This could be a good target for an ML tokenizer...

-$4000CAD

CA$-4,000.00

4.000,00CAD$


You should link the website instead:

https://bbodi.github.io/notecalc3/

Awesome work!


This is very cool! The project description says that it is inspired by Soulver [1].

A similar (but different) application for iOS is Tydlig [2] which can also generate some simple x-y plots.

[1] https://soulver.app

[2] http://tydligapp.com/


+1, I love Tydlig! Have used it as my main calculator for years


check-out numi app too!

https://numi.app/


Something like this exists for emacs as well: https://github.com/sulami/literate-calc-mode.el


I've been trying to find a similar plugin for vim. Does anyone happen to know one?

In fact, I have never seen a vim plugin that add a "notation" at the end of each line like this one. Is it something very difficult in vim?


I don't know of a plugin, but you can sorta do something kinda like the thing ish if you squint and cross your fingers...

You can perform actual in-place calculations by using the expression register. So for example:

    = 2 + 2
    <insert mode cursor here>
Then something like `<C-r>=eval(getline('1h')[2:])` will end up with:

    = 2 + 2
    4 
If you regularly did so writing a more robust mapping would probably useful.

And using regular :global you could perform similar operations across a file with `:g/^= / <expression replacement>`

I think the real solution would be just to use evil-mode in emacs when you wish to use things like literate-calc-mode. I do that for org-mode because it is just so much more powerful than the basic vim plugin for org-mode files.

> Is it something very difficult in vim?

Since 8.2 was released you can use popupwin¹ to emulate something similar. I'd probably give it a go if you wrote it :P

It is a real shame you can't use a funcref(or even multiple characters) for conceal replacement, or you could simply add a conceal² for => to show the result. Such functionality would also be nice for inlining computed types in various languages too.

¹ https://vimhelp.org/popup.txt.html

² https://vimhelp.org/syntax.txt.html#conceal


I've looked into this a bit and the closest thing I could find is in VimWiki, where certain plaintext patterns are dynamically replaced with other text without actually changing the buffer.

See how line 11 dynamically changes in this video based on whether his cursor is on the line:

https://youtu.be/C0OwhiCp2Hk?t=223

I believe this is done using "conceal" as JNRowe says, e.g. here:

https://github.com/vimwiki/vimwiki/blob/619f04f89861c58e5a64...

I also second what JNRowe says about trying the new popup feature. I recently used this to run a script that calculates something based on where my cursor is currently at in the file, then show the result at the cursor using a popup:

    fun! CalculateFoodCalories()
      let day = GetSectionName()
      let day = substitute(day, "\[", "", "g")
      let day = substitute(day, "\]", "", "g")
      let out = split(trim(system("food --date=" . day)), "\n")
      call popup_atcursor(out, #{ title: "Today's calories", highlight: 'Statement', border: [],  padding: [1,2,1,2]})
    endfun
    nnoremap <silent> <leader>m :call CalculateFoodCalories()<CR>


After looking into how conceal works, it doesn't look like you can use it to "annotate" a line or dynamically change the text on the screen without actually changing the contents of the buffer. It can only be used to hide some pattern of text that's already in the buffer.

I would look into using popups, a separate pane, or something like vim-notebook.


That's really cool! Reminds me of calca.


Great work.

Is there a Terminal UI for this? Many users love to have simple programs in the Terminal itself.


Hi, Not yet, it is on my list, but unfortunately with a low priority.

But fortunately, the whole architecture was designed with the terminal in mind: - 99% of the functionalty is implemented as a lib, and just a tiny part is responsible for input and rendering, so it is very easy to write new frontend for it. - both the rendering and the input uses characters as a basic for coordinates, so it is easy to translate the render commands generated by the lib to the terminal.


A version to use within VSCode would be very useful too.


I was just thinking, turning this into a VSCode plugin would be awesome. Would save me from opening up the browser console every time I wanted to do some simple math.


On macOS, there is the excellent Numi app

Sadly I haven't found any equivalent for iOS (iPhone and iPad): it would definitely get my money!


Numi would be my favourite of all these kind of calculators on macOS, if it wasn't for the lack of unit calculations[0], e.g density = 2 kg / 3 l, mass = 10 dm^3 * density

[0]: Not sure of the actual term in English


I think the term in English is dimensional analysis


Some feedback: it fills my browser history with a lot of entries.


Thanks, you are right, I did not notice but yes it could be annoying.

The reason is that the content of the note is stored in the URL so it is easy to share it by sending the url to friends. So the URL changes basically on every modification.

I add it to the fixlist.


If you aren't interested in the history, perhaps you should be replacing the state instead of adding to it? Without looking at the code, it seems like an easy fix.


Yes this will be, thanks :)


This is amazing. Doesn't feel like a web based tool at all. Can even do bitwise operations that's just great. Can there be a programmer mode where I can use & and | instead of AND and OR? Not a deal breaker though. It's going to help a lot in day to day bitwise stuff


yeah why not :) I added it to my todo.


It sounded great, so I opened a demo page to try it out. Copied the contents of my personal savings note, and wanted to paste it into the NoteCalc to see what magic it would do. Pressed Cmd+V but it didn't paste. It just typed v intstead.


Very nice. I end up using google search more frequently for simple calcs and have been wanting something to take that to another level but not as far as a full blown Juypter notebook.

This could fit that sweetspot for me and others I imagine.


I usually use Alfred's build in Calc for simple stuff; and ipython when i want more (or reproducibility to play with numbers better)


Very nice, reminds me of "literate programming": https://en.wikipedia.org/wiki/Literate_programming

In a similar vein - a few years ago I built an open source REPL calculator called LastCalc (http://lastcalc.org/), which supports some advanced ideas from functional programming including pattern matching.


Exciting to see an open source Rust WASM project as reference for us folks who are interested in playing around with it. Thanks for the cool work!


This is pretty cool. Reminds me of https://instacalc.com/


This is pretty good soulver replacement.

I found all these similar tools has the problem that there is exactly one expression per line.

Is there any exploration of this feature: have the computed number shown next to the expression.

I had this problem while using soulver, too. I had a lot of artificial line breaks. For calculations it is pretty good, but it is pretty horrible when I present it to someone else.


This is really cool. I am always in Org mode which lets you do "literate" programming as well. I think NoteCalc is a little more streamlined, but I am very used to throwing a little Python or elisp into my notes when I need to do math. Great to see more options on this front. Org-babel is a nice package, though it does have some limitations.


Any reason you don't use calc-mode to insert mathematical results into your Org buffer? Calc-mode is extremely powerful.


Other similar tools

http://mathnotepad.com/ can do graphs and bitwise operations as well

https://dedo.io/

http://notepadcalculator.com/


Very cool, though I find there's a lack of discoverability as to what I can do with it, and no help is provided if there's an error.

    pi() => 3.14...
    sin(3.14 rad) => 0.00..
    sin(pi() rad) => err
No idea why there's that error.


Thanks for noticing it!

Unfortunately it seems units cannot be applied to function results. It must be fixed, I noted down, thanks!


I'm not quite sure what's the purpose of either NoteCalc or Soulver, but I am currently getting acquainted with TeX - and from that perspective NoteCalc seems comically under-powered compared to what's achievable through plugging into the Lua(Meta)TeX engine with Lua, or with the Lua C API.

I'm not criticizing NoteCalc, rather I think somebody should create a lightweight note taking tool like that, I don't think it would be very difficult by leveraging the already existing TeX/ConTeXt/LMTX/LuaMetaTeX machinery, and it would blow the Soulver-like stuff out of the water. The main design problem could be deciding exactly where between ConTeXt and Soulver should the new tool/language lie power-wise, i.e., how much should it expose.

I'm not proposing using TeX directly, rather I'm proposing basing a new, simpler language on the Lua(Meta)TeX TeX engine, and probably also on ConTeXt/LMTX.


One of my primary design goal was something like that: "My mother should be able to use this tool to calculate/plan her vacation expenses". (My mother is older and not a tech guru you can guess :)) So the primary focus are on simple calculations with meaningful context and immediate feedback. Nothing fancy.

Though, beside that, I think it provides some nice features. E.g. the matrix creation/editing functionality was born because I could not find a simple tool to double check my rendering calculations with.


Yeah, I guess NoteCalc will be useful to many people, it's just that I'm noticing the sad lack of utilization of LuaTex (probably because people don't know it exists and exposes the power of TeX through Lua).

The targets of NoteCalc vs. the tool I'm proposing would be somewhat different, too, because LuaTex outputs primarily to PDF, and I don't know if it can produce HTML.


Very nice app, I really liked it


This looks amazing. Can the author explain the implementation choices?

* Why WASM?

* Why Canvas?

From what I could see, it seems to repaint the whole canvas every frame, so I'm guessing this uses a custom implementation of immediate mode GUI.


Hi, thanks :)

Why WASM:

One of the primary goal of NoteCalc is to be easily accessible (e.g. it was mainly born because Soulver is MacOS only). So the browser-based client was obvious choice, and I chosed WASM for

- performance reasons

- to be able to use rust

- to avoid as much JS (and related technologies) as possible

Why Canvas:

I answered here: https://github.com/bbodi/notecalc3/issues/6#issuecomment-749...

In a previous versions, only the changed areas were re-rendered, but the code was much more complex and error-prone, and it did not bring any performance improvement, so now I just rerender everything, still excellent performance but much simpler code. However this is different for calculations, only changed/affected lines are reparsed and recalculated.


Cool! Makes sense.

Any advice / learnings on using canvas from wasm for this kind of GUI stuff? If I get it right, you just implemented the editor yourself, not using any sort of widget system.

People often recommend not trying to implement editors on top of canvas because of ... reasons [1] [2], but it seems your implementation ended up being pretty simple? (at least in terms of lines of code...).

1: https://www.w3.org/TR/2dcontext/#best-practices

2: https://stackoverflow.com/questions/12425111/creating-canvas...


Alternative for linux (especially great on eOS): NaSC (https://parnold-x.github.io/nasc/)


I'm enjoying it, but the lack of documentation is frustrating.


This really looks great.. props to you.

just a nitpick.. changing the theme resizes the panels automatically to adjust to the first panel's width


That's really nice!

Looks like a labor of love.

Thanks for sharing it!


This is soooo nice. I wish there was a +10 option on HN - it'd be the first time I'd use it!


This is great. I have always wanted to build this for myself ever since i read Bret Victor. Good work


I wish this was built into the iOS notes app. So many notes are just number calculations like this.


Wow I didn't even notice this wasn't HTML until I tried pasting stuff...


I take it as a huge compliment :)

Pasting should work with simple texts, what was the issue? Don't hesitate to open an Issue in GitHub if something does not work. https://github.com/bbodi/notecalc3/issues


notepad + calculator is a really great combination. i'm using this time to time:

http://notepadcalculator.com/


is there a docker image ?


wow, love it.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: