Skip to content

Comment on F*: A general-purpose proof-oriented programming languageparent

Comments

what exactly makes the best performing languages perform so

There's a multitude of factors. Broadly speaking, to achieve high performance on modern hardware you want one or more of:

- Control over emitted code and/or data structures. You tend to see this most prominently with "low-level" programming languages like C or C++, especially when coupled with extensions like SIMD intrinsics or inline assembly.

- Semantics/features that make life easier for the optimizer/runtime. Types are an obvious example here, but other things like annotations (e.g., `restrict` in C, `std::unreachable` or `[[likely]]`/`[[unlikely]]` in C++) and the right abstractions (e.g., C++ expression templates) can all make it easier to get good performance.

- Less dynamic semantics. Stuff that changes or needs to be resolved at runtime tends to make optimizers/hardware unhappy, so if you want performance you either want to avoid writing such constructs in the first place (e.g., writing code that doesn't involve pointer chasing) or spend engineering effort to reduce/eliminate their impact at runtime (e.g., the JVM, though for best effect you tend to need to write your code in a specific style anyways).

There's probably other factors I'm forgetting...

c gets compiled to obj files and these are run natively by each cpu are they not?

To a first approximation, sure.

isnt there a way to say translate a high level language directly into higly optimized machine code very specific to each processor model in the world?

This is basically one of the things JITs promise - the ability to optimize a program specifically for the computer it is running on.

It's technically possible to offer processor-specific binaries with ahead-of-time compilation as well (e.g., passing the appropriate -march flag to GCC/Clang/etc.), but I think for most programs you'll usually see different binaries for different CPU families based on the instruction set(s) they implement (e.g., one binary for x86-64v2, one for x86-64v3, one for x86-64v4, etc.) rather than processor-specific binaries.

Really appreciate the effort put into a seemingly naive questions, thanks.

You never know if the person on the other end is going to be one of today's lucky 10000 :P

AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.