Hacker News new | past | comments | ask | show | jobs | submit login
Qalculate – A multi-purpose cross-platform desktop calculator (qalculate.github.io)
220 points by pantalaimon on Aug 9, 2023 | hide | past | favorite | 130 comments



If you want a lighter-weight package featuring a plaintext REPL, a large library of functions, function definition, arbitrary precision, and more (minus solver capability), give Speedcrunch a try:

https://heldercorreia.bitbucket.io/speedcrunch/


In college, I started out with SpeedCrunch because it comes with many KDE-based Linux distros as their default calculator. I eventually went on to play with a few alternatives and ultimately settled on Cantor, which is a nice, notebook-style frontend for pretty much every mathematical programming environment you can think of (including Qalculate!). At the time, I really liked using it with Maxima (and sometimes R).

https://cantor.kde.org/


Qalculate has a plain text repl (qalc), as well. And, as far as I know, all the other things you mention. Speedcrunch might be awesome for all I know (never tried it), but your comment does not really shed any light on why one would pick it over qalculate (what does "lighter-weight" mean? It's not like qalculate takes minutes to start up or is hard to use).


The plain text qalc doesn't compare with Speedcrunch. How do you copy & paste for example? Speedcrunch also has a shortcut for putting the result into the clipboard.

You can make Speedcrunch look like a good old fashioned bc session, whereas Qalculate puts way too much stuff on the screen. It misses a simple REPL mode.


You can copypaste plain text to and from the terminal, what kind of copypaste do you mean?


The shortcuts aren't the same, especially for copy. For example instead of Control+C (which normally interrupts the program), you have to use Shift+Control+C.


I strongly prefer speedcrunch due to it opening much faster and being simpler.

Qalc has poor documentation so I don't find learning its extra features to be worthwhile.

Qalc is also awkward to type.


I switched from Speedcrunch to Qalculate a while ago. I don't actually remember exactly why I switched at this point. (I think due to a lack of updates). Qalculate very similar in many ways, but I do like the interface on Speedcrunch better (after hiding the keyboard). The new UI for Qalculate has a similar enough feel to Speedcrunch that I've been happy with it.


Plus you can quickly build websites with speedcrunch IIRC

Edit: https://www.friendlyskies.net/speedcrunch/

Kinda funny but also impressive in its way...


A note to anyone using a high DPI display: you can build this from source and get a version that scales itself cleanly instead of forcing the OS to make a blurry mess out of it.


what changes would you need to make so that the build isn't blurry?


None at all. I just had to point CMake to Qt 5 installed via Homebrew by setting CMAKE_PREFIX_PATH to /opt/homebrew/opt/qt@5 before running CMake.


Speedcrunch is great but has (had?) a very annoying bug: was pretty slow after a while. You need to manually clear the history to make it load fast again.

I have it on speed dial (pause / break key to open and close) and use it all the time.


I'll +1 speedcrunch It's also been built for off-broadway mobile OS Sailfish.


It's a really great calculator for all sorts of stuff.

I use many of the following almost daily:

- currency conversion: `x USD to EUR` or `BTC to USD`

- time calculations: `now - 27 hours`

- unix epoch conversion: `timestamp(now - 3 days)`, also `stamptodate()`

- unit conversion: `34 oC to oF`

and more.

Works really nicely with https://github.com/svenstaro/rofi-calc


I have it bound to `$mod+c` and launched as a floating window in i3. It integrates very well into my workflow as I can just quickly launch, perform a one-off calc, and close it whether I'm in a terminal or elsewhere. Since it saves history, I can always relaunch it and continue where I left off as well.


I have `$mod+c` bound to rofi-calc [1] which I find even more convenient.

1. https://github.com/svenstaro/rofi-calc


Glad you like it. :)


Cool. Just having seen this I guess I'd better look at using libqalculate in earnest!


I tried this in cinnamon. But I use multiple desktops and if qalculate is already on another desktop, the experience is pretty bad since it doesn't move to this one (and I do want its 'allow only single process at once' enabled so settings save properly)

Does there exist a solution for that?


I hve a global shortcut to open a Julia REPL session and I use that to perform any sort of quick calculations instead of a GUI calculator. The best thing about this approach is that I can always create new functions for stuff I use often.


Qalc seems like a better calculator to me and is more stable somehow despite being written in I think C++. Not having to download a huge programming language taking up GB of space, research an ecosystem and import ten packages sounds ideal. I prefer python or R and sometimes even BC to Julia for terminal calculating anyways...

I'd let the post about qalculate be about qalculate here.


I am not sure if it is of interest to you, but from the cli, qalc's REPL is much faster to start when compared to julia


> The best thing about this approach is that I can always create new functions for stuff I use often.

Do you put those in your startup.jl? Do you have a Startup package like some recommend for Julia 1.9+?


i like the rpn mode


Huh, yeah, it does do RPN. This is actually looking like a serious replacement for my current daily driver, Emacs calc.


Anyone else just use the Python REPL as their desktop calculator?


For one-off simple calculations I just use awk, with this handy function in my .bashrc:

  function calc() { awk "BEGIN{print $*}"; }
  
  # usage in bash
  $ calc 'sqrt(25) + 2**3 - 17.17'
  -4.17


Yes! (although ruby (irb) instead of python). It's amazingly useful to be able plug in expressions in a single line of text format. Though for more complex expressions, something like qalculate looks nice to me.


yes, with modifications - https://github.com/idanpa/calcpy


Looks really nice! I wanted to ask if 'matplotlib' was strictly needed since it's a big depends?


matplotlib is not needed, SymPy fallsback to ascii plotter and this is what I use on phone with termux.


bc -l


The "ultimate" calculator wouldn't use the same irrelevant-in-PC physical number buttons paradigm, taking up more than half of useful UI space


shrug when I ran it the first time, the default GUI is a menu bar, entry area and history. Like: https://qalculate.github.io/images/qalculate-qt.png


and I got the screenshot advertized on the main page


If every PC had a number pad I'd agree but efficiently using the top row number keys for both symbols and numbers is a tall expectation for most users to default to. Doubly so when you factor in holding shift and memorizing the operator locations in that row. A full point and click is a great default IMO, even on PC. I'd also argue in the case of devices with a numberpad you're unlikely to care as much about the wasted UI space anyways.


> irrelevant-in-PC physical number buttons paradigm, taking up more than half of useful UI space

Calling it irrelevant is a bit like calling vim irrelevant. Classic calculators don't use REPL, they are designed to minimize the number of keypresses required to input your problem and explore it in the intuitive manner. They use highly efficient modal input languages (kind of like vim). Besides being efficient, these languages tend to have one-off commands you have to remember. Having a cheatsheet on your screen by default is useful for discoverability. In the algebraic calculator paradigm and their typical use cases (napkin math), having a history is not very useful (unlike in RPN where having the stack on the screen is nice).

That said, Qalculate is weird in that it uses a REPL and the input line, which is much slower and clunkier than the algebraic input, but still tries to mimic a classic calculator. It's also slow to start. Not sure what's its use case, as it offers neither speed of a classic calculator nor the feature set of full-fledged math software.


This doesn't make any sense, what kind of cheatsheet do you need to discover numbers on your keyboard???

What kind of efficient modal input language is it where you have to move your hands off the keyboard and move your mouse to press a button to insert a number?


Commands, not numbers. (what is the equivalent of +/- or 1/x?) Algebraic calculators don't have a lot of useful information to display when used properly, maybe the contents of memory registers but not much else. The screen estate can be used for anything, might as well be a cheatsheet.

> where you have to move your hands off the keyboard and move your mouse to press a button

Command cheatsheet, not number cheatsheet obviously (doubling as input won't hurt). Having numbers on it is excessive, as I already said Qalculate does it the weird way.


It sems you're still talking about some idealized vim-calculator instead of this app

> Command cheatsheet, not number cheatsheet

How do sin/cos/tan/e/p/i/ln/kg/mod buttons (that take most of the screen real estate ignoring the numbers) help you "cheat"? Do they help you discover sin/cos? Or is there some shortcut label that helps you remember how to toggle some extra options without using a mouse?


You can hide the number pad from the keys. Or hide the keys entirely. Or keep them and customize which functions they activate, including custom user-defined functions.


could I keep only half of all the keys (e.g., I'd never need 0-9 or cursor keys, but then maybe ANS is useful), reoder them and attach a shortcut to each button?

Or replacing sin with the rad/degree switcher (without the dropdown)?


Yes, you can hide all the 0-9 keys. And add rad/degree buttons. And set whatever functions/settings you can have elsewhere in the UI as buttons. And add or remove columns/rows from the "keypad". The upper-left button in the custom keypad will always be to edit the custom keypad itself, otherwise it's fully modifiable by the user.


oh, that's very nice! Do you happen to know a place with a good collection of those UI customizations not to start from scratch?


> It's also slow to start.

It's launching instantly here, with cold caches.


Feel free to turn it off. The "ultimate" calculator wouldn't deny the option to have the classic button paradigm...


That's not a good excuse - that would be an option, not the main UI, and if it weren't the default, than the dev could've realized that that space could be used in a much better way


When I first started it after install there was no keypad visible. Your distro may have set a different default than what the devs did (I just tried it on Windows, so no distro maintainers to change the defaults). It's also easily customizable, there's a button to pick which keypad (if any) you want.


you can't blame the distro when the main page has the same interface, I've replied re. customization in a different comment


There is also the command line version: `qalc`.

I use it since I discovered it.


Same. I was happy with `apt install calc` (I think nowadays called apcalc) for years because it does arbitrary precision and isn't as awkward as a python shell or so, but qalc is clearly a step up with support for units and solving

    $ calc 2^x=4
    x is undefined
    $ qalc 2^x=4
    ((2^x) = 4) = (x = 2)
I used the above for determining after how many years a given inflation rate doubles a price (1.03^x=2)

I think my most recent real-world application for units calculation was about how much energy a device uses in kWh after a year, given that it draws 10W during office hours:

    $ qalc 10W*(8h/day)*1year to kWh                                                                               
    (10 * watt) * ((8 * hour) / day) * (1 * year) = 29.22 kW*h
It even does time calculations: 13:37-08:00 tells you that you've been working for about 5.6 hours.

I don't know why this isn't the universally used command-line calculator. I have it on my phone as well via a Debian subsystem and it's the best


> $ qalc 10W(8h/day)1year to kWh

Question: why didn't you need quotes around the first expression? Both Zsh and Bash error on that command without quotes. Are you using nushell?


With zsh you can call it with the noglob builtin¹, that way it doesn't try to parse the bracketed section as a globbing pattern; if that works for you, then you can simply "alias qalc='noglob qalc'" for future use.

¹ https://zsh.sourceforge.io/Doc/Release/Shell-Grammar.html#Pr...


    $ qalc 10W*(8h/day)*1year to kWh
    zsh: bad pattern: 10W*(8h/day)*1year
    $:1 noglob qalc 10W*(8h/day)*1year to kWh
    (10 watts) × (8 hours/day) × (1 year) = 29.22 kW·h
Amazing. I use qalc frequently and you just improved my life, thank you!


Omitted for simplicity


hmmmm. bash worked for me as was ?


I use it as my calculator app on my phone


I wanted to chime in as a calculator dev dude. Qalculate is really nice if you want the kitchen sink, which I do on the desktop. I also, depending on the task use speedcruch which others have mentioned.

Using https://github.com/ArashPartow/exprtk I have one calculator with a repl at 512kb, including a QML wrapper. I have a combined rpn calculator using sympy (based on the work of others) with exprtk as a 'programmer's calculator' on the side (https://github.com/poetaster/fibonacci). And several QML apps for symbolic CAS using sympy.

I have way too many calculators. They are so much fun to build. Now I ask myself, port the Qalculate methods to macros for exprtk or check out using libqalculate? I'm not sure. exprtk is so light? And adding macros discrete.


As an engineer, I usually can just pop my expression into Siri/Spotlight or Cortana with a hotkey and get the result just fine. What kinds of calculations are people needing more for?


Can it do ans* etc. Is there a history of expressions and results. Is the history on-screen while next expression is typed. Is there a current result indicator, i.e. live update of the expression result as you fiddle with parameters.

Just what's coming to mind for basic daily use here.


Can you do dimensional analysis in Siri?


Or solve equations?

I imagine Siri has a database of constants, but is it usable?


I’m not sure what dimensional analysis means in this context. Is this like “does N-m = kg x m2/s2”?


Indeed, alongside all the other numerical calculations and symbolic manipulation...

Example question: what is the diameter of a sphere of tungsten - in inches, say - that weighs the same as a human (say, 150 lbs)?

Looking up the formula for the volume of a sphere gives: v = (4/3) pi (r^3), and googling the density of tungsten gives us 19.3 g/cm3.

Great! Now we already have inches, centimeters, pounds, grams, a fiddly ^3 to trip up our unit conversion from cubic centimeters to cubic inches (or is it vice versa?), some rearranging of an equation to extract the 'r'...

Luckily with qalculate, we can just smoosh it all together without thinking. We can substitute 'd/2' for "r", followed by 'x' for 'd' to tell qalculate that that's the quantity we want to figure out, and put it in inches while we're at it:

v = (4/3) pi ((x/2 inches)^3)

We're not after the volume but rather the mass, which is the volume times the density, and should equal 150lbs:

150 lb = (19.3 g/cm3) (4/3) pi ((x/2 inches)^3)

Hit enter and:

x ≈ 7.434184004

Amazing. A 7.4 inch cannonball of tungsten weighs as much as an adult human. Note that the result is only dimensionless because we balanced the equation - if we'd messed up any part of this formula, we'd have probably got our answer back in some perverse unit instead.

Oh and we didn't actually need to look up the formula for the volume of a sphere:

150 lb = (19.3 g/cm3) sphere(x/2 inches)


I'm confused why the result is dimensionless when you asked for inches.


Its returning the text that needs to be inserted in place of x to make the equality true. Since the parentheses already contain the inches they are not redundantly attached to the x. If you remove the inches from the query you get the result in mm, you would use 150 lb = (19.3 g/cm3) (4/3) pi ((x/2)^3) -> inches to get the answer in inches.


Fantastic tool. It also has a command line version which has almost completely replaced `bc` for me.


The most annoying part about bc is always having to type "scale=5" before you start otherwise it makes you think all your answers are integer.


"bc -l" runs it with scale set to 20. Also preloads some math functions.


The word "some" is definitely an exaggeration here.


Not on my bc. [1]

If it's missing anything you need, let me know.

[1]: https://git.gavinhoward.com/gavin/bc


Ooo, nice. Has there been any interest from any distros for including it in (for instance) Debian?


It's in some distros, but Debian for one has not been interested.

It's in Gentoo (can be selected as the main bc), Void, Alpine, and a few others. I think there's also a Nix package?

If someone's willing to go to bat for me to get it into Debian, I'll do the package myself.


What danadam said.

Also:

https://www.gnu.org/software/bc/manual/html_mono/bc.html#TOC...

Environment variables

BC_ENV_ARGS


Are there prebuilt binaries available for macOS? I'm running the GTK version on an m1 and it always takes a few seconds to get going.


Not to criticise the application, but how realistic is that such an application weighs ~70MB?


Looking at qalculate in Arch repos, libqalculate comes in at 14.94 MiB, and qalculate-qt at 3.37MiB, so 18.3 MiB total. If you're looking at the Appimage, the rest of the size would be from the libraries it depends on, like Qt/GTK+


So a smallish C++ static binary then.


You took my words


libqalculate is the mathematics part and the command line tool, while qt is GUI, so it's surprising the GUI part isn't the larger one of the two


About 6MB of it is the libqalculate.so.22.19.0 file, 1340KiB is .xml files that define all the units/functions/etc, and another 6MB is the documentation.


oh, it's way more than that, on a Mac via brew it needs 600M QT and 50M gtk+3 and a couple of dozen M for other dependencies


I think the real issue here is the brew formula - the Qt runtime should be under 50MB (over if you include the chromium packages). Only the full development toolchain might be close to 600M and that clearly isn't needed here,


I knew it would be fairly big but 70MB is ridiculous. I weep for today's software.


qalculate-gtk is 3.7M on my system with libqalculate.so.22.17.4 weighing in at 5.7M


Imagine if it was implemented in Electron, not in Qt. It would have been 300MB+ then.


Are you really so strapped for disk space that 70MiB impacts your user experience?

EDIT: The parent comment is disingenuous: the application isn't even 70MB. It's only 70MB if you download the windows edition with vendored libicu (unicode, 31MB) library. It weighs around ~20MB on linux distributions, which is insignificant.


Even worse this kind of critique is actively cancerous to new developers if they actually think that people outside of HN care about this.

Development productivity over everything. Features matter not app binary size.


That mindset is why modern-day ultrabooks give the same practical performance as 15 years ago. All of the hardware advances have been gobbled up in the name of "developer productivity".

Check (eg.) the Elevated 4k Demo winner to glimpse what modern computers are actually capable of in the hands of good developers.


Eh. Binary size by itself contributes very little to an application's performance.

>Check (eg.) the Elevated 4k Demo winner to glimpse what modern computers are actually capable of in the hands of good developers.

If all software were to be built using the same techniques the demo scene uses, nothing would ever get done, and if by chance a project does get released, no one would be able to maintain it afterwards. Let's not confuse art and engineering just because both use code as the medium.


An application's performance is orthogonal to its binary size.


Not orthogonal, maybe diagonal.

Sizecoding productions are an exception, because they tend to use really slow and memory hungry unpackers (can take up to gigabytes of RAM to do their job, for a 4k intro!), and they tend to lack all optimization techniques that could improve speed in exchange for more code (ex: culling, etc...). And flooding memory with millions of generated objects is no problem for these productions, as long as they are not stored in the executable.

But in general, larger binaries are slower to load, simply because there is more bytes to copy from disk to RAM. And although it is not always the case (ex: sizecoding), it usually means a larger memory footprint, resulting in worse CPU cache efficiency, less memory for other apps and filesystem caches, etc... Also, large binaries tend to be a symptom of inefficient code, with too many abstraction layers, poor optimization, etc... Another very common reasons for bloated executables is that they bundle all their libraries, which means that they don't take advantage of shared libraries, requiring the OS to maintain multiple copies of the same library, possibly including some outdated or poorly optimized versions.


I don't agree with this, not by a long shot, this kind of mindset is why we have such a cancerous proliferation of overbloated and slow software today and it's just getting worse and worse every day.


So what? The tradeoff is that you make much less money with your mindset in exchange for impressing people on an internet forum.


> Features matter not app binary size.

*.exe in Everything = 11 586 objects on this machine.

At 70MB a piece that would come out to ~800GB.


If you'd be running Qalculate on a Linux desktop system, where all the "heavy" dependencies (ICU, GTK or Qt) are already present and shared between all applications, Qalculate wouldn't require 70MB.

Of course you could also provide a Win32 frontend to bring down the space requirements drastically and make it more Windows "native"; there's a well documented libqalculate for exactly those purposes.


I love qalculate. Now Slackware (my distro) ships libqalculate, and then it's trivial to build a frontend.

I loved Qalculate back when it was a KDE3 application. In KDE4 times the UI switched to GTK+, but recently the dev added a newer Qt frontend which is really nice save for the fact that it doesn't have an app menu other than a hamburger menu not really accessible via keyboard; you must use the mouse for it.

I'd love to see a KDE Plasma frontend again with the more traditional layout. The app is great and powerful.


It is a very versatile piece of software indeed. The minimal mode window is a great pop-up calculator that can do a lot, including conversions and working with physical units.

Highly recommend!


RealCalc free version from Quartic on Android is not bad. Not comparing it to Qalculate.

And it has a really cool physical-world electronic calculator look, hence the name.


I use RealCalc on Android as well! Been handy to have for years. I bought the paid version and have been pleased with the purchase.


Definitely a purchase I have never regretted.


I forgot to mention in my last comment that https://github.com/vetux/qcalculator is also a nice qt based, exprtk using calculator with a python interface and higher floating point precision than plain exprtk.


I use calc mode in Emacs for that kind of thing. Any idea how the two compare?


Qalculate is great. I also use insect on the terminal for quick calculations or conversions

https://insect.sh/


If this evolves a little further, you get Jupyter notebooks.


Doing units in Python is a pain. No easy RPN/stack mode. No flexibility in parsing. Vector, matrix, and date maths require weird syntax. No good concept of infinite number.

Stuff it. I’m just reformulating https://qalculate.github.io/features.html ; you can do that yourself.



I am aware of the Python library ecosystem. Feel free to compare the examples with Qalculate’s syntax.


I'm told if you don't use floats the computer will explode and the whole city will burn down. End times, armageddon scenario pretty much.


I find it quickest to CTRL+SHIFT+K if I'm in the browser or run `iex` or `python3` in terminal to calculate something ad-hoc.


Have Droid48 on my phone. I am infested and will never use a calculator without a stack.


This program also supports rpn mode with a stack.


Lisp is the ultimate desktop calculator. But this one looks nice anyway.


At this point just use a CAS or a TI calculator emulator.


I also tend to just use a CAS, specifically maxima (either commandline, via emacs, via wxMaxima or via notebook, see https://github.com/robert-dodier/maxima-jupyter ). It has the plotting, great units etc, and also incredibly handy to do things like a taylor expansion around a point with no effort.

If not maxima, then the old M-x calc will usually do the job


Obligatory mention for bc, a command line arbitrary precision calculator and language.

https://en.wikipedia.org/wiki/Bc_(programming_language)


Thanks, I'll stick with Rstudio.


Beautiful piece of work. Kudos


i wonder why calculator apps are so popular


It's the oldest use-case for non-human computing and one the things computers are best at compared to humans.


They compute things on a computer

“Popular” is a bit of a stretch though, I’m not aware of any fanclubs


do you have a Mac installer available?

also you need a designer. the website looks like from the 2000s.

thanks for sharing the app.


Yes this website needs a huge full screen video of models in business attire making calculations on a white board. When scrolling down I don't wish to find out what it does but would like some quotes from people saying how it changed their lives. Some transitions would be nice, the ones that make my fans spin, it gets cold here in the winter. Without it this website is barely usable.


Totally.

Along the same lines, I'm nearly Goad Complete (TM) with an amazing SaaS called Append-Slash-Ess as a browser extension. It does what you would expect, at the click of a mouse or touch of a finger, no need of keyboards, which are so last century. We aim to obsolete them so we can rake in, oops, take on our mission of improving the world.

And since our team is made up of (literally) outstanding ex-Ghroaglers, we'll only support the Ghroan browser, of course. And it'll detect and reject others, for the benefit of everyone.


A quick click shows that it’s available on home brew and Mac ports.

I like the 2000s website style. It’s functional, simple, and loads very fast.


what the quick click doesn't show is that brew will require ~700mb of dependencies and still installs as a cli app, not an GUI app bundle


Can you please point me to a website from the 2000s that looks like this? A wayback machine link would do. Because I definitely don't remember websites from the 2000s looking like that.

The website's design is fine.


So, you think the website would be better if it:

- had low contrast text in a thin font

- had pointless animations of content fading in as you scroll down

- had a GDPR cookie consent popup

- popped up an interstitial form asking for your email address so you could receive their newsletter, but only after you've had the site open for 30 seconds and were in the middle of trying to read it

- was completely blank if you disabled JavaScript to try to avoid all of that nonsense

No thank you; the current design is unironically perfect IMHO.


what kind of satire is this




Join us for AI Startup School this June 16-17 in San Francisco!

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

Search: