对于 Windows 应用程序来说,C# 相对于 Delphi/realbasic 的优势是什么
有没有人编写过比 .NET 包更大的应用程序? 人们过去常常批评 VB6 的 2 MB 运行时间,但它很少使其附带的应用程序相形见绌。
今天,尽管我的机器上安装了 Vista,但我还是必须下载 35 MB 的 3.5 框架并重新启动才能尝试一半大小的应用程序。
当您考虑到源代码安全性下降的因素时,我想知道为什么有人会用 .NET 开发 Windows 应用程序,而不是使用允许构建本机可执行文件的语言。
在编写在 Windows 上运行的应用程序时,.NET 的哪些优点可以掩盖这些缺点?
Has anyone ever written an application bigger than its .NET luggage?
People used to criticize VB6 for its 2 MB runtime but it rarely dwarfed the app it accompanied.
Today despite having Vista on my machine I had to download 35 MB of the 3.5 framework and reboot to then try out an app half that size.
When you factor in the decreased source code security I wonder why anyone would anyone develop a windows application in .NET rather than in a language that allowed for the building of native executables.
What is superior about .NET that outshadows these drawbacks when it comes to writing applications to run on Windows?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(10)
人物:请注意,这是2009年2月写的,所说的话当时是合适的——在2012年底(3年多后)对我大喊大叫是无意义的。 :-)
Delphi 对于 Win32 有一些相当大的优势。 并不是说 .NET 应用程序本身就不好,而是尝试:
.NET 中的垃圾收集可能非常好,但是任何了解编程的人都可以使用 Delphi 轻松处理内存的手动分配/释放,并且 GC 可以通过引用计数接口使用。 VB 的伪 GC 不正是让所有非程序员大量涌现的原因之一吗? 在我看来,GC 是让 .NET 变得危险的原因之一,就像 VB 很危险一样——它让事情变得太简单,让那些真正不知道自己在做什么的人编写出最终会变得一团糟的软件。 (而且,在我在这里被火烧死之前,这对于那些确实知道自己在做什么的人来说非常棒,VB 也是如此;我只是不太确定这样做的优势熟练的人比不熟练的人对我们造成的危害更大)
Delphi Prism(又名 Rem Objects Oxygene,以前的 Chrome)提供了那些需要它的人正在寻找的 Delphi 的 GC 版本,以及 ASP.NET 和 WPF/Silverlight/CE,具有 Delphi 的可读性(并且没有花括号)。 对于那些(像我一样)Unicode 支持不是主要因素的人来说,Delphi 2007 提供了 ASP.NET 和 VCL.NET,以及本机 Win32 支持。 而且,在像我工作的地方,工作站(至少)每三年才升级一次,并且我们刚刚摆脱了最后一台 Win95 机器,因为它不是升级的优先事项,.NET 框架是一个问题。 (特别是公司代理要求只允许少数人访问互联网,限制带宽和下载能力,以及不允许使用 USB 设备的适当的非管理员帐户,所有这些仍然通过 Netware 网络运行 - 没有 Windows 更新之类的东西,并且到目前为止还没有病毒,因为没有任何东西进入。)
我使用 .NET 语言(C#、Delphi Prism)进行一些工作,但全职和副业的主要工作来自 Win32 和 Delphi。
PEOPLE: Please note that this was written in February, 2009, and what is said was appropriate at that time - yelling at me in late 2012 (3+ years later) is meaningless. :-)
Delphi has some considerable advantages for Win32. Not that .NET apps are inherently bad, but try:
Garbage collection in .NET might be really nice, but anyone who knows anything about programming can also handle manual allocation/deallocation of memory easily with Delphi, and GC is available with reference-counted interfaces. Isn't one of the things that brought all of the non-programmers to proliferation the pseudo-GC of VB? IMO, GC is one of the things that makes .NET dangerous, in the same way VB was dangerous - it makes things too easy and allows people who really have no clue what they're doing to write software that ends up making a mess. (And, before I get flamed to death here, it's great for the people who do know what they're doing as well, and so was VB; I'm just not so sure that the advantage to the skilled outweights the hazards to us from the unskilled. )
Delphi Prism (AKA Rem Objects Oxygene, formerly Chrome) provides the GC version of Delphi that those who need it are looking for, along with ASP.NET and WPF/Silverlight/CE, with the readability (and lack of curly braces) of Delphi. For those (like me) for which Unicode support isn't a major factor, Delphi 2007 provides ASP.NET and VCL.NET, as well as native Win32 support. And, at a place like where I work, when workstations are only upgraded (at a minimum) every three years, and where we just got rid of the last Win95 machine because it wasn't a priority to upgrade, the .NET framework is an issue. (Especially with company proxy requirements only allowing Internet access to a handful of people, limiting bandwidth and download capabilities, and proper non-admin accounts with no USB devices allowed, all still running across a Netware network - no such thing as Windows Update, and never a virus so far because nothing gets in.)
I work some in .NET languages (C#, Delphi Prism), but the bread and butter both full-time and on the side, comes from Win32 and Delphi.
好吧,我怀疑这会说服您,因为您不想被说服,但这是我对 .NET 相对于旧技术优势的看法。 我不会声称每个优点都适用于您在问题中提到的每种语言,或者 .NET 是完美的,但是:
托管环境可以更早地捕获常见错误并提供新的机会:
现代面向对象的框架:
一个针对多种语言的框架:
大部分内容的结果 - 以及我想的原话 - 是 .NET 允许更快地开发更强大的应用程序。
为了解决您在问题中提到的两个具体问题:
Okay, I doubt this will persuade you as you don't want to be persuaded, but here's my view of the advantages of .NET over older technologies. I'm not going to claim that every advantage applies to every language you mentioned in the question, or that .NET is perfect, but:
A managed environment catches common errors earlier and gives new opportunities:
A modern object-oriented framework:
One framework targeted by multiple languages:
The upshot of most of this - and the soundbite, I guess - is that .NET allows faster development of more robust applications.
To address the two specific issues you mentioned in the question:
仅举几例:
To name a few:
首先,没有一种语言/平台是普遍优越的。
较旧的语言将拥有可用的现有代码库,这既是积极的(经验、经过充分测试、广泛的支持文献),也是消极的(由此产生的反对变革的惯性、多种不同的做事方式导致新进入者的困惑)。
与大多数事情一样,语言和平台的选择/使用是利弊的平衡。
在下面的列表中,Delphi 具有一些相同的优点和缺点,但也有许多不同之处。
潜在 .Net 的缺点(如果它们对您来说不是问题,那么它们就不是缺点)
还有更多,但这些是亮点。
潜在优点(同样,如果它们对你来说不重要)
同样专门针对 c#
缺点:
优点:
C 基础确实有利有弊。 它可以被大量程序员理解(与基于 pascal 的风格相比),但有一定的缺陷(switch 语句就是一个明显的例子)。
强/弱/静态/动态类型系统是一个两极分化的争论,但毫无疑问,如果类型系统受到更多限制,它应该努力不要求过多的冗长,c# 在这方面肯定比许多系统更好。看待。
对于许多内部业务线应用程序来说,.Net 平台的大量缺点绝对无关紧要(受控部署是公司内部常见且已得到很好解决的问题)。
因此,使用 .Net(这在很大程度上意味着 c#,对不起,VB.Net 的家伙)对于 Windows 架构中的新开发来说是一个非常明显的选择。
OK first up, No one language/platform is ever going to be universally superior.
Older languages will have existing code bases that work, this is both positive (experience, well tested, extensive supporting literature) but also a negative (the resulting inertia against change, multiple different ways to do things leading to confusion for new entrants).
The selection/use of both languages and platforms is, as are most things, a balancing of the pros and cons.
In the following lists Delphi has some of the same pros and cons, but differs on many too.
Potential Negatives of .Net (if they are not an issue to you they aren't negatives)
There are more but these are the highlights.
Potential Positives (again if they don't matter to you)
Likewise specifically for c#
Con:
Pro:
The C underpinnings really is a pro and con. It is understandable by a vast number of programmers (compared to pascal based style) but has a certain amount of cruft (switch statements being a clear example).
Strong/Weak/Static/Dynamic type systems are a polarising debate but it is certainly not contentious to say that, where the type system is more constraining it should strive to not require excessive verbosity as a result, c# is certainly better than many in that regard.
For many internal Line of Business applications a vast number of the .Net platform Cons are absolutely immaterial (controlled deployment being a common and well solved problem within corporations).
As such using .Net (and this does largely mean c#, sorry VB.Net guys) is a pretty obvious choice for new development within a windows architecture.
使用它开发复杂(和简单)应用程序的“简单性”。 许多基本的东西已经在框架中为您编码,您可以直接使用它。 现在下载 35mb 文件比 8-6 年前下载 2mb 文件容易得多。
The "simplicity" of developing complex(and simple) applications using it. A lot of basic stuff is already coded for you in the framework and you can just use it. And downloading 35mb file today is much easier than 2mb file 8-6 years ago.
原因有很多。 我对 RealBasic 了解不多,但就 Delphi 而言:
不如 .NET 广泛,开发社区较小。 网上的许多 Delphi 资源都是古老且过时的。
在 Delphi 2009 之前,Delphi 没有完整的 unicode 支持。
我不了解Delphi 2009,但2007年没有很好的垃圾收集。 它有某种笨重的引用计数,需要开发人员进行一些干预。 .NET 有一个更先进的 GC,几乎可以为您完成所有工作。
.NET 拥有更大的标准库和更多最新的第 3 方库。
像 C# 这样的 .NET 语言可以说更好,对于那些刚接触该语言的人来说当然更容易理解。
像 C# 这样的 .NET 语言可以说更好,并且
There are a lot of reasons. I don't know much about RealBasic, but as far as Delphi goes:
Less widespread than .NET, smaller development community. Many of the Delphi resources on the net are ancient and outdated.
Until Delphi 2009, Delphi didn't have full unicode support.
I don't know about Delphi 2009, but 2007 didn't have very good garbage collection. It had some sort of clunky reference counting that required some intervention on behalf of the developer. .NET has a much more advanced GC that does virtually everything for you.
.NET has a larger standard library and more up-to-date 3rd party libraries.
.NET languages like C# are arguably better, and certainly easier to understand for those new to the language.
.NET 开发人员在这里引用了许多所谓的优点,但这些优点不应该出现在这种比较中,因为 Delphi 也具有这些优点:
有然而,.NET 中的一些东西 Delphi 没有现成的,只有其中一些可以通过库和自己的代码添加。 仅举几例:
[1] 如果您不知道但如果有兴趣,请查看 Marc Clifton 的主页,尤其是有关声明式编程的文章。
编辑:我想回应 Mason Wheeler 的评论:
关于动态代码:我知道有一些解决方案可以将 Pascal 脚本嵌入到应用程序中。 然而,使部分内部对象层次结构可供脚本引擎使用与在运行时使用用于代码的相同编译器之间存在明显的区别。 Delphi编译器和脚本引擎的编译器之间总是存在差异。 不管怎样,.NET 所带来的一切远远超出了 Delphi 所提供的一切。 不管怎样,是否能够为 Delphi 编写类似的基础结构并不重要,重要的是,使用 .NET,当您需要它时,它已经为您提供了。
重新多播事件:确实,有一些方法可以对其进行编码,但它不是 Delphi/VCL 开箱即用的一部分。 这就是我上面所说的。
关于弱引用:您大错特错了。 尝试以不平凡的方式使用接口,并在此过程中创建循环引用。 然后你必须开始使用类型转换并希望弱引用。
There's a lot of supposed advantages cited by .NET developers here that shouldn't be in that comparison, simply because Delphi has them as well:
There are however some things in .NET that Delphi doesn't have out-of-the box, and only some of those can be added by libraries and own code. To name a few:
[1] If you don't know but are interested, check out the home page of Marc Clifton, especially the articles about declarative programming.
Edit: I'd like to respond to the comment by Mason Wheeler:
Re dynamic code: I know that there are solutions to have Pascal scripting embedded in the application. There is however a distinct difference between making parts of your internal object hierarchy available to the scripting engine, and having the same compiler that is used for your code available at runtime as well. There are always differences between the Delphi compiler and the compiler of the scripting engine. Anyway, what you get with .NET goes far beyond anything that is available for Delphi. And anyway, it's not the point whether one would be able to code similar infrastructure for Delphi, the point is that with .NET it's already there for you, when you need it.
Re Multicast events: Exactly, there's ways to code it, but it's not part of Delphi / the VCL out-of-the-box. That's what I was saying above.
Re weak references: You are sadly mistaken. Try to use interfaces in a non-trivial way, creating circular references on the way. Then you have to start to use typecasts and wish for weak references.
好吧,.NET Framework 是为所有 .NET 应用程序共享的,因此您的计算机上只拥有一次它,而 35MB 如今根本不算什么(与 Vista 安装的大小相比)。 对于您的第二个 .NET 应用程序,您无需再次下载。
Well, the .NET Framework is shared for all .NET applications, so you have it only once on your machine and 35MB are nothing today (compare it to the size of your Vista installation). For your second .NET application you don't have to download it again.
对于 Windows 应用程序,.NET(使用 C# 或其他语言)可让您更直接地访问最新、最强大的 Windows 功能。 它也得到了 Microsoft 的大力支持,拥有庞大的社区和大量有关它的书籍。
REALbasic(现为 Xojo)适用于跨平台应用程序。 仅在 Windows 上使用它有时可能很有用,但这并不是它的优势(即它非常易于使用)。
我对德尔福了解不多。
For Windows app, .NET (using C# or whatever) gives you more direct access to the latest and greatest Windows features. It's also very well supported by Microsoft, has a huge community and lots of books written about it.
REALbasic (now Xojo) is for cross-platform apps. Using it just on Windows can sometimes be useful, but that would not be its strength (which is that it's amazingly easy to use).
I don't know much about Delphi.
据我所知,RealBASIC 在对象关系工具方面没有太多(如果有的话),并且对于 n 层、以数据库为中心的应用程序来说可能不是一个好的选择。
From what I can see RealBASIC doesn't have much (if anything) in the way of Object Relational tools and probably wouldn't be as good a choice for n-tier, database-centric applications.