12 ms·
Open-Sourcing Windows Calculator
- anonlastname 8y agoThis is the most trivial program on the entire OS. Hooray for Microsoft, I guess.
- Zekio 8y agoit is a good first step, now they just gotta keep walking down this line
- nathell 8y agoMost trivial? Not by a long shot. What about WINVER?
- gpm 8y agoNot windows, but `true` has to take the cake for the most trivial program, the portion of my comment after the second : is a valid implementation:
- mywittyname 8y agoIs true a program? I thought it was a command built into the shell.
- robin_reala 8y agoIt’s /usr/bin/true on Mac, and the OpenBSD source for it is at https://github.com/openbsd/src/blob/master/usr.bin/true/true.c https://github.com/openbsd/src/blob/master/usr.bin/true/true... .
- radgeRayden 8y agoI don't know what I expected.
- int_19h 8y agoMost shells optimize it to avoid the overhead of spawning a process for something as trivial as that. But yes, it's an actual binary even so, just in case - try `which true`. https://www.gnu.org/software/coreutils/manual/html_node/true-invocation.html#true-invocation https://www.gnu.org/software/coreutils/manual/html_node/true...
- gpm 8y agoSome history: http://trillian.mit.edu/~jc/humor/ATT_Copyright_true.html http://trillian.mit.edu/~jc/humor/ATT_Copyright_true.html
- AnIdiotOnTheNet 8y agoGO.COM for CP/M and DOS was similarly trivial. A 0-byte program, the effect of which was to cause the previously run program (which was still in memory at 0100h) to start again.
- ygra 8y agoI wouldn't call the arbitrary-precision may engine in that trivial, per se.
- nathell 8y agoWhoa, it appears to be written in C++/CLI. I wonder how much Windows code also is, and how it impacts maintainability.
- deleted 8y ago[deleted]
- favorited 8y agoI was trying to figure out if it was C++/CLI or C++/CX (I don't do enough Windows dev to know at a glance...). I was hoping it was C++/WinRT – I'm interested in seeing the new language projection in action.
- contextfree 8y agoIt's C++/CX. For an example of OS code that uses C++/WinRT, check out the native UI controls library, WinUI: https://github.com/Microsoft/microsoft-ui-xaml https://github.com/Microsoft/microsoft-ui-xaml
- kristianp 8y agoApparently C++/WinRt was only introduced in Windows 1803 [1], a few years after original Win 10. Interesting to learn that it was originally developed by an independent developer, who was then brought into Microsoft to continue work on it. C++/WinRt uses standard c++. [1] https://en.wikipedia.org/wiki/C%2B%2B/WinRT https://en.wikipedia.org/wiki/C%2B%2B/WinRT
- SloopJon 8y agoThank you. I was trying to figure out what language this is, because there's some weird syntax in the .h and .cpp files that I don't recognize as C++.
- contextfree 8y agoIt's C++/CX, which uses some of the same syntax but targets WinRT instead of .NET.
- valleyjo 8y agoI worked on a win32 application for my first job out of college. My boss told me "want to learn win32 and c++, go program a windows calculator clone." It was a great project to get started and I did learn a lot. Now I have something to compare my work to ha
- ktjfi 8y agoThis calculator is not written using Win32. (Why the downvotes?)
- dvfjsdhgfv 8y agoI guess people downvoting you think it's obvious.
- WorldMaker 8y agoIt's still useful for comparing the C++ parts. Could even be useful for learning how modern UWP XAML compares to classic Win32 approaches in C++.
- mwfunk 8y agoI didn't downvote you, but it comes across like you were trying to nitpick someone by pointing out a detail that isn't relevant to what they were saying.
- valleyjo 8y agoYes I realize this calculator is now a universal windows app, I couldn’t edit cause noprocast locked me out after posting. Reguardless, building a calculator is still a great way to learn a new UI framework. I could see that this would have been a great resource for me as a new engineer (if building a universal windows app).
- turrini 8y agohttps://github.com/Microsoft/calculator#data--telemetry https://github.com/Microsoft/calculator#data--telemetry "This project collects usage data and sends it to Microsoft to help improve our products and services. Read our privacy statement to learn more. Telemetry is disabled in development builds by default, and can be enabled with the SEND_TELEMETRY build flag." Even on a simple calculator.
- yellowapple 8y agoI'm not sure if I should be disturbed or amused by Microsoft putting telemetry in (at this rate) literally every one of its products. Like, what the hell do they even track? I guess the obvious ones are things like application crashes, but now I'm curious if they have the data on the most common calculations, folks' favorite numbers, etc.
- abakker 8y agoI mean, I guess it would be cool to know what kind of operations people are doing most often? Maybe you send different ads to people who only use addition/subtraction than people who use sin / cos?
- jchw 8y agoThis is really cool! I thought the open sourcing of Winfile was cool too. I hope they continue down this road. I doubt we'll see the NT Kernel on GitHub in my life time... but, one can dream.
- dividuum 8y agoTechnically that already happened: https://torrentfreak.com/microsoft-takes-pirated-windows-nt-4-0-source-code-offline-150415/ https://torrentfreak.com/microsoft-takes-pirated-windows-nt-...
- jchw 8y agoThe NT 4.0 source code is probably stupidly interesting and I'm sure there's much to be learned, but... Source code leaking is not the same as something getting open sourced. It's illegal, and it doesn't foster collaboration in the same way. And plus, even as fascinating as NT 4.0 is, it'd be neat to see more recent stuff too.
- ocdtrekkie 8y agoAwesome seeing another component of Windows (albeit a small one) shifting to open source. My hope is that over time, more and more components will end up open source as they get updated and rewritten.
- james_s_tayler 8y agoThis is their whole plan. They are testing the waters with this. Soon all of Windows will be open source.
- ilovwindows 8y agoAnd we still have to pay for it
- thunderbong 8y agoWhat does that have to do with anything?
- Titanous 8y agoIn case anyone is wondering what telemetry is collected: https://github.com/Microsoft/calculator/blob/master/src/CalcViewModel/Common/TraceLogger.cpp https://github.com/Microsoft/calculator/blob/master/src/Calc...
- deleted 8y ago[deleted]
- diminish 8y agoMS goes on to open source the famous and non interesting parts of its products. What's next? Notepad, Ms Paint? Shall we see anything bigger than VS Code?
- shawnz 8y ago> Shall we see anything bigger than VS Code? .NET framework?
- dvtrn 8y ago"Microsoft open sources MSPaint.exe" two weeks later "Show HN: I added transparency support to MSPaint" two (more) weeks later "Adobe shares plummet as users cancel their subscriptions to Creative Cloud by the thousands, analysts baffled"
- doctorRetro 8y agoAs an aside, this very proposed scenario makes me wonder how many users with more casual image editing requirements PaintDotNet has taken from Photoshop.
- dvtrn 8y agoThe real question is: if Microsoft's Paint gets alpha channel support, what happens to GNU Gimp? :P
- ggambetta 8y agoWhile I applaud this, and I'm generally positive about Microsoft's new stance regarding open source, I wonder whether they ever have, or ever will, apologise for having made remarks like "Linux is communism". They caused a lot of damage. It feels a bit disingenuous to just pretend now that nothing happened.
- Teknoman117 8y agoThey will not. I can't find the link at the moment but I read an article about 6 months or so ago where, iirc, Steve Balmer and Satya Nadella where talking about Microsoft's open source plans and some of the history and made a remark that fighting open source "was the correct business choice at the time."
- kilo_bravo_3 8y agoI don't know what a single sentence, said in 2000 by a person who has not been at an organization since 2014 has to do with said organization in 2019. Kind of like the people who comment "embrace, extend, extinguish" on every Micro$oft article, forgetting that the one person to who the phrase has been directly attributed (by a third party who was paraphrasing) resigned from Microsoft 19 years ago and when obliquely referenced (like during lawsuits) the documents used as exhibits in the lawsuits all date from the mid-90s. It kind of makes me roll my eyes, like people ask "did you know coca cola used to have COCAINE in it?"
- ggambetta 8y agoIn the 50s, Alan Turing was convicted for being gay. Much later, in 2013, the UK government issued a posthumous pardon [0]. I'm pretty sure nobody in the 2013 government was in the government in 1950, but AFAIK this was widely seen as a good thing, an admission that what the institution that is the UK government, although not the same people, had made a mistake. I think this applies in exactly the same way to the wrongs of corporations. Out of decency, if not out of being consistent with the idea of treating them as legal persons. [0] https://www.bbc.co.uk/news/technology-25495315 https://www.bbc.co.uk/news/technology-25495315
- 8y ago
- chungy 8y agoIs this the version with floating point precision errors?
- deleted 8y ago[deleted]
- Someone1234 8y agoI might try to commit to this. I've always found the "App" version of Calculator lacking compare to its Win32 predecessor. In particular History. On the old Calculator you could double-click the history and edit the equation, and get a new result, no go on the App. Plus the Programmer UI, while being more powerful is actually harder to use since the information is now split between two screens rather than one. Oh and you cannot paste in currency ($10) is now invalid. The old one just stripped the currency symbols.
- gdulli 8y agoI use this: https://winaero.com/blog/get-calculator-from-windows-8-and-windows-7-in-windows-10/ https://winaero.com/blog/get-calculator-from-windows-8-and-w... I don't know if it has the features you're missing, I use it because I don't like the look and feel of the new apps.
- smush 8y agoVery nice, and it even has a chocolatey package via choco install oldcalc so I can do my [Windows]+R calc and have the Win8 calculator open, very nice indeed!
- kristianp 8y agoI don't like the fact that the new calculator always seems to be the wrong size, when using different DPI monitors. I don't need calc to take up 90% of the screen and I don't want to have to resize it. There's no real need for that. Agreed on the history missing functionality, that has annoyed me too.
- slimscsi 8y agoNow if the would open solitaire, that would be huge.
- nimbius 8y agospeaking from experience working in a truck repair shop, I quit using calculator in windows as it was rather unreliable. if im calculating inner diameter or outer diameter for a part, or doing tooth math for machining a new bull gear, ive often encountered wildly different values in calculator from what a machinists handbook tells me. Ive even had an old-timer warn me about different depth and feed rate calculations that calculator has never done right. This is simple shop math, but i think we're calling it trigonometry these days. https://blogs.windows.com/windowsexperience/2018/04/04/announcing-windows-10-insider-preview-build-17639-for-skip-ahead/ https://blogs.windows.com/windowsexperience/2018/04/04/annou...
- orbital-decay 8y agoThis is an issue with any math-related tool in general, including the specialized software, where bugs are much much more sophisticated. Most App Store/Microsoft Store/Google Play apps can't be trusted even for simple square root and trigonometry calculations.
- acqq 8y ago> doing tooth math for machining a new bull gear, ive often encountered wildly different values in calculator from what a machinists handbook tells me Please some example, I'm curious, as Microsoft claims that they use the "infinite" precision library there.
- tombert 8y agoThis is cool, but I really wish they'd release the source for the original Notepad. No real reason other than "this software was really important to me when I was a kid". As it stands, though, Calculator is not something I've particularly cared about in the Windows world; pretty much anyone here could write a simple calculator app in an afternoon. Still, I am glad MS is slowly becoming more OSS-friendly; I doubt anyone installs Windows specifically for the calculator app, so as a result, why the hell not open-source it?
- ocdtrekkie 8y ago"Original" is the issue there. They're far more likely to open source a modern UWP app, written with current best practices in mind, rather than a 20 year old C app with untold terrors hiding in the codebase. If they ever rework Notepad into a UWP app, I suspect that would be open sourced, as I expect many newer Windows components to be.
- ktjfi 8y agoPart of the Windows 2000 source code leaked and it included Notepad. I don't think it's changed much since then as it's pretty much a wrapper around the Win32 widget with a few features like changing the font, printing, etc. The only place where I found it where it is publicly "browseable" -> http://www.codeforge.com/article/148667 http://www.codeforge.com/article/148667
- _trampeltier 8y agoIt seems they updated a couple of things in Notepad (Unix eol, text size, ..) https://hn.algolia.com/?query=windows%20notepad&sort=byDate&prefix=false&page=0&dateRange=all&type=story https://hn.algolia.com/?query=windows%20notepad&sort=byDate&...
- sixothree 8y agoAccepting some pull requests on notepad would be nice....
- temac 8y agoIIRC Notepad source code is in a Windows SDK. Probably an old one, but it only started to be actively maintained quite recently (and even then: only very lightly), so the source code you can get will likely cover most of its lifespan for now. I'm not sure the source of notepad is that much interesting, though. I mean, yeah, nice to have out of curiosity, maybe, but I'm not sure I would get anything from looking at it. I'm even more interested by monstrosities like historical version of conhost, or of cmd, because it is both simultaneously horrendous and bizarrely not extremely buggy (probably was debugged by some kind of brute force effort, then... :p ) Although a version of the Notepad source under a free software licence would at least permit to strip it of the new ridiculous shits, like "Search with Bing" and maybe some spying features.
- shakehar 8y agoFinally I can have it run in a size that does not take up 3/4th of my screen by default.
- nly 8y agoKinda shocking how large the codebase is for such a simple app
- Someone1234 8y agoThat's enterprise development for you. 49% boilerplate, 49% tests, and 2% actual code.
- deleted 8y ago[deleted]
- Tade0 8y agoNice to hear that. I like to calculate stuff from time to time, so I use the default OS calculator app a lot. The Windows one is actually pretty decent, except maybe for the shortcuts - e.g. raising to the power is under "y" for some reason. Ubuntu/Linux(es) has by far the best one. The shortcuts are obvious and the whole expression is visible at all times. The one for macOS is surprisingly lacking.
- ygra 8y agoI think that function has been bound to y for decades by now. No reason to change muscle memory, even when rewriting the UI.
- cbsks 8y agoThe "help wanted" label on some of the GitHub issues[0] is interesting to me. Presumably there are Microsoft employees who are being paid to work on Calculator, are they trying to crowd-source their jobs? I should convince my company to open source the project I am working on so I can offload some of my work too ;) [0]: https://github.com/Microsoft/calculator/issues?q=is%3Aissue+is%3Aopen+label%3A%22help+wanted%22 https://github.com/Microsoft/calculator/issues?q=is%3Aissue+...
- WorldMaker 8y agoIt's something of a GitHub-wide standard/best-practice to have a "help wanted" or "probably easy" or "good first issue" label: https://help.github.com/en/articles/helping-new-contributors-find-your-project-with-labels https://help.github.com/en/articles/helping-new-contributors... It's the Open Source issue tracker equivalent of the "Welcome mat". It doesn't necessarily mean that Microsoft's employees here need help, but it certainly shows that they welcome it. (Which is a very useful indicator for engagement and shows presumably some stake in actually continuing to develop Calculator out in the open, as opposed it being a one time or rarely-if-ever code drop.)
- neop1x 8y agomaybe it become so complex that it's hard to maintain so they seek the community to maintain it for them for free so they can focus on selling the OS it runs on. ;)
- fetbaffe 8y agoHow many threads for a calculator? My Task Manager says 20.
- deleted 8y ago[deleted]
- ilovwindows 8y agoSo they are gonna open source everything so that the community can contribute to it and still charge us for using it. Cleaver move Microsoft
- faissaloo 8y agoThis is going to be great for ReactOS, they're even open sourcing more of their UI components.
- jacobparker 8y agoThe history is truncated on GitHub. (first real commit is https://github.com/Microsoft/calculator/commit/c13b8a099eea11d5d6777de7562d350352b909d2 https://github.com/Microsoft/calculator/commit/c13b8a099eea1... ) They're using GitHub to merge PRs now. Was this source previously in the Windows repository? Has all development moved to GitHub? If it was in the Windows repo, are they mirroring it back? Do they still have the old history? There are multiple ways to deal with this in git (grafts, replacements) I wonder if they're using anything like this to get full history, internally.
- nevster 8y agoCan someone explain why it launches so slowly? It's 2019, I have a multi-gigahertz processor, it's a calculator app, and it takes a few seconds to launch!
- neop1x 8y agoAll the layers of more and more abstractions. What used to be a simple app with a few dependencies is now multi-team project requiring almost a virtual machine to run.
- platz 8y agoI see xaml there, does that mean this is WPF even though it's c++ ?
- Const-me 8y agoThat's XAML but not WPF. XAML is just a markup language, it's used across multiple frameworks and languages. This particular technology is called UWP, it's mostly rebranded WinRT. Historically, XAML was also used in Silverlight, both desktop/web, WinCE, and Windows Phone.
- platz 8y agoWell, the constructs used in the xaml appear to be very similar between uwp and wpf. You still have controltemplates, datatemplates, and dependency properties, so there is a lot in common more than just syntax.
- Const-me 8y agoThe syntax and controls are indeed very similar. If you know any XAML, you’ll have zero issues using the rest of them. Speaking from experience, I started with Silverlight a decade ago, had no problems switching to others. But the underlying tech is very different. Early Silverlight rendered on CPU, WPF is based on DirectX 9, UWP uses Direct3D 11. Silverlight and WPF are .NET based, WinRT and UWP are not, they’re 100% native code, exposed to .NET through COM interop.
- platz 8y agothanks
- kerng 8y agoIs this for the old school cool calc.exe or the new Calculator Windows 10 app?
- charliebrownau 8y agoIs that the proper old calc from win9x-2x/XP/7 or the new cloud web "app" with 8/10
- tee5r333 8y agoMy favorite calculator was the PowerToy Calculator back in the Windows XP days. Does anyone have a suggestion for a replace on Windows 10?
- mihaitodor 8y agoI can’t believe the core of it is still some C code from ’95 called “Ratpack”: https://github.com/Microsoft/calculator/tree/master/src/CalcManager/Ratpack https://github.com/Microsoft/calculator/tree/master/src/Calc... over which they added a whole bunch of enterprise fluff.
- acqq 8y ago> I can’t believe the core of it is still some C code from ’95 Why? https://en.wikipedia.org/wiki/NumPy https://en.wikipedia.org/wiki/NumPy "Internally, both MATLAB and NumPy rely on BLAS and LAPACK for efficient linear algebra computations." As far as I know BLAS and LAPACK are still based on the decades old FORTRAN code.
- 1337shadow 8y agoI hope cmd.exe is next so that we can learn how to build terminals the ms way
- edward 8y agoThey accepted my pull request: https://github.com/Microsoft/calculator/pull/106 https://github.com/Microsoft/calculator/pull/106