Calc.exe is now open source; there’s surprising depth in its ancient code (2019)
arstechnica.com
arstechnica.com
In one of the old Win2k source leaks the code can be found for the far more efficient "classic" one.
Also, title needs (2019). There are some other HN articles from around that time discussing it: https://news.ycombinator.com/item?id=19321217
It's very cool it's open source in the first place though, don't get me wrong. And MS doesn't have to merge fixes if they don't want to of course.
You're probably better off just using a REPL at that point.
But anyway, for a quick calc, is there anything faster than Spotlight (for mac)/Gnome shell (for linux)/Powertoys Run (for windows)? Instead of app name you are going to launch, just punch in your expression.
Why don't they tell you that after you've launched calculator for the 20th time in an hour.
Maybe 1 in 5 that I try will be a reasonable startup time.
I'm getting 1-2s on my machines, both just plain powershell and powershell inside windows terminal. No enterprise crap running though, just Defender.
It took upgrading to i9s to get something that could run Teams and Outlook at the same time without audio stuttering during a voice call.
Or maybe starting anything on modern windows is slow.
You can try Windows 3.1 here: https://www.pcjs.org/software/pcx86/sys/windows/3.10/
And, indeed, 2.11 - 2.1 = 0.00
But, if you then add 1.0, you get 1.01. So the right value is there somewhere.
"It was fixed in this update for Windows 3.1, which switched away from floating point: https://jeffpar.github.io/kbarchive/kb/124/Q124345/"
These apps really should produce 0 for this and avoid floating point issues. Most of us understand why it wouldn't. To me it's an experience/quality issue.
For what it's worth, the default Android calc app produces 0 (as well as nice RPN apps like Droid48).
They seem to be going the other direction; notepad.exe is now updated from the App Store in the Dev channel.
Hoping you could point out how to build it or where it is hiding.
This is for the new calculator only.
What happened to software...
So, no. Not for me.
IIRC somewhere along the line of all the Win32 windows versions the loading animation got somewhat broken and explorer window was more likely to get simply unresponsive instead of displaying loading animation, but that is another story.
The user became the product.
Windows collects user behavior and sells ads.
You can still buy whatever they call Windows LTSB this week if you hate this.
> Do you really think it is going to make much difference to the final answer?
> Even the algorithms used are probably only accurate to so many significant figures.
Beautiful. (Keep in mind the issue referred to here only requires five decimal digits to show up.)
Sounds like the linux ecosystem moved to client-side-decorations, and Windows moved to a window manager model.
Wait, you only get one of those? As of about a month ago on my computer, launching calc.exe takes 5-6 seconds for anything to happen and I'm then greeted 1-2 seconds of a loading screen after the window appears.
I've taken to just leaving an IDLE shell open at this point.
https://www.reddit.com/r/mildlyinfuriating/comments/a5r971/t...
Yeah?
I'm running Far Cry $SOME_SEQUEL_NUMBER on Wine, while running Android Builds in a background terminal, using another terminal to hack into the Israeli Defence Force network to deliver my Android exploit that will cause their centrifuges to spin slightly too fast in the incorrect direction, slowing down the spin of the earth ever so slightly ... I'M STOPPING TIME! ...
(Too much? :-)
I’ve been cutting people out of my life for repeatedly talking like GP (and you, to a lesser extent) lately; that’s how frustrating it is to be on the other end after 20 years of hearing it from elitist peers. I finally snapped when I set my iPhone on the table at a bar and was treated to the entire conversation turning to iOS vs. Android for the next two miserably painful hours, while ignoring that we all went there to drink to forget about shit like that.
You might consider my approach harsh. That’s fine because I know my approach is clearly better. (See?) It amazes me that it’s been decades now and advocates of non-mainstream operating systems and tools (read: FLOSS) haven’t figured out looking down at the people you’re trying to convince is repulsive to anything you’d say - and sometimes you as a person. Persuasion from a negative is almost always a net loss. Ask anyone in sales.
Tell me why it’s better for my specific needs. Not that my choices are inferior. Until then, I’m distantly happy for you that you’ve found a tool that works for you, and I’d prefer that you tell someone else (in general, not you specifically). I’m especially thinking of the randoms who don’t know me and approach at conferences or social events to reflect on my choices. It’s never Windows or macOS or Edge or VS Code advocacy, either, weirdly enough. Emacs in particular seems to catch these attitudes like a magnet.
Edit: Wider screenshot.
In particular, some old video games feature the absolutely most wonderful hacks to achieve what they wanted to with the available hardware, but also often lead to engines having to make particular compromises in possibility of environment design that many players failed to notice.
Many older game engines were actually incapable of stacking walkable planes on top of each other, though the levels were three dimension and one could ascend and descend, there was never any walkable surface directly under another, which was necessary for some optimizations.
Also older software tended to be documented better because there was no 'fire off an email' or 'ask Bob on Slack' what this code means. The barriers to quick communication where higher, hence reading the code comments would have been the path of least resistance.
Is it arrogance to say that medicine is far better than it was in the past?
Irrelevant. Medicine and Software Development are not correlated, just because we want them to be. That's the point. Software Development results seem to have devolved (quality metrics such as binary size for equivalent reliability, functionality, and notably time to release), despite improvements in almost every aspect of development tooling.
Also interesting to note, these quality metrics follow along expected curves (accounting for development tooling) when DUPLICATING (sometimes with small improvements) working software. This tells us a great deal about what is a large problem with modern software.
Binary size is not a quality metric.
Server back ends don't care about it, front ends don't care about it despite the lip service paid, games sure as hell don't, etc
A small minority of web devs seem to care, together with creators of already gigantic mobile apps and as I was saying, embedded devs working in very constrained environments.
The market, as a whole, maybe has this as their 100th priority. Which means it's not.
No, they're not worthless, they're worth less :-)
Don't tell me, tell the business people financing everything we build. By and large, they don't care, it's reflected in incentives and it's reflected in what we build.
So yes, I stand by that strawman.
Another common scapegoat for developers who write bad software. I just wish we had a little more integrity as an industry, especially since so many of us insist on calling themselves "engineers".
Software designed to spec and user requirements does (where those requirements could be fast development time, high performance for whatever the performance criteria are, longevity, easy and cheap extensibility, etc.).
Binary size, as I was saying before, is like 100 on the list of priorities for most categories of software. Mobile apps sometimes have it as a priority and embedded apps frequently have it, too. But for mobile apps those limits are loosening, so soon they'll stop caring, too, and embedded apps are a minuscule percentage of all apps developed out there (most of them are web apps, especially Line of Business - LOB - apps).
Sometimes even playing music doesn't work on my mobile phone, and I have to restart it. I never had that problem with my casette player 30 years ago. But that doesn't mean that I go back using a casette player instead of my phone for listening music.
Shipping meant producing that gold master build and sending it off to a floppy replication service and then got distributed to the store shelves. That 1.0 version was frozen until you'd ship a new version a year or more later. There was no second chance for that release, code had to be as close to perfect as possible, first time out.
Expecting code from the past to be "worse" is like expecting math from the past to be worse.
It's just improving classical computer science has less practical benefits than machine learning nowdays, so the focus of research changed.
Windows 10 Calculator is now running on WebAssembly, natively on iOS and Android - https://news.ycombinator.com/item?id=20275484 - June 2019 (10 comments)
Fixing a Small Calc.exe Bug - https://news.ycombinator.com/item?id=20210963 - June 2019 (117 comments)
Counting Bugs in Windows Calculator - https://news.ycombinator.com/item?id=19367366 - March 2019 (53 comments)
Open-Sourcing Windows Calculator - https://news.ycombinator.com/item?id=19321217 - March 2019 (174 comments)
Windows Calculator invalid input with 10^x function - https://news.ycombinator.com/item?id=17670644 - Aug 2018 (88 comments)
%*$*#&#* Windows 7 Calculator - https://news.ycombinator.com/item?id=10791667 - Dec 2015 (108 comments)
Why is there not a Square Root button in calc.exe? - https://news.ycombinator.com/item?id=1623381 - Aug 2010 (23 comments)
https://devblogs.microsoft.com/oldnewthing/20040525-00/?p=39...
A few years later they released Vista. Stones and glass houses.
Some previous discussion: https://news.ycombinator.com/item?id=20696695
That seems like thinking it ironic that lawn mowers have a place to put blades for cutting grass.
The idea that there’s a huge wrapper around the CPUs core functionality is indeed weird because you would expect that functionality to be available without any program at all.
A more apt analogy in this case would be a car having pedals.
Obviously, a prompt that accepts arbitrarily complicated mathematical expressions and returns a value is a far superior interface than clicking on buttons with a mouse, but skeuomorphisms in design are very common place, in spite of their lesser efficiency.
(This obviously misses the point that we made computers usable by mostly anybody along the way, but it’s still funny)
- planning a program
- implementing missing mul and/or shl instructions in your mind
- managing register pressure for more complex expressions
- having to start from scratch on a mistake
- debugging with a multimeter
Even if you think of MBR-style calculator, there is at least dozen kb BIOS and dozen kb VGA BIOS to start with a blank screen that can do cursor and digits. There is nothing cheap or straightforward down there, and the first thing people did was abstracting baremetal away ASAFP.A modern CPU has got the calculation part covered by itself, but it still needs the UI. Of course there are other kinds of UI for people to do calculations - for example Excel, or programming language REPLs - but desk calculators had pretty good UI for some use cases, so it makes sense to have an option based on them.
A more apt comparison would be having a 40ft tall Mech that transforms into a jet and flies from neighborhood to neighborhood then crouches down and uses a tiny pair of scissors to cut the grass.
Transposing the metaphor of a desk calculator verbatim is inefficient and unproductive, graphical gimmick exclusively. Unix bc, which predates Windows calculator by a couple decades, is Turing-complete and in fact close to a full-featured modern dynamic language.
Today's equivalent would be a {python|ruby|node|perl} REPL.
Accessibility is everything. I would guess the skeuomorphic calculator apps have 5 orders of magnitude more users than bc, and 4 more than the REPLs (not that the REPLs were even built for this purpose).
I think they will evolve over time away from skeuomorphism, but not into anything resembling a plain REPL.
Also, the UX of a REPL sucks because it lives in a white-on-black terminal and prints scary version messages about a thing called "clang". Do the same thing with nice colors and friendly messages and I doubt the usability would be any worse.
Engineers fall into this trap a lot - projecting our own preferences onto what we think other people should find accessible. Most people require training before they can use Excel. The training required to use a calculator is so minimal, they teach it in elementary school. And a REPL is gibberish to the vast majority of people, even if you dress it up with nice colors and friendly messages (which to be fair help a lot).
Powershell says 0.2,
calc.exe app and libreoffice calc agree with 0.2,
BC running in CYGWin also 0.2,
Python 2 and 3 answer 0.19999999999999998,
JS in Vivaldi and firefox also answer 0.19999999999999998,
But Portacle (Common Lisp) returns 0.20000002
- if you get 0.2, the code is using rational numbers or a custom implementation
- 0.199999...8 is the double precision IEEE subtraction.
- 0.200000...2 is the single precision IEEE subtraction.
This looks like a typecasting/coercion issue. You can likely get all of the above in C++ or Java by using different explicit casts.
IIRC, there are languages that use IEEE double precision but the way they handle default display presents this as 0.2 (basically, they use a display algorithm that displays the shortest decimal expression that has the same double precision representation.)
jshell> new BigDecimal("0.3").subtract(new BigDecimal("0.1"))
$8 ==> 0.2 jshell> .3f-.1f
$1 ==> 0.20000002
We got ourselves a hat trick :)Floating point implementations can vary not only between languages, but also between different CPUs, if the language relies on the hardware implementation (which is the smart thing to do in most cases).
As a side note: Python's implementation of FP isn't standard-compliant. E.g. when you divide by 5.0 by 0.0, the standard says you should get a +inf. In Python you get an exception.
In [1]: from decimal import Decimal as D
In [2]: D('0.3') - D('0.2')
Out[2]: Decimal('0.1')[1] https://medium.com/@raiph_mellor/fixed-point-is-still-an-app...
For a refreshingly modern take on calculator apps, take a look at something like Soulver/Numi/Calca which use a notebook-style interface, or SpeedCrunch which uses a REPL-style interface (and which does have a keypad, but you can turn it off).
If the idea of a calculator app just seems ugly to your brain, PowerShell does floating-point math and is scriptable to boot. I've used it as a calculator in the past, though it means having to put up with some wonky syntax.
I'm sure all tools you suggest are great, but as someone who can program, I can just use the REPL of whatever programming language I'm using at the moment. I have no need for a dedicated tool in the first place.
How would a non technical person do a square root or exponent? It's not obvious to type sqrt(2) or 3^4 into a text field, and people shouldn't have to read a manual to use a calculator. The default calculator is meant for the average person, and advanced tools are available for the rest.
Feeding it 1 + (2*3) produced 7.
In scientific mode you can enter the full expression and get 7: https://i.imgur.com/DT6LNKb.png
There's a proposal to change the UI to make this clearer: https://github.com/microsoft/calculator-specs/blob/247bbb50d...
It's a different paradigm to using the buttons to enter a full expression then pressing [=] to evaluate it, but I don't think it's accurate to call it "the wrong thing" - just that the button presses aren't transcribing to the equation you expect (the equation actually displayed by Windows 10 calculator is now accurate).
their stack to design native programs is bloated and confusing af, it seems very tedious and incompatible with quick iteration workflows
when you compare to apple with SwiftUI, it's night and day
XAML is intuitive and powerful. Android XML seems like an afterthought.
Somewhat related, HP calculators used floating point BCD internally since the beginning, to avoid this sort of thing. (Custom mostly-4-bit CPU chips with specific hardware for the purpose, etc.)
As I recall, there was quite a bruhaha about Windows calculator solving 2 x 2 as 3.9999999945 or something like that. Pretty sure this rational number library was added in response to bad press.
Why calc.exe?
https://docs.microsoft.com/en-us/windows/win32/controls/edit...
Also being open source do they accept pull requests? Can my code end up being shoved out in a Windows update?
I know that I could obviously just create my own text editor, but I think it would be kind of fun to specifically recreate notepad of all things.
https://superuser.com/questions/26193/why-does-windows-calcu...
Having read the code and lots of other MS code. It is in pretty typical MS style. Though a bit undercommented for the random few modules I looked at. I am sure there are probably a few bits in there that are hairy. But I think I will skip that code review today.
Do not mistake someone else's "style" for "ugly". It is an easy trap to fall into.
https://answers.microsoft.com/en-us/windows/forum/apps_windo...
Once the computations get complex enough that you have to write down the formulas, then it makes a lot of sense to treat the computations as algebraic expressions, meaning PEMDAS.
These days for actual physical calculators, and on phone, I've transitioned to RPN which neatly transcends such petty ambiguity problems.
If you took one of the people who still use old fashioned "standard" calculators and put them on a standard mode that followed PEMDAS, they'd probably be confused, at least initially. I've seen that a lot at cash registers in restaurants, dry cleaners, and other small businesses.