News for hackers. Stuff that matters.
Re:Rust/WinRT Public Preview by xrd on Thursday April 30, 2020 @02:45PM (#23034525)
I stopped reading at "The Windows Runtime is based on Component Object Model (COM) APIs..."

Is that a bad choice on my part?

I see COM and think of OLE, CORBA and I remember that I'm old and going to die pretty soon (within the next 40-50 years almost assuredly).

https://en.wikipedia.org/wiki/Component_Object_Model

Re:Rust/WinRT Public Preview by pjmlp on Thursday April 30, 2020 @03:24PM (#23035006)
Yes it is.

After the whole political disaster that was Longhorn, the Windows team decided to rebuilt Longhorn ideas, originally based on .NET, and redo them with COM.

So while many outside Windows have considered COM dead, actually since Vista all major Windows APIs have been provided as COM interfaces, the large majority of Win32 surface has been frozen since Windows XP.

With WinRT/UA/UAP/UWP they have gone back to the roots, while pursuing this idea one level up.

Basically they replaced COM type libraries with .NET Metadata, added support for generics, structured data types and implementation inheritance, bringing it to what .NET would have been like if they did not decided to copy Java.

So while the implementation of this reboot has been somewhat clusmy, COM is not going anywhere on Windows.

Also, this isn't a Windows only thing, Linux has gathered around DCOP, Android has AIDL, Fuchsia FIDL, macOS/iOS has XPC, then there is gRPC and plenty of other variants.

Re:Rust/WinRT Public Preview by amaranth on Thursday April 30, 2020 @06:28PM (#23036974)
I think the most similar thing to WinRT on Linux would be GObject Introspection since the main point appears to be a way to somewhat automatically surface the platform API in multiple languages using language-specific idioms. D-Bus is instead for RPC and events, which I guess COM also gets used for?
Re:Rust/WinRT Public Preview by pjmlp on Friday May 01, 2020 @01:45AM (#23039439)
I guess you are kind of right, then it would be a mix of GObject, KParts and D-BUS then.

As for COM, yes there are multiple models, in-process, external process and across the network (with DCOM).

GObject and KParts would be the in-process variant, with D-BUS for the other execution models.

Re:Rust/WinRT Public Preview by codys on Thursday April 30, 2020 @03:40PM (#23035192)
For linux I believe you mean D-Bus instead of DCOP. (that said, it's largely similar in concept)
Re:Rust/WinRT Public Preview by pjmlp on Thursday April 30, 2020 @05:09PM (#23036158)
You are right, that was the old protocol.
Re:Rust/WinRT Public Preview by KeBugCheckEx on Thursday April 30, 2020 @04:50PM (#23035951)
Historical note: first versions of .NET were called "COM+ 3.0".
Re:Rust/WinRT Public Preview by lukeh on Friday May 01, 2020 @08:46AM (#23041433)
Well, even before XPC there was Distributed Objects. In the mid-90s NeXT had a bridge between COM and DO called D'OLE, which remoted COM before Microsoft did. Of course, that didn't really take off, but it was a great example of how flexible a dynamic runtime can be. (They also had a lot of very smart developers.)
Re:Rust/WinRT Public Preview by sleepinseattle on Thursday April 30, 2020 @02:47PM (#23034559)
It’s not that different from things like Protocol Buffers, and for application code it’s mostly a hidden implementation detail. The API you’re calling (like the Composition API’s in the Minesweeper example) might be calling into a separate process but you don’t have to care.

Disclosure: I work on the Windows team

Re:Rust/WinRT Public Preview by hota_mazi on Thursday April 30, 2020 @03:13PM (#23034887)
COM is a fantastic invention and implementation.

Granted, it was pretty painful in C and somewhat in C++, but all the other languages (VB and C# mostly, but plenty of others) really unlock the power of COM.

Nothing like that remotely exists on Linux or macOS.

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.
Re:Rust/WinRT Public Preview by tonyedgecombe on Thursday April 30, 2020 @04:18PM (#23035588)
Nothing like that remotely exists on Linux or macOS.

https://developer.apple.com/library/archive/documentation/Co...

Re:Rust/WinRT Public Preview by hota_mazi on Thursday April 30, 2020 @04:49PM (#23035941)
There have been plenty of attempts to emulate what COM does.

All operating systems have some sort of object model and sharing API's, but neither macOS nor Linux have anywhere near the thriving ecosystem and actual cooperation model between applications that Windows has.

Re:Rust/WinRT Public Preview by winter_blue on Thursday April 30, 2020 @04:54PM (#23035993)
Yea, this is so true. It would be amazing if some standard similar to COM could unify the Linux community.
Re:Rust/WinRT Public Preview by snuxoll on Thursday April 30, 2020 @06:04PM (#23036740)
GObject gets us some of the way, but the ABI and bindings for other languages make it a royal pain in the ass to export types from anything but C rather than just consuming them.

Rather unfortunate, because with GIR you could easily have a program written in a mix of Rust, C, Go, C++, Vala, etc. all playing nicely if they were all able to expose to the common object model.

Re:Rust/WinRT Public Preview by lukeh on Friday May 01, 2020 @08:51AM (#23041466)
The COM support in CoreFoundation (such as it is) is... unusual. I have actually used it but it doesn't give you much from memory, beyond a way to locate plugins by UUID and the IUnknown ABI layout.
Re:Rust/WinRT Public Preview by dralley on Thursday April 30, 2020 @03:57PM (#23035370)
GObject is somewhat similar but it's nowhere close to first-class (being a Gtk specific tech)
Re:Rust/WinRT Public Preview by winter_blue on Thursday April 30, 2020 @04:55PM (#23036010)
COM brings back a lot of fantastic old memories.

When I was a kid, I used to make VB6 applications, and I'd be able to get custom widgets from the Internet, and import them into my VB6 project seamlessly. It was truly amazing, and mind-expanding.

The JS/React/etc web ecosystem doesn't come anywhere close, in terms of the ease-of-use that VB6 had.

Re:Rust/WinRT Public Preview by blinkingled on Thursday April 30, 2020 @02:50PM (#23034595)
Trouble is you can't really the solve the problem Microsoft had without using something like COM. Good news is you don't have to care - you can use C# or Rust and not worry about COM.
Re:Rust/WinRT Public Preview by pjmlp on Thursday April 30, 2020 @03:26PM (#23035039)
Somehow I think .NET would have been much better had it started as something like .NET Native, but yeah cannot turn back in time.
Re:Rust/WinRT Public Preview by barrkel on Thursday April 30, 2020 @05:04PM (#23036109)
It would have been no good for web application servers, which is where the competition was going.

Native would have chased the declining native GUI market.

Re:Rust/WinRT Public Preview by pjmlp on Thursday April 30, 2020 @05:08PM (#23036148)
Sure it would, after all that is where backend development is going to, back to AOT compilation toolchains.

If Delphi never managed much on the server side, it has more to do with the downfall from Borland than anything else.

So ASP + COM would be ASP.NET with COM+ Runtime instead.

Re:Rust/WinRT Public Preview by barrkel on Friday May 01, 2020 @08:04PM (#23047762)
I just don't buy it. Delphi could have done better, but not good enough. I think on its best day it would have had a hard time time competing with Java, much less Python or Ruby, and Rails was on the up as Delphi's .NET strategy was on the wane.

It needed to be an open source cross-platform compiler to be truly viable in the Linux ecosystem, and Linux would be needed to compete with Windows and its licensing fees. Anything other than C# is always a step or two behind on .NET, and .NET was the best route to web apps on Windows.

The only reason AOT is coming back for web apps is FaaS, IMO. FaaS works best with minimal boot-up latency, and FaaS delivers operationally as a way to scale out stateless compute on demand, which optimally means acquiring those compute resources just for the duration of a request or job, and no longer.

Re:Rust/WinRT Public Preview by oaiey on Thursday April 30, 2020 @02:56PM (#23034665)
Windows UI and Framework beyond Win32 is solidly based on COM. Win 10 works for many years now with a deployment close to a billion. I would say: works.
Re:Rust/WinRT Public Preview by alxmdev on Thursday April 30, 2020 @02:56PM (#23034670)
"Under the hood" makes it sound like you wouldn't deal with any COM stuff yourself, it's just how the different languages' APIs were implemented to interface with the OS runtime.
Re:Rust/WinRT Public Preview by discreteevent on Thursday April 30, 2020 @05:52PM (#23036598)
I don't think the basic architecture is going to go away. Even some of the newest operating systems have something quite similar:

https://fuchsia.googlesource.com/docs/+/ea2fce2874556205204d...

Re:Rust/WinRT Public Preview by Koshkin on Thursday April 30, 2020 @04:58PM (#23036032)
That's what they called "going native" (vs. using .NET).