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

  • Mastering Blazor Authentication and Authorization

    At the Visual Studio Live! @ Microsoft HQ developer conference set for August, Rockford Lhotka will explain the ins and outs of authentication across Blazor Server, WebAssembly, and .NET MAUI Hybrid apps, and show how to use identity and claims to customize application behavior through fine-grained authorization.

  • Linear Support Vector Regression from Scratch Using C# with Evolutionary Training

    Dr. James McCaffrey from Microsoft Research presents a complete end-to-end demonstration of the linear support vector regression (linear SVR) technique, where the goal is to predict a single numeric value. A linear SVR model uses an unusual error/loss function and cannot be trained using standard simple techniques, and so evolutionary optimization training is used.

  • Low-Code Report Says AI Will Enhance, Not Replace DIY Dev Tools

    Along with replacing software developers and possibly killing humanity, advanced AI is seen by many as a death knell for the do-it-yourself, low-code/no-code tooling industry, but a new report belies that notion.

  • Vibe Coding with Latest Visual Studio Preview

    Microsoft's latest Visual Studio preview facilitates "vibe coding," where developers mainly use GitHub Copilot AI to do all the programming in accordance with spoken or typed instructions.

  • Steve Sanderson Previews AI App Dev: Small Models, Agents and a Blazor Voice Assistant

    Blazor creator Steve Sanderson presented a keynote at the recent NDC London 2025 conference where he previewed the future of .NET application development with smaller AI models and autonomous agents, along with showcasing a new Blazor voice assistant project demonstrating cutting-edge functionality.

Subscribe on YouTube