Kaz Kylheku said:
sasha said:
Joe Pfeiffer wrote:
[snip]
Compilers are tools like any other. A hammer is there to make life
easy for you, but your life is likely to be much more pleasant if you
don't use it to drive screws into sheet metal.
Similarly, how you code can have a large effect on how well the
compiler does its job.
I bet that thinking too much about such details today is
counter-productive.
Using languages compiled to machine code for tasks which do not
required this amount of attention to details is counterproductive
nowadays (and it has been this way for quite a while).
This is an oversimplification of the issue. Compiling to machine code
is not aways a form of premature optimization. It's just an implementation
strategy.
Consider the language Common Lisp.
[...]
My use of terms was arguably imprecise and Lisp is a good example to
demonstrate that. Assuming that some Lisp implementation actually has
a compiler which can create native code[*], there are two general ways
of using it:
- run the compiler on the Lisp-program which has not been
specially annotated with information only relevant for such
a compiler: The result will be a compiled program which has
the Lisp runtime linked to it, but uses the same
general-purpose subroutines the uncompiled program would
use, too.
- annotate the (already working) Lisp-code with
compiler-relevant information, especially, with
(preferably restrictive) type-declarations: the compiler can
then either open-code certain operations (like addition) in
the same way a C-compiler usually would or at least use less
general subroutines which will execute more efficiently.
My use of 'language compiled to machine code' would be analogous to
the second way of using such a Lisp-compiler: Include lots of
meta-information about the data structures used by the program in the
code in order to achieve more efficient runtime behaviour at the
expense of an increase in development and debugging time (and likely,
also an increase in 'bugginess' of the final result). It's just that
'people' think 'C++' if they see 'language compiled to machine code' and
'f***ing mess of nested brackets' when they see 'Common Lisp' (this
is, of course, again an oversimplification).
[*] One could argue that the existence of such compilers is a
historical accident dating back to the time when computers
where generally a lot slower and less ressourceful than
nowadays. Eg, there used to be 'a Perl compiler' which was
(very) roughly equivalent to 'Lisp compilers', but it was
recently dropped from the language distribution, because it
never attracted enough interest to even make it work reliably,
vulgo: the execution speed of the interpreted bytecode was
demonstrably 'good enough'.
[...]
What wastes the programmer's time is when he, not the machine, is
asked to pay attention to irrelevant details and responsibilities.
That can happen in an interpreted or compiled language. It's the
fault of the language, not its implementation strategy,
In my opinion, its the fault of the person who chose a particular
implementation language when this choice results in time wasted on
details that wouldn't really have mattered for achieving a usable
solution to some problem.