没有 .NET Framework 的 C#

发布于 2024-08-08 07:28:40 字数 186 浏览 6 评论 0原文

使用 C# 等现代跨平台编程语言编写带有 API 调用等的快速本机应用程序会很棒,不是吗?例如,如果您想使用简单且现代的编程语言编写一个简单的实用程序来帮助 IT 人员安装不需要其他组件的东西?或者如果你想编写一个 3D 游戏,它应该很快,而 JIT 只会让它变得更慢......

为什么,为什么不可能?为什么这些东西没有原生的现代编程语言?

Writing fast native applications, with API calls and etc, in a modern cross platform programming language like C# would be awesome, wouldn't it? For example if you want to write a simple utility for helping IT people with installing things, which wouldn't need another components, in an easy and modern programming language? or if you want to write a 3D game, it should be fast, and JIT would just make it slower...

Why, why isn't it possible? Why there are no native modern programming languages for these things?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(7

若无相欠,怎会相见 2024-08-15 07:28:40

C# 和 .Net 是本机代码。我认为您误解了 JITter。这不是虚拟机。 AC# 程序在执行之前会被编译为完全本机代码。

现在,“需要其他组件”部分是一个问题。不过,给点时间吧。如今,您将很难找到至少没有 .Net 2.0 的 Windows 安装,甚至一些主流 Linux 发行版都包含开箱即用的 Mono。

C# and .Net are native code. I think you misunderstand the JITter. It's not a VM. A C# program is compiled to fully native code before any of it is executed.

Now, the "needing other components" part is a concern. Give it time, though. You'll be hard pressed to find a windows installation these days without at least .Net 2.0, and even a couple mainstream linux distros include mono out of the box.

筱武穆 2024-08-15 07:28:40

不要认为 JIT 会使事情变慢。 JIT 可以针对运行应用程序的确切计算机进行优化,而不是针对 386 或 Pentium 等通用计算机进行优化。它甚至可以在生成代码时做出更好的速度/内存权衡决策,因为它确切地知道可用的内容。如果 JIT 仍然使速度变慢,您可以对它们进行 NGEN,以便 JIT 提前完成。

作为证明,请考虑 Quake 已被移植到 CLR 几次,在我个人的测试中,当 Quake 在 CLR 上运行时,每秒帧数更快大约是我演示它的一半。

Don't assume the JIT makes things slower. The JIT can optimize for the exact computer running the application rather than a generic computer like a 386 or Pentium. It can even make better speed/memory trade-off decisions when generating code because it knows exactly what's available. And if JIT still makes things slower, you can NGEN them so that JITting is all done beforehand.

As proof of this, consider that Quake has been ported to the CLR a couple of times, and in my personal tests, the frames per second have been faster when Quake runs on the CLR about half the times I demo it.

梦里兽 2024-08-15 07:28:40

编译的 .NET 程序已被证明运行速度与 C 一样快。如果您希望它超精简,请在本机处理器的汇编中编写它。

Compiled .NET programs have been shown to run just as quickly as C. If you want it ultra-lean write it in assembly for your native processor.

白首有我共你 2024-08-15 07:28:40

您可以使用 Microsoft NGEN.EXE 工具创建 .NET 程序集的本机映像。
请参阅 MSDN NGEN 文档。微软已经考虑过你在这里得到的内容。

Microsoft 还制作 ILMERGE.EXE工具将多个程序集文件合并为一个。这也可能与优化和速度有关。

You can use the Microsoft NGEN.EXE tool to create a native image of a .NET assembly.
See MSDN NGEN documentation. Microsoft already though about what you're getting at here.

Microsoft also makes ILMERGE.EXE tool to merge multiple assembly files into one. This might border on optimization and speed too.

单身狗的梦 2024-08-15 07:28:40

顺便说一句,Mono 具有完全的提前编译,消除了运行时。 (我认为这就是他们在 iPhone 上运行的方式,因为 iPhone 禁止任何 JIT。)

As a side note, Mono has full ahead of time compiling, eliminating the runtime. (I think that's how they get away running on iPhone, which prohibits any JIT.)

相思碎 2024-08-15 07:28:40

那么,这是否意味着我们可以使用(有限的).NET 调用将 C# 程序完全编译并链接到独立的 EXE 中,而无需安装 .NET 即可运行?

仅供参考:检查大约 5000 台服务器的服务器资产后发现,大约有 200 台服务器甚至没有安装 .NET 2.0。

这会导致必须在“所有 Windows 实例”上运行的代码出现问题。对于不包括 2.0 的 .NET 4.0+,情况会变得更糟,因为新旧 Windows 计算机可能都没有“正确的”.NET

So, does this mean that we could fully compile and link a C# program using (limited) .NET calls into a standalone EXE that would run without .NET being installed at all?

FYI: Checking a server estate of some 5000 servers revealed about 200 without even .NET 2.0.

This causes problems for code that must run on "all Windows instances". With .NET 4.0+ not including 2.0 this gets worse as both new AND old Windows machines might not have the 'right' .NET

过气美图社 2024-08-15 07:28:40

还有,C.C 可以用来编写任何应用程序,永远!!!

there is, C. C can be used to write any application , ever !!!

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