14 ms·
Calc.exe is now open source; there’s surprising depth in its ancient code (2019)
- maxbaines 6y agoNotepad next...
- prepend 6y agoMSPaint please
- selfhoster11 6y agoI would very much welcome that on my Linux install.
- yjftsjthsd-h 6y agoObviously not quite the same, but if you haven't seen it yet: https://jspaint.app/ https://jspaint.app/
- Pet_Ant 6y agoWhy? There is Paint.Net and it was open source for a long time.
- prepend 6y agoBecause Paint.Net isn’t MSPaint. It’s not exclusive. There’s lots of paint programs but only one MSPaint. Why calc.exe?
- selfhoster11 6y agoUnlikely. Notepad is just a wrapper around the Windows API's textbox/textarea/whatever it's called, so open sourcing it isn't much.
- saagarjha 6y agoApple open sourced TextEdit for exactly that reason, to show how easy it is to write text editing applications in Cocoa: https://developer.apple.com/library/archive/samplecode/TextEdit/Introduction/Intro.html https://developer.apple.com/library/archive/samplecode/TextE...
- foepys 6y agoNotepad.exe is just a wrapper around the edit control [1] that Windows ships as part of its core system. It doesn't even properly support undo as you can only undo the last action, which becomes the new last action, allowing you to only toggle between two states. https://docs.microsoft.com/en-us/windows/win32/controls/edit-controls https://docs.microsoft.com/en-us/windows/win32/controls/edit...
- ianhanschen 6y agoIt's a window that mostly uses an edit control, but, having code in Notepad, it's not just a wrapper around the edit control. Could you write Notepad in a day or two? Perhaps. But it's deceiving to say that it's just a wrapper around the edit control.
- jmercouris 6y agoText says “depth”, I read “spaghetti”
- Laakeri 6y agoYou may not like it, but this is what peak performance looks like.
- sumtechguy 6y agoOne mans spaghetti is another mans elegant architecture. Though sometimes it is spaghetti. 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.
- commandlinefan 6y agoReally? It was actually a lot better than I was expecting.
- LeonM 6y agoMaybe now someone can finally fix the pixel alignment... https://www.reddit.com/r/mildlyinfuriating/comments/a5r971/the_microsoft_calculator_buttons_being_one_pixel/ https://www.reddit.com/r/mildlyinfuriating/comments/a5r971/t...
- TeMPOraL 6y agoOh hell, I didn't need to know that. Now I'll be noticing it every time I see the new Windows calc...
- StavrosK 6y agoIt's your punishment for running Windows.
- me551ah 6y agoI'm right now running pacman on Arch Linux via WSL while playing 'Call of Duty' in another window. Let's see if your OS can beat that.
- StavrosK 6y agoIt can run Call of Duty, yeah: https://www.protondb.com/app/393080 https://www.protondb.com/app/393080
- globular-toast 6y agoOf course it can beat that. Just swap "Call of Duty" with something that only runs on Linux.
- andi999 6y agoStandard mode doesn't follow PEMDAS. This software needs to go. https://answers.microsoft.com/en-us/windows/forum/apps_windows_10-winapps-appscat_tools/windows-10-standard-calculator-not-using-standard/64aaf724-5f16-46c5-87fe-9da0a297a4d4 https://answers.microsoft.com/en-us/windows/forum/apps_windo...
- nightcracker 6y agoThis is the standard way calculators have operated since forever. They don't evaluate a whole expression, they simply have an accumulator and you operate on it one step at a time.
- me551ah 6y agoWhile its basic math you would be surprised at how many people have forgotten about PEMDAS. I would argue that the additive way comes more naturally to people. For people wanting to more complex equations scientific one does follow PEMDAS.
- munchbunny 6y agoI think it's just a matter of people adapting to the tools that are easily available. Almost 100% of the time I've seen someone use an actual basic tabletop calculator, they've been tallying prices and slapping on a sales tax. At that point it's just a learned ritual and they're not thinking about order of operations. If they needed parentheses, they'd just memorize that the parentheses go around the prices. 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.
- deleted 6y ago[deleted]
- gekkonier 6y agoBack in stoneage, while using Windows 3.11 (I think it was calles Windows for Workgroups or so...) there was a bug in calc: 0.02-0.01 resulted in a flat zero. Perhaps it's time to open an issue.
- mschaef 6y agoThey addressed that quite a long time ago, with a switch away from floating point math: https://devblogs.microsoft.com/oldnewthing/20040525-00/?p=39193 https://devblogs.microsoft.com/oldnewthing/20040525-00/?p=39... 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.)
- Narishma 6y agoIt must have been fixed ages ago as I can't reproduce it in Windows 95.
- gekkonier 6y agoYes, as far as I remember it was really only in WfW 3.11
- qsort 6y agoI've always found calculator applications to be quite funny. To use a calculator application while sitting at a computer is at least a bit ironic.
- mywittyname 6y agoThe original intention of computers was to perform calculations. The inclusion of facilities that allow for calculations to be performed on a computer is ironic how? That seems like thinking it ironic that lawn mowers have a place to put blades for cutting grass.
- dijit 6y agoI agree with the parent because creating code which runs arbitrary calculations is quite weird. You would assume you could just send instructions to the CPU and print the output. 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.
- anthk 6y agoI think your parent comment meant computers are calculators themselves since forever.
- qsort 6y ago> That seems like thinking it ironic that lawn mowers have a place to put blades for cutting grass. A more apt analogy in this case would be a car having pedals.
- Blikkentrekker 6y agoThe irony is more so the unnecessary skeuomorphism, that, inside of a machine that is a strict superset in capabilities of another, simulates the limited interface of the latter machine to make it “look and feel” as though it be an actual calculator. 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.
- mylons 6y ago"surprising depth in ... ancient code" seems extraordinarily condescending to the past, upon which computer science has evolved little.
- thehappypm 6y agoPerhaps what's surprising to non-programmers is that older code tends to be better/faster/more optimized than new code, which is unintuitive because new hardware is orders of magnitude better.
- Blikkentrekker 6y ago“better” by definition of often applying rather absurd hacks for the sake of performance, yes, hacks that very often also compromise the output of the end result. 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.
- pixl97 6y agoIt's an inverse relationship. As the "just release a patch" method of development takes over the idea of a 'gold master' disappears. When software used to ship on floppies and no one had modems, in general software had to ship working 'well enough' because it was not easy to fix. 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.
- thehappypm 6y agoI completely agree. I wonder if there would be a niche for high-performance languages that are maybe a little harder to write than Python but still easy, and closer to the performance of C.
- userbinator 6y agoThis is the "modern" one with the egregiously bloated UI (including a loading screen!) and telemetry... but funny that it's using the same calculation code. Of course they still managed to screw it up somehow: https://news.ycombinator.com/item?id=17670644 https://news.ycombinator.com/item?id=17670644 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 https://news.ycombinator.com/item?id=19321217
- tyingq 6y agoOpen sourcing it seems to be working. Several of the open pull requests fix bad math: https://github.com/microsoft/calculator/pulls https://github.com/microsoft/calculator/pulls
- capableweb 6y agoSeems there are 4 pull requests open to fix various math issues, all of them opened in 2019. Most PR merges seems to be about minor changes like translations and version bumps. Not sure we can call it a success just yet. 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.
- swiley 6y agoA loading screen? You're probably better off just using a REPL at that point.
- Shadonototro 6y agoit's no wonder windows 10 is ugly 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
- thrower123 6y agoXAML is relatively horrible to work with in comparison to the old Win32 controls.
- sdflhasjd 6y agoAm I the only one that likes XAML?
- dblohm7 6y agoI prefer Android's XML mechanism for declaring UI over XAML.
- miguelrochefort 6y agoHow come? XAML is intuitive and powerful. Android XML seems like an afterthought.
- miguelrochefort 6y agoI disagree. XAML is by far the best UI framework I’ve worked with.
- the_only_law 6y agoI’ve always wondered how far back the modern Windows 10 codebase goes. Could there be any remnants in the code from before the Windows 3.x era? Also being open source do they accept pull requests? Can my code end up being shoved out in a Windows update?
- CodeHz 6y agoat least the oldest icons are still exists in modern win 10, yes, even after ms decided to update some icons to fit new "Fluent Design" https://imgur.com/a/6T31ziE https://imgur.com/a/6T31ziE (from latest insider build
- WorldMaker 6y agoSome changes to calc.exe (and a few other open source parts) in Windows 10 over the last couple years have come from pull requests.
- ChrisArchitect 6y ago(2019) Some previous discussion: https://news.ycombinator.com/item?id=20696695 https://news.ycombinator.com/item?id=20696695
- waynesonfire 6y agoI use https://thomasokken.com/free42/ https://thomasokken.com/free42/ as my calculator on all my devices: android, pc, and offline.
- dang 6y agoIf curious, past threads: Windows 10 Calculator is now running on WebAssembly, natively on iOS and Android - https://news.ycombinator.com/item?id=20275484 https://news.ycombinator.com/item?id=20275484 - June 2019 (10 comments) Fixing a Small Calc.exe Bug - https://news.ycombinator.com/item?id=20210963 https://news.ycombinator.com/item?id=20210963 - June 2019 (117 comments) Counting Bugs in Windows Calculator - https://news.ycombinator.com/item?id=19367366 https://news.ycombinator.com/item?id=19367366 - March 2019 (53 comments) Open-Sourcing Windows Calculator - https://news.ycombinator.com/item?id=19321217 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 https://news.ycombinator.com/item?id=17670644 - Aug 2018 (88 comments) %*$*#&#* Windows 7 Calculator - https://news.ycombinator.com/item?id=10791667 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 https://news.ycombinator.com/item?id=1623381 - Aug 2010 (23 comments)
- dhosek 6y agoWait, isn't this the calculator that doesn't know order of operations? When I used to teach math, I would tell my students to type in 1+2*3 in their calculator and if it didn't give 7 as the answer, they should throw it away. The Windows calculator was one of the ones that failed, if I remember correctly.
- stu2b50 6y agoRather than not knowing order of operations, it doesn't parse algebraic expressions, it just takes binary inputs for the common real operations. It doesn't operate on "1+23" as an input, it operates on "1", "+", "2" = 3 "" "3" = 9.
- Snitch-Thursday 6y agoI'm running calc.exe from Ye Olde Windows days, not this fluent-UI 'refresh', and it gave me 9. Feeding it 1 + (2*3) produced 7.
- treesprite82 6y agoWindows 10 calculator has a simple mode where operations are evaluated immediately which would give 9 for those keystrokes, but does at least show what it's actually calculating: https://i.imgur.com/au7dvfg.png https://i.imgur.com/au7dvfg.png In scientific mode you can enter the full expression and get 7: https://i.imgur.com/DT6LNKb.png https://i.imgur.com/DT6LNKb.png
- contextfree 6y agoIt works like you say in standard mode by design because it's trying to match the behavior of older desk calculators that worked that way. In scientific mode it respects order of operations. There's a proposal to change the UI to make this clearer: https://github.com/microsoft/calculator-specs/blob/247bbb50d6d7f1d02410e967673a7ae095778d4f/active/TransactionalHistory/README.md https://github.com/microsoft/calculator-specs/blob/247bbb50d...
- dhosek 6y agoIt seems absurd to make the default behavior incorrect because older cheap calculators did the wrong thing. This isn't like making an incompatible change to a programming language to fix an incorrect behavior, this is more like if the designer of a new programming language decided to make 1+2*3 give nine because his cheap desktop calculator did the same.
- dblock 6y agoPSA: Here's another, much more feature-rich calculator called Expression Calculator (or Global Calculator sold in Germany in 1997), written in Delphi - https://github.com/dblock/excalc https://github.com/dblock/excalc, full source code and a working executable that still runs on any version of Windows.
- tombert 6y agoI probably wouldn't have time to do this for next few years, but I wish they'd release regular Notepad as open source. There's a part of me that sort of wants to do some kind of masochistic feature-by-feature port of Notepad into a functional language, just to pay homage to the first editor I ever used. 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.
- bad_username 6y agoRaymond Chen about the infinitely precise engine of the Windows calc. https://devblogs.microsoft.com/oldnewthing/20040525-00/?p=39193 https://devblogs.microsoft.com/oldnewthing/20040525-00/?p=39...
- casefields 6y ago>I wouldn’t be surprised if these are the same people who complain, “Why does Microsoft spend all its effort on making Windows ‘look cool’? A few years later they released Vista. Stones and glass houses.
- jordache 6y ago3.11-3.10= ???
- GoToRO 6y agoMaybe they can fix this one, in the new calc: https://superuser.com/questions/26193/why-does-windows-calculator-always-start-minimised https://superuser.com/questions/26193/why-does-windows-calcu...
- deleted 6y ago[deleted]
- killjoywashere 6y ago> the very earliest iterations of Windows Calculator, starting in 1989, didn't use the rational arithmetic library, instead using floating point arithmetic and the much greater loss of precision this implies. 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.