News

Uno Platform Ports Open Source Windows Calculator (C++) to Web/iOS/Android (C#)

While porting a calculator to a different platform might seem simple -- how hard can it be to convert code for addition/subtraction/multiplication/division? -- the reality is far different.

Developers at UNO Platform detailed just how complicated a calculator can be, having just open sourced the Uno Calculator, a port of the previously open sourced Windows Calculator, which now runs on the Web via WebAssembly and natively on iOS and Android.

Uno Platform describes itself as "a framework trying to improve the development cycle of cross-platform apps using Windows, iOS, Android and WebAssembly using Mono and Xamarin."

Those skills were put to the test as the team worked to port Windows Calculator -- featuring a ton of C++ code and backed by a calculation engine dating back to 1995, with C code origins -- to C# code and the Uno Platform. So it now runs on the Web via WebAssembly -- the preview technology backing Microsoft's red-hot Blazor project -- and natively on iOS and Android mobile platforms.

Uno Calculator
[Click on image for larger view.] Uno Calculator (source: Uno Platform).

Enabling the same C# and XAML code to run on Web, mobile and desktop is "what we do," the team said in a June 25 blog post titled "A piece of Windows 10 is now running on WebAssembly, natively on iOS and Android."

"The Windows Calculator is an interesting and not-so-simple piece of software," said the post authored by Jérôme Laban, CTO of Uno Platform. "The simple initial UI you see upon launch can be deceiving. Of course, that is a good UX choice Microsoft made as most uses of the calculator are rather simple ones. However, the calculator is complex both in the way it was coded over the years, as well as the advanced functions it has."

Besides all that C++ code and its ancient origins, the calculator also sports advanced functionality such as support for scientific and programmer modes and much more complicated capabilities.

"The Uno Platform being developed in C#, to be able to support the Calculator on iOS, Android and WebAssembly, some parts of the code needed to be translated to C#," Laban said. "Others needed to be adjusted to be compliant with clang's C++ 11 support."

That resulted in numerous complicated challenges that needed to be overcome, detailed in the blog post and summarized thusly:

  • Porting the Engine to the Uno Platform:
    • Adjusting the C++ of the Calculation Engine
    • Native Code Interop Specifics
    • Converting the C++/CX code to C#
    • Converting the XAML
    • Localization Resources
  • Connecting the C++ and C# Together:
    • Mono for WebAssembly Dynamic and Static Linking Support
    • The C adaptation layer
    • The case of C++ to C# callbacks
    • String Marshalling
    • Adding features to Uno Platform

"The porting of the Calculator is a very interesting project to work on, and also makes for a very good calculator to use on all platforms," Laban concluded. "You can try building it yourself by heading over to the GitHub repo."

About the Author

David Ramel is an editor and writer at Converge 360.

comments powered by Disqus

Featured

  • Compare New GitHub Copilot Free Plan for Visual Studio/VS Code to Paid Plans

    The free plan restricts the number of completions, chat requests and access to AI models, being suitable for occasional users and small projects.

  • Diving Deep into .NET MAUI

    Ever since someone figured out that fiddling bits results in source code, developers have sought one codebase for all types of apps on all platforms, with Microsoft's latest attempt to further that effort being .NET MAUI.

  • Copilot AI Boosts Abound in New VS Code v1.96

    Microsoft improved on its new "Copilot Edit" functionality in the latest release of Visual Studio Code, v1.96, its open-source based code editor that has become the most popular in the world according to many surveys.

  • AdaBoost Regression Using C#

    Dr. James McCaffrey from Microsoft Research presents a complete end-to-end demonstration of the AdaBoost.R2 algorithm for regression problems (where the goal is to predict a single numeric value). The implementation follows the original source research paper closely, so you can use it as a guide for customization for specific scenarios.

  • Versioning and Documenting ASP.NET Core Services

    Building an API with ASP.NET Core is only half the job. If your API is going to live more than one release cycle, you're going to need to version it. If you have other people building clients for it, you're going to need to document it.

Subscribe on YouTube