[ prog / sol / mona ]

prog


Greenspun's tenth rule

1 2020-12-07 04:58

Is it true that “Any suffi­ciently com­pli­cated C or For­tran pro­gram con­tains an ad hoc, infor­mal­ly-spec­i­fied, bug-rid­den, slow imple­men­ta­tion of half of Com­mon Lisp?”

2 2020-12-07 08:57

>>1
A dedicated C-based program will be much faster
in most cases, due better optimizations - however it will take much longer to write.
for example, this minikanren runs inside scheme;
If it was translated to C code parser, and that parser was
run vs a pure Scheme program the C parser will win on performance
and bugs will be caught by static analysis tools if desired.
The scheme program will be transpiled to C code with all the scheme
cruft/overhead since its automated, not hand-written.

https://github.com/webyrd/miniKanren-with-symbolic-constraints/blob/master/mk.scm

3 2020-12-07 09:36

>>1
It depends on the domain:
1. High-level stuff will resemble
lisp or whatever domain its in(e.g. logic) superficially,
providing minimal functionality developed as throwaway code
to solve something specific and
being hard to debug(e.g. function pointers, nested macros) vs
high-level stuff that is meant to be extensible, generic and composable.
C API will not be pretty to use vs parsing LISP: it is however much
likely to be faster in its dedicated task.

2.Mid-level stuff will resemble object systems from C++/java/ada.
There will be equal or better functionality, but much buggier due
exposing low-level primitives. The flexibility and speed will be competitive
with mid-level languages.

3.Low-level C has no competitors and its what your high-level languages
compile to most of time.
Low-level stuff is easy to debug/optimize/refactor.
Its possible to make higher-level abstraction based on low-level
stuff, which entails creating a complex high-level system with all
the disadvantages of C in #1.

4 2020-12-07 09:41

>>1
What if C programmers don't want to 'accidentally implement LISP'
but some specific subset of it, that is practically useful?
https://github.com/FrozenVoid/C-headers/blob/main/lambda.h

5 2020-12-11 12:38

>>2
Even C's performance will suffer once you bring the level of abstraction up to the point where you can comfortably explore and solve problems across your whole problem domain.

I could write a fast sudoku solver in C, but its functionality would be only a fraction of a similar program in prolog.

6 2020-12-11 19:24

>>1

https://news.ycombinator.com/item?id=25386971

7


VIP:

do not edit these