The joy of concurrent logic programming
call-with-current-continuation.org
call-with-current-continuation.org
"As in Prolog, strings are lists of character codes which makes them automatically suitable for stream processing. Apart from avoiding the tedious duplication of list and string manipulation operations, this allows for efficient, asynchronous handling of streams of characters, so the extra space needed for lists is partially balanced by manipulating them in a lazy manner, one piece at a time, by communicating processes."
In Prolog, the meaning of double-quoted strings depends on the value of the Prolog flag double_quotes. Only if it is set to the value codes are double-quoted strings interpreted as lists of codes. However, a much better setting is the value chars, and then double-quoted strings are interpreted as lists of 1-char atoms. For example, with this setting, we have:
?- "abc" = [a|Ls].
Ls = "bc".
This is the default value in all of the three newest Prolog systems: Scryer Prolog, Tau Prolog and Trealla Prolog. It was also the original interpretation of strings in the very first Prolog systems, Prolog 0 and Marseille Prolog, which were designed for natural language processing. Lists of characters ensure that strings are very readable, also when emitted in their canonical representation. For example, Scryer Prolog yields: ?- write_canonical("abc").
'.'(a,'.'(b,'.'(c,[]))) true.
The mentioned advantage of "avoiding the tedious duplication of list and string manipulation operations" in this way can hardly be overstated: It is massive, because everything one knows about lists carries over directly to strings, including common predicates such as append/3, length/2 and reverse/2 which even beginning Prolog programmers universally know, and the ability to generalize arbitrary elements by using logic variables at desired positions, obtaining partially instantiated terms such as "all strings of length 3" which can be specified symbolically as [_,_,_]. In addition, lists are especially conveniently reasoned about with Prolog's built-in grammar mechanism, definite clause grammars (DCGs), tailor-made for generating and parsing sequences and therefore also strings. And further, "the extra space needed for lists" can be avoided with a compact internal representation of lists of characters, i.e., encoding them as sequences of raw bytes, using UTF-8 encoding. This efficient representation is currently already implemented in Scryer Prolog and Trealla Prolog.The book is a much underappreciated gem
If you pass single operations between threads you will run slower, not faster because of the synchronization overhead.
Whenever I parallelize something I build batching in from the beginning. Most other people seem to think it is an optimization you can do later but the way I see if if your goal is to get any speed up at all batching is essential.
For this the natural ‘batch’ is one image and that justifies the overhead easily.
From: http://www.call-with-current-continuation.org/fleng/fleng.ht...
It seems the author has taken this into account, it's not a 1:1 mapping of processes to OS threads.
> the order in which these unifications take place is immaterial, any order is fine ... if a logic variable is unbound, then matching a pattern containing such a variable suspends and does not continue until the variable has been bound.
> There is no need to artificially orchestrate how the processes execute in parallel, this is done implicitly like the cells of a spreadsheet - once a required result is available, it may trigger further variables to be bound and processes to be resumed, and so on, until the network of processes settles.
The author notes: "There is a compiler for KL1 to C available [2], which seems to work, but suffers from bit rot." Note that Ueda and colleagues have been updating this software (KLIC): see https://www.ueda.info.waseda.ac.jp/software.html for details. Ueda's work on LMNtal is also very interesting.
I wonder how many readers made it past the formatting, only to stop reading here?
but the software people have known for 50 years that concurrency was going to be necessary to go further..but it was never really a good time.
maybe we can finally start looking at other programming models instead of wasting so much time and getting such crappy reliability and performance out of thread-and-lock?
[0] https://gamefaqs.gamespot.com/snes/588741-super-metroid/faqs...
It messes up Firefox reader mode.
I myself have gotten complaints from other people when using linebreaks in Github comments because their device renders them.
There's a chicken and egg problem with compilers and languages on the one side and machines architectures and instruction sets on the other, it's not easy breaking the mold. (GPUs are a counter-example perhaps?)
CPU designers can't all be Ivan Godard ( https://hackaday.com/2013/08/02/the-mill-cpu-architecture/ https://millcomputing.com/ ) or Chuck Moore ( https://en.wikipedia.org/wiki/Charles_H._Moore#Hardware_desi... http://www.greenarraychips.com/ ) eh?
If you're at Intel, you not likely to see this as a calm period bereft of ideas, while Apple silicon has made such strides. New ideas, or simply a rebalancing of familiar ideas, can make significant progress against the same physics.
It would be much better to find the most interesting/surprising/meaty thing and start a thread with that.
https://hn.algolia.com/?dateRange=all&page=0&prefix=true&que...
(Also, re formatting - see https://news.ycombinator.com/newsguidelines.html: "Please don't complain about website formatting, back-button breakage, and similar annoyances. They're too common to be interesting. Exception: when the author is present. Then friendly feedback might be helpful."
p.s. Your comments are usually excellent—thank you!