您可以推荐哪些快速的低级语言?

发布于 2024-07-15 09:00:24 字数 241 浏览 9 评论 0 原文

我对用于性能计算的类 C 语言产生了兴趣。 您能否推荐一些具有以下属性的替代编程语言:

  • 必须接近硬件(位摆弄、指针或一些替代安全方法,如引用)
  • 没有托管代码(没有 jvm/.net 语言)
  • 必须非常快(比如C)
  • 必须高于 ASM 级别(是的,我对 ASM 之上的宏语言感兴趣)
  • 可以是晦涩的,不是很广泛

我主要对鲜为人知的语言感兴趣。

I have become interested in C-like languages for performance computing. Can you recommend some alternative programming languages which have the following attributes:

  • must be close to the hardware (bit fiddling, pointers or some alternative safe method like references)
  • no managed code (no jvm/.net languages)
  • has to be really fast (like C)
  • must be above ASM level (and yes I am interested in macro languages on top of ASM)
  • can be obscure, not very widespread

I am mainly interested in little-known languages.

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

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

发布评论

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

评论(12

平安喜乐 2024-07-22 09:00:24

如果您对此不了解并且只是想拓宽视野,请查看 第四。 阅读 Forth 总是让我感觉 C 很高级。

If you don't know about it and are interested just in broadening your horizons, take a look at Forth. Reading about Forth always makes me feel C is high-level.

给妤﹃绝世温柔 2024-07-22 09:00:24

嗯,我一直更喜欢 C 和/或 C++,因为它有多种风格(MSVC、glibc 等),它可以在许多不同的平台(例如移动设备、Windows、linux)和设备上运行,并且可以跨平台编写(不同的处理器架构),甚至高端图形(例如 DirectX)。

您可以获得对平台资源的“体面”访问(条件有所不同),它可以像您选择磨练它一样快,并且它比 ASM 更容易编写(恕我直言)。 还有一系列相当不错的支持工具和代码分析工具,可以让事情变得更容易一些。

而且 C 和 C++ 已经存在相当长一段时间了,所以它(即使在今天)也有一个优秀而热情的社区!

Well, I've always preferred C and/or C++ because there are multiple flavours (MSVC, glibc etc), it runs on many different platforms (e.g. mobile devices, Windows, linux) and devices, and it can be written cross platform (different processor architectures) and even for high end graphics (e.g. DirectX).

You get "decent" access to platform resources (conditions vary), it can be as fast as you choose to hone it, and it's a tad easier (IMHO) to write than ASM. There's also a pretty decent range of support tools and code analysis tools to make things a little easier.

Also C and C++ have been around for quite some time, so it's got (even today) an excellent and enthusiastic community!

国际总奸 2024-07-22 09:00:24

您没有明确指出您的问题中不能是 C,所以我会继续推荐 C。它满足您的三个项目符号愿望,并且您不必担心该语言的不同版本(例如每种不同类型的汇编器)。

You don't explicitly state that it can't be C in your question, so I'll go ahead and recommend C. It fulfills your three bulleted desires, and you won't have to worry about different versions of the language (like each different kind of assembler).

尐籹人 2024-07-22 09:00:24

向前!

在某些架构上,Forth 可能比机器语言更快。 编译后的代码非常密集,因此可以充分利用代码缓存。

Forth!

Forth can be faster than machine language on some architectures. The compiled code is extremely dense, therefore, making optimal use of code caching.

流心雨 2024-07-22 09:00:24

组装将是最接近硬件的,因此是最快的

assembly would be the closest to the hardware and therefore the fastest

梦萦几度 2024-07-22 09:00:24

Ada 最初是为嵌入式系统(以及其他系统)设计的。

Ada was originally designed for embedded systems (among other things).

木落 2024-07-22 09:00:24

OpenCL 可能很有趣。 它有点像 OpenGL 着色器语言(带扩展的 C 子集),但用于通用并行数组计算。

OpenCL might be interesting. It's sort of like OpenGL shader language (a subset of C with extensions), but for general purpose parallel array computing.

无敌元气妹 2024-07-22 09:00:24

您可以开始使用 VHDL、Verilog、System C 对 FPGA 进行编程...

You could start programming FPGAs in VHDL, Verilog, System C ...

此岸叶落 2024-07-22 09:00:24

主题的变体

FORTRAN 早于 C,并且仍然存在数值计算领域的主要参与者之一。 直到 1990 年(当时该语言已实现大幅现代化),该语言还没有任何形式的指针(检查或未检查)。 这种缺乏意味着无法动态管理内存; 它还使编译器可以轻松进行别名分析,这是其中之一这使得 Fortran 代码变得更快。

ALGOL 是第一种结构化编程语言。 尽管它在程序员中取得的成功有限,但它对语言设计者产生了强大的影响。

Ada 是一种具有强类型的命令式语言系统和良好的模块化性,这使得它非常适合具有强保证要求的低级编程(它是由美国政府赞助的,考虑到军事和航空电子应用)。 它的灵感来自 Pascal,例如 Modula-2Modula-3

远离主流的低级命令式编程,有 FORTH。 FORTH 可以针对内存很少的设备进行编译,甚至可以在其上进行解释; 它在低端嵌入式系统(包括微控制器)上有很多用途。 该语言基于因 HP 计算器而闻名的逆波兰表示法(事实上,HP 计算器的语言深受 FORTH 的影响)。 许多实现没有变量:所有数据都保存在一个或多个堆栈上。

只是为了好玩,我会提到 INTERCAL,深奥语言的鼻祖。

那些让你大吃一惊的东西

深奥语言可能具有启发性,而且相当多的作品接近机器(通常是虚拟机,但原则上,如果您足够疯狂,您可以在实际计算机上实现它们)。 你可以看看 brainfuck (图灵机和 C 之间的一种中间阶段),或者许多单指令语言,或befunge(如果内存是两个 维数组?)。

Cyclone 看起来很像 C。语法是一样的,Cyclone 有指针、无标记结构和联合、goto 语句和手动内存管理。 然而它是一种安全语言:不能有悬空指针或缓冲区溢出。 您还可以访问高级功能,例如模式匹配、异常、多态性、抽象类型和可选的自动内存管理(不仅是垃圾收集,还包括区域)。 Cyclone 既有用又具有启发性; 对于 C 的顽固分子来说,这可能是发现什么是安全语言的好方法。 Cyclone 可以编译为 C,因此您可以在任何有 C 编译器的地方运行您的程序。

换个方向,如果您想接近硬件,但仍然没有实际设计硬件,请查看 同步语言,例如LustreEsterel。 这些语言用于对核电站、飞机和铁路信号等高保证实时系统进行编程。 这些语言放弃了图灵完备性,并确保程序员可以准确地知道他们的程序运行的速度以及需要多少内存。 如果您认为 C 语言最接近机器,那么了解什么语言真正接近机器可能会令人震惊。

Variations on a theme

FORTRAN is older than C, and is still one of the major players in numerical computing. Until 1990 (when the language was substantially modernized), the language didn't have any form of pointer (checked or not). This lack meant that there was no way to manage memory dynamically; it also made aliasing analysis easy for the compiler, which is one of the things that makes Fortran code fast.

ALGOL was the first structured programming language. Although it had limited success with programmers, it had a strong influence on language designers.

Ada is an imperative language with a strong type system and good modularity, which makes it good for low-level programming with strong assurance requirements (it was sponsored by the US government with military and avionics applications in mind). It was inspired by Pascal, like Modula-2 and Modula-3.

Going further from the mainstream of low-level imperative programming, there is FORTH. FORTH can be compiled for, and even interpreted on, devices with very little memory; it finds a lot of use on low-end embedded systems, including microcontrollers. The language is based on reverse polish notation, made famous by HP calculators (in fact, the language of HP calculators is strongly influenced by FORTH). Many implementations don't have variables: all data is kept on one or more stacks.

Just for fun, I'll mention INTERCAL, the grandaddy of esoteric languages.

Stuff that will blow your mind

Esoteric languages can be instructive, and a quite a few work close to the machine (usually a virtual machine, but in principle you could implement them for an actual computer if you were crazy enough). You could look at brainfuck (a sort of intermediate stage between Turing machines and C), or the many single-instruction languages, or befunge (what if memory was a two-dimensional array?).

Cyclone looks a lot like C. The syntax is the same, and Cyclone has pointers, untagged structures and unions, goto statements and manual memory management. And yet it's a safe language: you can't have a dangling pointer, or a buffer overflow. And you have access to high-level features such as pattern matching, exceptions, polymorphism, abstract types and optional automatic memory management (not just garbage collection, but also regions). Cyclone is both useful and instructive; for a C die-hard, it can be a good way of discovering what makes a safe language. Cyclone can compile to C, so you can run your programs anywhere you have a C compiler for.

Going in a different direction, if you want to be close to the hardware, while still not actually designing hardware, have a look at synchronous languages, such as Lustre and Esterel. These languages are used to program high-assurance realtime systems such as nuclear plants, airplanes and railway signaling. These languages give up Turing completeness and gain the assurance that programmers can know exactly how fast their program will run and how much memory it will require. If you think C is close to the machine, finding out what a language that is really close to the machine may come as a shock.

烟花易冷人易散 2024-07-22 09:00:24

你不可能比汇编语言更接近,除非你在芯片制造商找到一份工作并开始编写微代码!

如果您使用的是 Windows,我认为您可以使用 Microsoft MASM(宏汇编器),它可以让您快速启动并运行。 我很久以前就用过它,它不是一个糟糕的产品。

You can't get much closer than assembly language, unless you get a job with a chip-maker and start writing micro code!!!

If you're on Windows I think you can get hold of Microsoft MASM (macro assembler) that will allow you go get up and running quickly. I used it a long time ago and it's not a bad product.

不气馁 2024-07-22 09:00:24

回答我的问题似乎有点尴尬,但我发现了两种语言:

  • Pyrex
  • Vala

它们可能无法满足所有约束,但它们对于性能计算非常有用,并且都可以翻译为 C。

Seems a bit awkward to answer my question, but I have found two languages:

  • Pyrex
  • Vala

They may not fulfill all of the constraints, but they are great for performance computing and both translates to C.

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