
Open-Sourcing Windows Calculator - Shinkirou
https://blogs.windows.com/buildingapps/2019/03/06/announcing-the-open-sourcing-of-windows-calculator/
======
turrini
[https://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.

~~~
dtrailin
Basically every Android and IOS app you use collects telemetry (which you
usually cannot disable) for UX purposes but suddenly when Microsoft does it
it's a Big Deal. I don't see the issue with refining UX using anonymous data
if it improves the product for the end users. Every high quality commercial
app does this.

~~~
rozenmd
You can effectively disable telemetry in Android by getting Blokada from
F-droid

~~~
oblio
Can it run on regular Android?

~~~
narcissus
You don't need to root your phone to run Blokada, if that's what you're
asking... I installed it sometime last year and as of right now, it claims to
have blocked 595944 requests.

------
tombert
This 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?

~~~
ktjfi
Part 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
It seems they updated a couple of things in Notepad (Unix eol, text size, ..)
[https://hn.algolia.com/?query=windows%20notepad&sort=byDate&...](https://hn.algolia.com/?query=windows%20notepad&sort=byDate&prefix=false&page=0&dateRange=all&type=story)

------
Someone1234
I 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
I use this: [https://winaero.com/blog/get-calculator-from-
windows-8-and-w...](https://winaero.com/blog/get-calculator-from-
windows-8-and-windows-7-in-windows-10/)

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
Very 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!

------
valleyjo
I 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
This calculator is not written using Win32.

(Why the downvotes?)

~~~
mwfunk
I 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.

~~~
dblohm7
One of my pet peeves when engaging in technical discussions!

------
cbsks
The "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+...](https://github.com/Microsoft/calculator/issues?q=is%3Aissue+is%3Aopen+label%3A%22help+wanted%22)

~~~
WorldMaker
It'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...](https://help.github.com/en/articles/helping-new-contributors-
find-your-project-with-labels)

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.)

------
nevster
Can 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
All 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.

------
nimbius
speaking 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/annou...](https://blogs.windows.com/windowsexperience/2018/04/04/announcing-
windows-10-insider-preview-build-17639-for-skip-ahead/)

~~~
orbital-decay
This 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.

~~~
copperx
I know it's totally overkill, but I use Mathematica for even simple arithmetic
computations. I assume that the developers have ironed most of the obvious
bugs.

~~~
pkaye
I think Mathematica uses the GNU multiple precision arithmetic (gmp) library
itself in many cases.

------
Titanous
In case anyone is wondering what telemetry is collected:
[https://github.com/Microsoft/calculator/blob/master/src/Calc...](https://github.com/Microsoft/calculator/blob/master/src/CalcViewModel/Common/TraceLogger.cpp)

------
ocdtrekkie
Awesome 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
This is their whole plan. They are testing the waters with this. Soon all of
Windows will be open source.

~~~
ilovwindows
And we still have to pay for it

~~~
thunderbong
What does that have to do with anything?

------
diminish
MS 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?

~~~
dvtrn
"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"

~~~
hadrien01
You joke, but Paint actually has a very rudimentary support of transparency:
[https://www.wikihow.tech/Make-a-Background-Transparent-in-
Pa...](https://www.wikihow.tech/Make-a-Background-Transparent-in-Paint)

~~~
dvtrn
I wouldn't even call that 'rudimentary' transparency support, since you're
still relying on a background color to select an area of your image.

What I'm talking about is actual RGB _alpha channel_ support

[https://en.wikipedia.org/wiki/RGBA_color_space](https://en.wikipedia.org/wiki/RGBA_color_space)

But what you have here is still a neat function of MSPaint.exe

------
nathell
Whoa, it appears to be written in C++/CLI. I wonder how much Windows code also
is, and how it impacts maintainability.

~~~
favorited
I 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
It'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)

------
jacobparker
The history is truncated on GitHub. (first real commit is
[https://github.com/Microsoft/calculator/commit/c13b8a099eea1...](https://github.com/Microsoft/calculator/commit/c13b8a099eea11d5d6777de7562d350352b909d2)
) 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.

------
nly
Kinda shocking how large the codebase is for such a simple app

~~~
Someone1234
That's enterprise development for you. 49% boilerplate, 49% tests, and 2%
actual code.

------
edward
They accepted my pull request:

[https://github.com/Microsoft/calculator/pull/106](https://github.com/Microsoft/calculator/pull/106)

------
Tade0
Nice 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
I think that function has been bound to y for decades by now. No reason to
change muscle memory, even when rewriting the UI.

------
fetbaffe
How many threads for a calculator? My Task Manager says 20.

------
faissaloo
This is going to be great for ReactOS, they're even open sourcing more of
their UI components.

------
slimscsi
Now if the would open solitaire, that would be huge.

------
mihaitodor
I can’t believe the core of it is still some C code from ’95 called “Ratpack”:
[https://github.com/Microsoft/calculator/tree/master/src/Calc...](https://github.com/Microsoft/calculator/tree/master/src/CalcManager/Ratpack)
over which they added a whole bunch of enterprise fluff.

~~~
acqq
> 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.

------
jchw
This 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
Technically that already happened: [https://torrentfreak.com/microsoft-takes-
pirated-windows-nt-...](https://torrentfreak.com/microsoft-takes-pirated-
windows-nt-4-0-source-code-offline-150415/)

~~~
jchw
The 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.

------
chungy
Is this the version with floating point precision errors?

------
tee5r333
My favorite calculator was the PowerToy Calculator back in the Windows XP
days.

Does anyone have a suggestion for a replace on Windows 10?

------
shakehar
Finally I can have it run in a size that does not take up 3/4th of my screen
by default.

------
kerng
Is this for the old school cool calc.exe or the new Calculator Windows 10 app?

------
1337shadow
I hope cmd.exe is next so that we can learn how to build terminals the ms way

------
platz
I see xaml there, does that mean this is WPF even though it's c++ ?

~~~
Const-me
That'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
Well, 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
The 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
thanks

------
anonlastname
This is the most trivial program on the entire OS. Hooray for Microsoft, I
guess.

~~~
nathell
Most trivial? Not by a long shot. What about WINVER?

~~~
gpm
Not 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
Is true a program? I thought it was a command built into the shell.

~~~
robin_reala
It’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...](https://github.com/openbsd/src/blob/master/usr.bin/true/true.c)
.

~~~
radgeRayden
I don't know what I expected.

------
ggambetta
While 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.

~~~
kilo_bravo_3
I 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
In 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)

------
ilovwindows
So they are gonna open source everything so that the community can contribute
to it and still charge us for using it. Cleaver move Microsoft

