views:

489

answers:

12

I have became 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)

Also I am mainly interested in little-known languages.

update: more constraints

  • must be above ASM level (and yes I am interested in macro languages on top of ASM)
  • can be obscure, not very widespread
+11  A: 

How about Assembly language, or the D programming language?

Andrew Hare
Yeah, I love assembly but I am actually searching for above-asm languages
Richard J. Terrell
check out "D" it might be just what you are after.
Andrew Hare
Looks great, thanks!
Richard J. Terrell
+2  A: 

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

Gambrinus
Closest to hardware != fastest. In fact, you actually have more room to worsen performance than you do in a "farther from the hardware" language like Java (for a number of reasons). Mainly because you spend more time dealing with lower level things than you can on actual algorithms.
Jason Baker
+10  A: 

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.

unwind
+5  A: 

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

Kyle Walsh
After the updated question, I felt the need to delete this...but I'll just leave it up. It seems Rob Sanders and myself are in agreement.
Kyle Walsh
+5  A: 

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!

RobS
No intention to abandon the great C/C++ world. Just to explore ways and possibilities around the same level. So, a language unable to call C/C++ code is useless.
Richard J. Terrell
A: 

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.

Sean
have you read the question? it is not about getting as close as possible. and "must be above ASM level"
Richard J. Terrell
VASM is also an option http://sun.hasenbraten.de/vasm/ :)
RobS
Thanks Sanders, looks great!
Richard J. Terrell
@gdivos: Yes I read the question. There was no mention of "must be ASM level" when I posted (he's added an update). Try and stay calm!
Sean
@Sean: it was just a comment, didn't wanted to offend you. and yeah i am totally calm :)
Richard J. Terrell
A: 

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.

Richard J. Terrell
Both of those are tools for creating C which communicates with a simple object model - CPython and GObject respectively. Neither has, AFIAK, anything to do with high performance computing.
Pete Kirkham
No? check out pyrex at the bottom of this page: http://www.scipy.org/PerformancePython
Richard J. Terrell
That shows that someone tried using Pyrex to generate C, which was found to run nearly as fast as C by itself. NumPy on the other hand is actively used in HPC applications, as are Python wrappers for Intel HPC libraries.
Pete Kirkham
Still, Pyrex (and Vala) run nearly as fast as C, thus they are good candidates for writing high-performance software.
Richard J. Terrell
A: 

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

Hank Gay
+1  A: 

Forth!

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

is the dense object code a feature of Forth, or a feature of a particular Forth compiler?
slim
"faster than machine language on some architectures" - eh, how's that possible?
Skizz
What he means is that some Forth compilers generate machine code that is often better than your average developers' assembly will be.
thenduks
You could say that about any language.
Skizz
It's a property of some Forth-systems (in Forth there is no compiler/interpreter as commonly known. Some Forths simply interpret a list of subroutine addresses. This list is shorter than the corresponding subroutines calls in assembly, hence the advantage. A complete Forth can take as little as 2KB.
+1  A: 

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.

Pete Kirkham
+1  A: 

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

starblue
A: 

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.

Gilles