简体   繁体   English

用C / C ++学习COM能帮助我更好地理解.NET吗?

[英]Would learning COM with C/C++ help me understand .NET better?

Often when learning about .NET I run into things that hail from the COM world, or C/C++ (handles, gdi, interop, STA/MTA, etc., the list goes on!). 通常在学习.NET时,我会遇到来自COM世界或C / C ++(句柄,gdi,interop,STA / MTA等)的事情,这个列表还在继续!)。

Would it be worth my time to go learn how to program in COM with C or C++, thus killing two birds with one stone? 我是否值得花时间学习如何使用C或C ++编写COM程序,从而一举两得?

Would this deepen my knowledge of developing with .NET? 这会加深我对使用.NET开发的知识吗? I am tired of the "This HAPPENS BY MAGIC" feeling! 我厌倦了“这种发生魔法”的感觉!

Instead of diving into this, read Don Box's tomes on the .NET framework and why things work the way they do inside .NET. 不要深入研究这个问题,而是阅读Don Box在.NET框架上的主题,以及为什么它们在.NET中的运行方式。 All magic will be relinquished after this book (though dated, it is still very relavent). 在这本书之后,所有的魔法都将被放弃(尽管过时了,它仍然非常相关)。

Learning COM will help you understand certain portions of .NET better, but they are mainly the portions that deal with COM interop. 学习COM将帮助您更好地理解.NET的某些部分,但它们主要是处理COM互操作的部分。 It will not help (much) for general .NET development overall, other than in certain scenarios. 除了在某些情况下,它对整体.NET开发总体上没有帮助。

That being said, if your primary goal is to learn and be focused in .NET, I would focus on learning some of the newer .NET technologies. 话虽如此,如果您的主要目标是学习并专注于.NET,我将专注于学习一些较新的.NET技术。 Between WCF, WPF, Silverlight, WF, EF, etc - there's no way one person can become a true expert at all of the .NET technologies already existing, let alone others. 在WCF,WPF,Silverlight,WF,EF等之间 - 一个人无法成为现有所有.NET技术的真正专家,更不用说其他人了。 Focusing on the main .NET based technologies that interest you may be a more productive use of your time. 专注于您感兴趣的主要基于.NET的技术可能会更有效地利用您的时间。

If you want to try to expand your knowledge in general, then COM may be worth learning - but I'd probably personally recommend learning a new language, especially one that uses a very different paradigm than your main .NET language. 如果你想尝试扩展你的知识,那么COM可能值得学习 - 但我个人可能会建议学习一门新语言,特别是那种使用与你的主要.NET语言截然不同的范例的语言。 For example, studying a functional programming language might really expand your view of programming and be a much better use of your time. 例如,学习函数式编程语言可能会真正扩展您对编程的看法,并且可以更好地利用您的时间。

My personal opinion...keep in mind this is just my opinion: 我的个人意见......请记住这只是我的意见:

I am glad that I learned .NET first. 我很高兴我先学习.NET。 I was not constrained to think about things like binary compatibility and activeX. 我并不局限于考虑二进制兼容性和activeX之类的东西。 These are legacy concepts that I have really only needed when dealing with older COM libraries. 这些是我在处理旧的COM库时真正需要的遗留概念。

I will admit that going back and learning COM was useful in certain aspects as you really should understand how compatibility works. 我承认,回过头来学习COM在某些方面很有用,因为你真的应该理解兼容性是如何工作的。 Though, my situation was a little different in that I learned about COM with vb6 which can be VERY different. 虽然,我的情况有点不同,因为我了解了与vb6的COM,这可能非常不同。

I would say learn .NET fairly well first, but go back and learn about MTA and multi-threading with C++. 我会说首先要学习.NET,但是回过头来学习MTA和C ++的多线程。 This still seems to be an area where many people have hesitated to say that .NET is better. 这似乎仍然是许多人对于.NET更好的犹豫不决的领域。

To add one last thought, I work with many legacy programmers that come form the COM world. 为了添加最后一个想法,我与许多来自COM世界的遗留程序员一起工作。 They get so stuck in that world that it prohibits them from moving on. 他们在这个世界中陷入困境,禁止他们继续前进。 If I see something like clsOrder one more time I may barf. 如果我再次看到像clsOrder这样的东西,我可能会呕吐。 Do yourself a favor and learn how to actually program in .NET. 帮自己一个忙,学习如何在.NET中实际编程。 Don't just program vb6/c/c++ in .NET. 不要只在.NET中编写vb6 / c / c ++。 It's a huge waste of time. 这是浪费大量时间。

学习任何东西都有助于你理解类似的概念,所以不确定。

它不会受到伤害,但是如果你不太了解C / C ++,尤其是指针和内存分配,你可能需要在直接跳转到与COM对象接口之前先了解它们。

"C/C++" suggests to me that you definitely don't know, well, anything about it. “C / C ++”告诉我,你肯定不知道,关于它的任何事情。 I would skip it if you just want to know about .NET, as they will likely come with relevant documentation that will explain how it works from the .NET side. 如果您只是想了解.NET,我会跳过它,因为它们可能会附带相关文档来解释它如何从.NET端运行。 However, if you want to learn more generally, or the kinds of things involved in the implementation details of .NET, like the magic that's involved in interop, then I'd definitely go for C++. 但是,如果你想更全面地学习,或者.NET的实现细节中涉及的事情类型,比如interop中涉及的魔法,那么我肯定会选择C ++。

I wouldn't learn c++/C for the com I would learn it because its a very different way of looking at how to structure problems and solutions. 我不会学习c ++ / C,因为它是一种非常不同的方式来研究如何构建问题和解决方案。 Any of the higher level languages do a lot by magic and the closer you go to the machine the less that happens. 任何更高级别的语言都会通过魔法做很多事情,你越接近机器就会越少。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM