对于 Windows 应用程序来说,C# 相对于 Delphi/realbasic 的优势是什么

发布于 2024-07-13 11:29:42 字数 286 浏览 8 评论 0原文

有没有人编写过比 .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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(10

静若繁花 2024-07-20 11:29:43

人物:请注意,这是2009年2月写的,所说的话当时是合适的——在2012年底(3年多后)对我大喊大叫是无意义的。 :-)

Delphi 对于 Win32 有一些相当大的优势。 并不是说 .NET 应用程序本身就不好,而是尝试:

  • 在 Win95/ME 上运行 .NET 应用程序(任何版本),其中 .NET 不存在(AFAIK)
  • 分发任何小型(< 1.5 MB).NET 应用程序(是的) ,软盘驱动器仍然存在)
  • 在无法访问 Internet 的系统上提供任何 .NET 应用程序(是的,它们存在)
  • 在没有广泛高带宽的国家/地区分发您的 .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:

  • running a .NET app (any version) on Win95/ME, where .NET doesn't exist (AFAIK)
  • distributing any small ( < 1.5 MB) .NET app (yes, floppy drives still exist)
  • providing any .NET app on a system that has no Internet access (yes, they exist)
  • distributing your .NET apps in countries without widespread high bandwidth
  • keep people from seeing your source code without spending a ton of dough (Reflection, anyone?)

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.

妄司 2024-07-20 11:29:43

好吧,我怀疑这会说服您,因为您不想被说服,但这是我对 .NET 相对于旧技术优势的看法。 我不会声称每个优点都适用于您在问题中提到的每种语言,或者 .NET 是完美的,但是:

  • 托管环境可以更早地捕获常见错误并提供新的机会:

    • 强类型可以避免错误地将一种类型视为另一种类型
    • 垃圾收集在很大程度上消除了内存管理问题(我承认,并非完全如此)
    • “分段错误”通常翻译为“NullReferenceException” - 但更容易调试!
    • 不可能出现缓冲区溢出(当然,除了潜在的 CLR 错误之外) - 这立即消除了一个重大的安全问题
    • 声明式安全模型和精心设计的运行时允许代码在各种信任级别下运行
    • JITting 允许 CLR 充分利用在 64 位计算机上运行的优势,而无需重新编译(某些互操作情况除外)
    • JITter 还可以针对未来的处理器开发,无需开发人员进行任何工作即可进行改进(包括无需重建或分发多个版本)。
    • 反思可以实现在非托管环境中不可能或困难的各种事情
  • 现代面向对象的框架:

    • 具有执行时间知识的泛型(与 Java 中的类型擦除相反)
    • 合理的线程支持,以及 .NET 4.0 中出现的一组新原语(并行扩展)
    • 从一开始就支持国际化和 Unicode - 一方面只需考虑一种字符串类型:)
    • Windows 演示框架提供了现代 GUI 框架,允许声明式设计、良好的布局和动画支持等
    • 对与本机库互操作的良好支持(例如,P/Invoke 比 JNI 好得多)
    • 异常比错误代码提供更多信息(并且更容易处理)
    • LINQ(.NET 3.5 中)提供了一种处理处理中数据的好方法,还提供了处理数据库、Web 服务、LDAP 等的各种选项。
    • 委托允许使用 VB 和 C# 的某种功能性编码风格; 由于 lambda 表达式,这在 C# 3.0 和 VB9 中更好。
    • LINQ to XML 是我用过的最好的 XML 库
    • 使用 Silverlight 作为 RIA 框架,您可以在轻量级客户端和其他访问方法之间共享大量代码
    • 一个非常好的版本控制故事,包括绑定重定向、运行时首选项等
  • 一个针对多种语言的框架:

    • 与(例如)COM 相比,共享组件更简单
    • 语言选择可以根据任务和团队经验来决定。 从 .NET 4.0 开始,这一点尤其重要:如果函数式语言更合适,请使用 F#; 如果动态语言更合适,请使用 IronRuby 或 IronPython; 所有语言之间轻松互操作
    • 坦白说,我只是认为 C# 是一种比 VB 或 C++ 干净得多的语言。 (我不了解 Delphi,但我听说过有关它的好消息 - 嘿,无论如何,您现在可以使用 Delphi 将 .NET 定位为目标。)

大部分内容的结果 - 以及我想的原话 - 是 .NET 允许更快地开发更强大的应用程序

