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

  • Hands On: New VS Code Insiders Build Creates Web Page from Image in Seconds

    New Vision support with GitHub Copilot in the latest Visual Studio Code Insiders build takes a user-supplied mockup image and creates a web page from it in seconds, handling all the HTML and CSS.

  • Naive Bayes Regression Using C#

    Dr. James McCaffrey from Microsoft Research presents a complete end-to-end demonstration of the naive Bayes regression technique, where the goal is to predict a single numeric value. Compared to other machine learning regression techniques, naive Bayes regression is usually less accurate, but is simple, easy to implement and customize, works on both large and small datasets, is highly interpretable, and doesn't require tuning any hyperparameters.

  • VS Code Copilot Previews New GPT-4o AI Code Completion Model

    The 4o upgrade includes additional training on more than 275,000 high-quality public repositories in over 30 popular programming languages, said Microsoft-owned GitHub, which created the original "AI pair programmer" years ago.

  • Microsoft's Rust Embrace Continues with Azure SDK Beta

    "Rust's strong type system and ownership model help prevent common programming errors such as null pointer dereferencing and buffer overflows, leading to more secure and stable code."

  • Xcode IDE from Microsoft Archrival Apple Gets Copilot AI

    Just after expanding the reach of its Copilot AI coding assistant to the open-source Eclipse IDE, Microsoft showcased how it's going even further, providing details about a preview version for the Xcode IDE from archrival Apple.

Subscribe on YouTube

Upcoming Training Events