Welcome to the Lounge
For discussing anything related to a software developer's life but is not for programming questions. Got a programming question?
The Lounge is rated Safe For Work. If you're about to post something inappropriate for a shared office environment, then don't post it. No ads, no abuse, and no programming questions. Trolling, (political, climate, religious or whatever) will result in your account being removed.
|I've been repurposing a bunch of my old C# code for use as C++ code on microcontroller devices.
This is going far far better than I would have ever imagined.
For starters, C# under .NET is a garbage collected memory pig.
The environment this code gets ported to could not be more different. I have 320kB of usable RAM, no garbage collection, and an allergy to
And yet my JSON parser i built for it was originally written in C#. It will run comfortably on 4kB of RAM. The same code on .NET uses tens of megabytes or more.
And don't get me started on my latest endeavor - stealing Microsoft .NET's
SynchronizationContext paradigm for use on my ESP32 IoT devices.
Porting the code was cake, in both of the above cases. It was almost too easy.
It's shocking to me because the differences in environments and development paradigms are profound, but the code is almost copy-paste-search-replaceable in terms of porting it.
private struct Message
public SendOrPostCallback Callback;
public object State;
public ManualResetEventSlim FinishedEvent;
std::function<void(void *)> callback;
It's the same code!
Callback: C++ functor vs. C# singlecast delegate
State: C++ void* vs. C# object
Finished event: C++ TaskHandle_t based notification vs C# ManualResetEvent
It's incredible how similar it is for something so platform specific. And now that C++ has things like coroutines and awaitable methods it will be even easier to port .NET code to C++ going forward.
How did this happen? When did this happen? I'm thrilled!
Real programmers use butterflies
General News Suggestion Question Bug Answer Joke Praise Rant Admin
Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.