为了解决您在问题中提到的两个具体问题:

  • 如果您的客户运行的是 Vista,那么他们已经拥有 .NET 3.0。 如果他们运行的是 XP SP2 或 SP3,则他们可能至少拥有 .NET 2.0。 是的,如果您想使用该框架,您必须下载该框架的较新版本,但我认为这是一个很小的问题。 我认为将应用程序的大小与框架的大小进行比较没有任何意义。 您是否将应用程序的大小与操作系统的大小或 IDE 的大小进行比较?
  • 我并不像大多数人那样认为反编译是一个问题。 你真的需要考虑一下你害怕什么:
    • 如果您担心人们复制您的实际代码,那么如果您了解基本设计,从头开始编写代码通常会容易得多。 请记住,反编译器不会给出局部变量名称(假设您不分发 PDB)或注释。 如果您的原始源代码仅像反编译版本一样容易理解,那么您遇到的问题比盗版更大。
    • 如果您担心人们绕过您的许可并盗版您的代码,您应该记住我们为阻止人们盗版本机应用程序付出了多少努力 - 以及效果如何。
    • .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:

    • Strong typing avoids treating one type as another improperly
    • Garbage collection largely removes memory management concerns (not totally, I'll readily admit)
    • "Segmentation fault" usually translates to "NullReferenceException" - but in a much easier to debug manner!
    • No chance of buffer overruns (aside from the potential for CLR bugs, of course) - that immediately removes a big security concern
    • A declarative security model and a well-designed runtime allows code to be run under a variety of trust levels
    • JITting allows the CLR to take advantage of running on a 64 bit machine with no recompilation necessary (other than for some interop situations)
    • Future processor developments can also be targeted by the JITter, giving improvements with no work on the part of the developer (including no need to rebuild or distribute multiple versions).
    • Reflection allows for all kinds of things which are either impossible or hard in unmanaged environments
  • A modern object-oriented framework:

    • Generics with execution time knowledge (as opposed to type erasure in Java)
    • Reasonable threading support, with a new set of primitives (Parallel Extensions) coming in .NET 4.0
    • Internationalisation and Unicode support from the very start - just one string type to consider, for one thing :)
    • Windows Presentation Framework provides a modern GUI framework, allowing for declarative design, good layout and animation support etc
    • Good support for interoperating with native libraries (P/Invoke is so much nicer than JNI, for example)
    • Exceptions are much more informative (and easier to deal with) than error codes
    • LINQ (in .NET 3.5) provides a lovely way of working with data in-process, as well giving various options for working with databases, web services, LDAP etc.
    • Delegates allow a somewhat-functional style of coding from VB and C#; this is better in C# 3.0 and VB9 due to lambda expressions.
    • LINQ to XML is the nicest XML library I've used
    • Using Silverlight as an RIA framework allows you to share a lot of code between your lightweight client and other access methods
    • A mostly-good versioning story, including binding redirection, runtime preference etc
  • One framework targeted by multiple languages:

    • Simpler to share components than with (say) COM
    • Language choice can be driven by task and team experience. This will be particularly significant as of .NET 4.0: where a functional language is more appropriate, use F#; where a dynamic language is more appropriate, use IronRuby or IronPython; interoperate easily between all languages
    • Frankly, I just think C# is a much cleaner language than VB or C++. (I don't know Delphi and I've heard good things about it though - and hey, you can target .NET with Delphi now anyway.)

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:

  • If your customer is running Vista, they already have .NET 3.0. If they're running XP SP2 or SP3, they probably have at least .NET 2.0. Yes, you have to download a newer version of the framework if you want to use it, but I view that as a pretty small issue. I don't think it makes any sense to compare the size of your application with the size of the framework. Do you compare the size of your application with the size of the operating system, or the size of your IDE?
  • I don't view decompilation as nearly such a problem as most people. You really need to think about what you're afraid of:
    • If you're afraid of people copying your actual code, it's usually a lot easier to code from scratch if you're aware of the basic design. Bear in mind that a decompiler won't give local variable names (assuming you don't distribute your PDB) or comments. If your original source code is only as easy to understand as the decompiled version, you have bigger problems than piracy.
    • If you're afraid of people bypassing your licensing and pirating your code, you should bear in mind how much effort has gone into stopping people from pirating native applications - and how ineffective it's been.
    • A lot of the use of .NET is on the server or for internal applications - in neither of these cases is decompilation an issue.
    • I've written more on this topic in this article about decompilation and obfuscation.
深陷 2024-07-20 11:29:43

仅举几例:

  • 自动内存管理、垃圾收集
  • 类型安全
  • 边界检查
  • 访问数千个无需创建的类

To name a few:

  • Automatic memory management, garbage collection
  • Type safety
  • Bounds checking
  • Access to thousands of classes that you will not have to create
你的呼吸 2024-07-20 11:29:43

首先,没有一种语言/平台是普遍优越的。

  • 专业化总是会在某些领域提供更好的用例,但通用语言将适用于更多领域。
  • 多范式语言将遭受范式之间复杂的边界情况的影响,例如
    • 在任何函数式语言中进行类型推断,在提供子类时也允许 OOP
    • C++的语法极其复杂,这直接影响到其工具链的能力。
    • 同向/反向方差与 C# 中的泛型相结合的复杂性非常难以理解。

较旧的语言将拥有可用的现有代码库,这既是积极的(经验、经过充分测试、广泛的支持文献),也是消极的(由此产生的反对变革的惯性、多种不同的做事方式导致新进入者的困惑)。

与大多数事情一样,语言和平台的选择/使用是利弊的平衡。

在下面的列表中,Delphi 具有一些相同的优点和缺点,但也有许多不同之处。

潜在 .Net 的缺点(如果它们对您来说不是问题,那么它们就不是缺点)

  • 是的,您需要部署(和安装)运行时,而且它很大。
  • 如果你想要一种具有多重继承的语言,你不会得到它
  • BCL 集合库有一些严重的缺陷
  • 在 MS 领域之外没有得到广泛支持(单声道很棒,但它明显落后于官方实现)
  • 潜在的专利/版权负担
  • Jitted(忽略 ngen)启动时间总是会变慢并且需要更多内存。

还有更多,但这些是亮点。

潜在优点(同样,如果它们对你来说不重要)

  • 通用GC,没有引用计数会阻止某些数据结构的使用,我知道没有广泛使用的函数式语言没有GC,我不能想想过去 10 年中至少没有可选 GC 的重要语言。 如果您认为这不是什么大问题,那么您似乎属于少数派。
  • 大型 BCL(某些部分不如其他部分那么好,但非常广泛)
  • 可以使用大量语言(以及数量惊人的范式)并相互交互(我在一个更广泛的应用程序中使用 c#、f#、C++/CLI在最有意义的地方使用每一个,但能够轻松地使用其中一个方面)。
  • 全功能内省与声明性编程支持相结合。 通过这种方式,各种框架变得更加简单且易于使用。
  • Jitted - 底层 CPU 架构的改变在很大程度上是透明的,预编译语言无法实现的复杂的运行时优化是可能的(java 目前在这方面做得更好)
  • 内存访问安全
  • Fusion dll 加载和系统 dll 的 GAC

同样专门针对 c#

缺点:

  • 基于 C 基础
  • (4.0 之前)的语法仅通过继承进行后期绑定
  • 比某些命令式语言更冗长
  • 对复杂嵌入文字(正则表达式/xml/多行字符串)的不良处理
  • 闭包内的变量捕获可能会令人困惑
  • 嵌套生成器既麻烦又复杂执行令人震惊

优点:

  • 基于 C 基础的语法
  • 通过 lambdas 提供大量功能支持
  • 表达式允许对非代码区域(例如 Linq to SQL)进行编译时验证
  • 强类型,但具有一些类型推断,
  • 如果您确实需要不安全的交互,则可以
  • 更轻松地进行交互通过 P/Invoke 使用现有的 C++ ABI 代码既简单又清晰。
  • 内置多播事件模型。
  • 轻量级运行时代码生成

C 基础确实有利有弊。 它可以被大量程序员理解(与基于 pascal 的风格相比),但有一定的缺陷(switch 语句就是一个明显的例子)。

强/弱/静态/动态类型系统是一个两极分化的争论,但毫无疑问,如果类型系统受到更多限制,它应该努力不要求过多的冗长,c# 在这方面肯定比许多系统更好。看待。

对于许多内部业务线应用程序来说,.Net 平台的大量缺点绝对无关紧要(受控部署是公司内部常见且已得到很好解决的问题)。
因此,使用 .Net(这在很大程度上意味着 c#,对不起,VB.Net 的家伙)对于 Windows 架构中的新开发来说是一个非常明显的选择。

OK first up, No one language/platform is ever going to be universally superior.

  • Specialization will always provide a better use case in certain areas but general purpose languages will be applicable to more domains.
  • Multi-paradigm languages will suffer from complex boundary cases between paradigms e.g.
    • Type inference in any functional language that also allows OOP when presented with sub classes
    • The grammar of C++ is astonishingly complex, This has a direct effect on the abilities of its tool chain.
    • The complexities of co/contra variance coupled with generics in c# is very hard to understand.

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)

  • Yes, you need the runtime deployed (and installed), and it's big.
  • If you wanted a language with multiple inheritance you're not going to get it
  • The BCL collections library has some serious flaws
  • Not widely supported outside the MS universe (mono is great but it lags the official implementation significantly)
  • Potential patent/copyright encumbrance
  • Jitted (ignoring ngen) start up time is always going to be slower and more memory will be needed.

There are more but these are the highlights.

Potential Positives (again if they don't matter to you)

  • A universal GC, no reference counting that prevents certain data structures being usable, I know of no widely used Functional language without GC, I can't think of significant language of the last 10 years without at least optional GC. If you believe this is not a big deal you would appear to be in a minority.
  • A large BCL (some parts not so good as others but it's very broad)
  • Vast numbers of languages (and a surprising number of paradigms) can be used and interact with each other (I use c#, f#, C++/CLI within one wider application using each where it makes most sense but able to easily use aspects of one from another).
  • Full featured introspection combined with declarative programming support. A wide variety of frameworks become much simpler and easy to use in this manner.
  • Jitted - alterations in underlying CPU architecture can be largely transparent, sophisticated runtime optimizations not available to pre-compiled languages are possible (java is doing rather better on this currently)
  • memory access safety
  • Fusion dll loading and the GAC for system dlls

Likewise specifically for c#

Con:

  • Syntax based on C underpinnings
  • (pre 4.0) late binding solely via inheritance
  • More verbose than some imperative languages
  • poor handling of complex embedded literals (regexes/xml/multi line strings)
  • variable capture within closures can be confusing
  • nested generators are both cumbersome and perform appallingly

Pro:

  • Syntax based on C underpinnings
  • Much functional support through lambdas
  • Expressions allowing compile time validation of non code areas such as Linq to SQL
  • Strongly typed but with some Type inference to make this easier
  • if you really need to unsafe is there for you
  • interaction with existing C++ ABI code via P/Invoke is both simple and clear.
  • multicast event model built in.
  • light weight runtime code generation

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.

天赋异禀 2024-07-20 11:29:43

使用它开发复杂(和简单)应用程序的“简单性”。 许多基本的东西已经在框架中为您编码,您可以直接使用它。 现在下载 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.

や莫失莫忘 2024-07-20 11:29:43

原因有很多。 我对 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.

在你怀里撒娇 2024-07-20 11:29:43

.NET 开发人员在这里引用了许多所谓的优点,但这些优点不应该出现在这种比较中,因为 Delphi 也具有这些优点:

  • 类型安全
  • 边界检查
  • 访问数千个无需创建的类(组件)

有然而,.NET 中的一些东西 Delphi 没有现成的,只有其中一些可以通过库和自己的代码添加。 仅举几例:

  • 支持在同一运行时上工作的多种语言 - 允许为问题选择匹配的语言(例如使用 F# 进行函数式编程)
  • 动态源代码生成和编译 - 这对 Delphi 程序员来说是如此陌生,以至于他们可能甚至不知道它有什么用处 [1]
  • 多播事件
  • 更好的多线程支持(例如,BackgroundWorker 类、异步委托)
  • 对 32 和 64 位进程的无缝支持
  • 弱引用

[1] 如果您不知道但如果有兴趣,请查看 Marc Clifton 的主页,尤其是有关声明式编程的文章。

编辑:我想回应 Mason Wheeler 的评论:

  1. 关于动态代码:我知道有一些解决方案可以将 Pascal 脚本嵌入到应用程序中。 然而,使部分内部对象层次结构可供脚本引擎使用与在运行时使用用于代码的相同编译器之间存在明显的区别。 Delphi编译器和脚本引擎的编译器之间总是存在差异。 不管怎样,.NET 所带来的一切远远超出了 Delphi 所提供的一切。 不管怎样,是否能够为 Delphi 编写类似的基础结构并不重要,重要的是,使用 .NET,当您需要它时,它已经为您提供了。

  2. 重新多播事件:确实,有一些方法可以对其进行编码,但它不是 Delphi/VCL 开箱即用的一部分。 这就是我上面所说的。

  3. 关于弱引用:您大错特错了。 尝试以不平凡的方式使用接口,并在此过程中创建循环引用。 然后你必须开始使用类型转换并希望弱引用。

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:

  • Type safety
  • Bounds checking
  • Access to thousands of classes (components) that you will not have to create

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:

  • Support for multiple languages working on top of the same runtime - allowing to choose the matching language for the problem (e.g. functional programming using F#)
  • Dynamic source code generation and compilation - this is something so alien to Delphi programmers that they probably don't even see how it could be useful [1]
  • Multicast events
  • Better multi-threading support (for example BackgroundWorker class, asynchronous delegates)
  • Seamless support for both 32 and 64 bit processes
  • Weak references

[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:

  1. 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.

  2. 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.

  3. 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.

木有鱼丸 2024-07-20 11:29:43

好吧,.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.

奈何桥上唱咆哮 2024-07-20 11:29:43

对于 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.

﹂绝世的画 2024-07-20 11:29:43

据我所知,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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文