News for hackers. Stuff that matters.
Re:Rust/WinRT Public Preview by recursive on Thursday April 30, 2020 @03:21PM (#23034963)
My only experience with COM (that I know of) was trying to do MS Office automation from C# >10 years ago.

I recall that it was very awkward, and somehow prone to memory leaks, and unclosed resources. To this day, I still don't really understand what COM is, or is supposed to be. But I still have a negative visceral reaction.

Re:Rust/WinRT Public Preview by magicalhippo on Thursday April 30, 2020 @10:07PM (#23038440)
> To this day, I still don't really understand what COM is

Maybe some excerpts from the documentation[1]:

"COM specifies an object model and programming requirements that enable COM objects (also called COM components, or sometimes simply objects) to interact with other objects. These objects can be within a single process, in other processes, and can even be on remote computers. They can be written in different languages, and they may be structurally quite dissimilar, which is why COM is referred to as a binary standard; a standard that applies after a program has been translated to binary machine code."

"The only language requirement for COM is that code is generated in a language that can create structures of pointers and, either explicitly or implicitly, call functions through pointers."

"Besides specifying the basic binary object standard, COM defines certain basic interfaces that provide functions common to all COM-based technologies, and it provides a small number of functions that all components require."

[1]: https://docs.microsoft.com/en-us/windows/win32/com/the-compo...

Re:Rust/WinRT Public Preview by Ididntdothis on Thursday April 30, 2020 @03:37PM (#23035158)
there is a big difference between out of process COM (like Office Automation) and in process COM (like WinRT and UWP or DirectX). Out of process was always a little tricky and not implemented well. DCOM was even worse. In process COM works really well.

Edit: I should add that C# isn’t the best language for COM because it doesn’t release objects when they go out of scope so you either have to release everything manually or wait for the GC to kick in which can cause memory problems. VB and C++ and even PHP are better that way.

Re:Rust/WinRT Public Preview by pjmlp on Friday May 01, 2020 @01:46AM (#23039445)
That was kind of sorted out with the COM improvements in .NET 4.0 and SafeHandles.
Re:Rust/WinRT Public Preview by Ididntdothis on Friday May 01, 2020 @10:23AM (#23042245)
Can you give more detail?
Re:Rust/WinRT Public Preview by jfkebwjsbx on Thursday April 30, 2020 @05:58PM (#23036678)
What is the point of "In process COM"? Is the same as any other library?

I thought COM was meant to communicate between processes?

Any enlightenment is appreciated...

Re:Rust/WinRT Public Preview by snuxoll on Thursday April 30, 2020 @06:08PM (#23036794)
COM is primarily used in-process, it exposes an ABI that allows multiple languages to operate on a common object model within the same process. That's why you can import COM controls into a .Net application by referencing the DLL in your project and work with them as if they were native CLR objects - or Python, Ruby, Perl, etc. for that matter.
Re:Rust/WinRT Public Preview by jdub on Friday May 01, 2020 @01:20AM (#23039345)
It lets you use libraries written in numerous supported languages with a richer, more object oriented interface than a C ABI. You can use the same underlying interface to call out of process or distributed objects.
Re:Rust/WinRT Public Preview by Ididntdothis on Thursday April 30, 2020 @06:25PM (#23036947)
COM is Common Object Model. What you mean is OLE. In process COM calls are basically direct DLL calls and therefore very fast.
Re:Rust/WinRT Public Preview by mycall on Thursday April 30, 2020 @10:30PM (#23038536)
Is these problems fixed with AOT C# (CoreRT)?
Re:Rust/WinRT Public Preview by rk06 on Friday May 01, 2020 @01:45AM (#23039438)
Unlikely, as those problems are coming because of Garbage Collection which is a core part of language. C++/Rust don't have GC, so they don't have those problems
Re:Rust/WinRT Public Preview by asveikau on Thursday April 30, 2020 @07:05PM (#23037300)
The bit about memory leaks is probably a comment on the effectiveness of the .net GC more than anything else. COM objects are reference counted. When the .net runtime GCs a wrapped COM object it bumps the count down. My experience from years ago is that can take a long time or not happen at all. There is a manual call that releases the object, after which it is no longer usable from .net.