upvote
I don't think I knew how to approach the problem. There would have been no benefit in using the compiler if I did. Kind of like, if we want to talk about code, many coders don't know how to approach making a hashmap. They don't need to. The compiler figures it out for them, as it did me for my problems. I'd call the input I gave a specification of the problem, but words are in the eye of the beholder, I suppose.

If we take "write the specification of how to approach the problem" at literal value, you might be narrowly thinking of a low-level compiler, or what sometimes gets called a transpiler? However, compilers encompass a much wider spectrum than that. Generally they enable users to operate at higher levels of abstraction.

reply
I think you're talking about more than just a compiler, though standard libraries are often distributed with the compiler. Take Rust for example, it's not like the compiler has special integration with hash maps, it's just that the standard library has a standard implementation and the compiler lets you refer to that implementation without having to repeat it yourself. In a way you're just including parts of another spec in yours. Specifications do this all the time, for example by using English. You don't have to define all the levels of abstraction, only the ones that matter.

Even so, I'd argue that you still have to define how to use those abstractions rather than only the result you'd like to achieve with them. Sure, maybe the abstraction has a ".achieve_the_result()" method, and calling that method is how you achieve it, but often there's a bunch of stuff you fit together to achieve a solution to your problem and the compiler doesn't necessarily do that for you.

I think there actually may be some compilers that get closer to this, for example some problems can be expressed quite elegantly in Haskell or APL and the compiler will do a lot of black magic behind the scenes to get you a performant executable (somehow). But for most traditional compilers you are still going to have to define how to approach your problem, even if only at a higher level thanks to libraries.

reply