Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Nice project, just as a challenge / piece of feedback - most of the time you don't actually need to have a C backend for this type of project. The challenge is to get all the P/Invoke signatures and struct declarations / pointer walking correct on .Net. The benefit being a single managed EXE and no need for cross process communication and the edge cases it brings.

(Source: Have built a full SCSI interop layer in .Net to do low level CD ripping, full with native pointer walking and all. Have also written tools to walk the PEB (process environment block) in .Net w/ no native backends.)



If you do have headers, you don't have to write the bindings by hand: https://github.com/dotnet/ClangSharp?tab=readme-ov-file#gene...

Also because this is Windows, there is https://github.com/microsoft/CsWin32 already (and adjacent libraries) which rely on the same generator.


Which is the reason that to this day I remain a big C++/CLI fan.

It is still much easier than dealing with P/Invoke and COM from .NET code.

Create a nice wrapper, exposing C# compatible types and we're done.

In regards to COM, not even the CCW/RCW replacement is as developer friendly as VB 6 or Delphi.

I have some hopes that Secure Future Initiative will finally give the spotlight to .NET on Windows, that Windows team keeps pushing away, unlike what happens on Apple and Google platforms.


What do you think about the tooling that @neonsunset mentioned: https://news.ycombinator.com/item?id=42286681


It helps, but when one has enough C++ knowledge, I still consider C++/CLI a better solution instead of yet another tool, that might not understand everything.

Now if doing cross platform code, C++/CLI is naturally not an option.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: