Question

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.

Was it helpful?

Solution

OTHER TIPS

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.

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!

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

Forth!

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

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.

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

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

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.

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

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.

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top