会用 C/C 来学习 COM++帮助我更好地理解 .NET?
在学习 .NET 时,我常常会遇到来自 COM 世界或 C/C++ 的东西(句柄、gdi、互操作、STA/MTA 等,这样的例子不胜枚举!)。
我是否值得花时间去学习如何使用 C 或 C++ 在 COM 中进行编程,从而一石二鸟?
这会加深我对 .NET 开发的了解吗?我厌倦了“这一切都是由魔法发生”的感觉!
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!).
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?
Would this deepen my knowledge of developing with .NET? I am tired of the "This HAPPENS BY MAGIC" feeling!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(7)
学习 COM 将帮助您更好地理解 .NET 的某些部分,但它们主要是处理 COM 互操作的部分。除了某些场景之外,它对于一般的 .NET 开发整体来说没有太大帮助。
话虽这么说,如果您的主要目标是学习并专注于 .NET,我会专注于学习一些较新的 .NET 技术。在 WCF、WPF、Silverlight、WF、EF 等之间,一个人不可能成为所有现有 .NET 技术的真正专家,更不用说其他技术了。专注于您感兴趣的基于 .NET 的主要技术可能会更有效地利用您的时间。
如果您想尝试扩展您的一般知识,那么 COM 可能值得学习 - 但我个人可能会建议学习一门新语言,尤其是使用与您的主要 .NET 语言截然不同的范例的语言。例如,学习函数式编程语言可能会真正扩展您的编程视野,并更好地利用您的时间。
Learning COM will help you understand certain portions of .NET better, but they are mainly the portions that deal with COM interop. It will not help (much) for general .NET development overall, other than in certain scenarios.
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. 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. Focusing on the main .NET based technologies that interest you may be a more productive use of your time.
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. For example, studying a functional programming language might really expand your view of programming and be a much better use of your time.
不要深入研究这个问题,而是阅读 Don Box 的有关 .NET 框架的著作以及为什么事物以 .NET 内部的方式工作。在这本书之后,所有的魔法都将被放弃(尽管已经过时,但它仍然非常相关)。
Instead of diving into this, read Don Box's tomes on the .NET framework and why things work the way they do inside .NET. All magic will be relinquished after this book (though dated, it is still very relavent).
我的个人观点...请记住,这只是我的观点:
我很高兴我先学习了 .NET。我没有被限制去考虑诸如二进制兼容性和 activeX 之类的事情。这些是遗留概念,我实际上只在处理较旧的 COM 库时才需要这些概念。
我承认回过头来学习 COM 在某些方面是有用的,因为您确实应该了解兼容性是如何工作的。不过,我的情况有点不同,因为我是用 vb6 学习 COM 的,这可能非常不同。
我想说,首先要学好 .NET,然后再回去学习 MTA 和 C++ 的多线程。这似乎仍然是许多人犹豫是否说 .NET 更好的领域。
最后补充一点,我与许多来自 COM 世界的遗留程序员一起工作。他们被困在那个世界里,以至于无法继续前进。如果我再看到像 clsOrder 这样的东西,我可能会呕吐。帮自己一个忙,学习如何在 .NET 中实际编程。不要只在 .NET 中编写 vb6/c/c++ 程序。这是对时间的巨大浪费。
My personal opinion...keep in mind this is just my opinion:
I am glad that I learned .NET first. I was not constrained to think about things like binary compatibility and activeX. These are legacy concepts that I have really only needed when dealing with older COM libraries.
I will admit that going back and learning COM was useful in certain aspects as you really should understand how compatibility works. Though, my situation was a little different in that I learned about COM with vb6 which can be VERY different.
I would say learn .NET fairly well first, but go back and learn about MTA and multi-threading with C++. This still seems to be an area where many people have hesitated to say that .NET is better.
To add one last thought, I work with many legacy programmers that come form the COM world. 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. Do yourself a favor and learn how to actually program in .NET. Don't just program vb6/c/c++ in .NET. It's a huge waste of time.
学习任何东西都会帮助你理解类似的概念,所以为什么不呢?
Learning anything will help your understanding of similar concepts, so sure why not.
这不会有什么坏处,但如果您不太了解 C/C++,尤其是指针和内存分配,您可能需要在直接开始与 COM 对象交互之前温习一下这些内容。
It can't hurt, but if you don't know C/C++ very well, especially pointers and memory allocation, you may want to brush up on those before jumping straight in to interfacing with COM objects.
“C/C++”对我来说意味着你绝对不知道,嗯,关于它的任何事情。如果您只想了解 .NET,我会跳过它,因为它们可能会附带相关文档,从 .NET 方面解释它是如何工作的。但是,如果您想更广泛地学习,或者了解 .NET 实现细节中涉及的各种内容,例如互操作中涉及的魔法,那么我肯定会选择 C++。
"C/C++" suggests to me that you definitely don't know, well, anything about it. 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. 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++.
我不会为了com而学习c++/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. Any of the higher level languages do a lot by magic and the closer you go to the machine the less that happens.