[ prog / sol / mona ]

prog


[Book] Sussman - Software Design for Flexibility

1 2021-03-17 13:50

The new book is out!

Strategies for building systems that can be adapted for new situations with only minor programming modifications.

Time pressures encourage programmers to write code that works well for a narrow purpose, with no room to grow. But the best systems are evolvable; they can be adapted for new situations by adding code, rather than changing the existing code. The authors describe techniques they have found effective—over their combined 100-plus years of programming experience—that will help programmers avoid programming themselves into corners.

The authors explore ways to enhance flexibility by:
• Organizing systems using combinators to compose mix-and-match parts, ranging from small functions to whole arithmetics, with standardized interfaces
• Augmenting data with independent annotation layers, such as units of measurement or provenance
• Combining independent pieces of partial information using unification or propagation
• Separating control structure from problem domain with domain models, rule systems and pattern matching, propagation, and dependency-directed backtracking
• Extending the programming language, using dynamically extensible evaluators

Some of the techniques, such as dynamically extensible generic procedures, are extremely powerful but potentially dangerous. Each chapter includes exercises. Code is written in Scheme, a simple dialect of Lisp. Examples range from astronomy to automatic differentiation to an adventure game.

This is *not* a SICP rehash.

The book was written with the intent of being used in his 6.945 course, "Adventures in Advanced Symbolic Programming", which features ancient black magic techniques not previously found in SICP!
If you'd like a taste on some of the topics covered (Sussmans ideology on flexible systems, as well as touching upon dynamically extending evaluators and generic procedures), you can (if you haven't already), watch his 2011 talk, "We Really Don't Know How to Compute!"
https://www.youtube.com/watch?v=HB5TrK7A4pI

And of course, much credit is due to Chris Hanson for also authoring the book and maintaining Mit-Scheme for all these years.

Places to buy:
MIT-Press
https://mitpress.mit.edu/books/software-design-flexibility
Am*zon
https://www.amazon.com/Software-Design-Flexibility-Programming-Yourself/dp/0262045494/
Library Genesis
http://libgen.rs/book/index.php?md5=85B018F03EADF1F8BA64C12044CF6F19

Well /prog/ , this is the place to discuss your thoughts and journey through this book, so..
Discuss!

2 2021-03-17 18:23 *

Wasn't there already a thread on this?

3 2021-03-17 21:18 *

>>2
https://textboard.org/prog/77 Doffing his fez with an impish grin, The Sussman returns.

4 2021-03-18 02:16 *

>>2-3
We now have this thread.

5 2021-03-18 03:56

This one is easier to find in the catalog.
I like the [Book] prefix

6 2021-03-18 11:41

Is it Creative Commons like promised? Does that make it legal to download from libgen?

7 2021-03-18 12:34

>>6
There's nothing illegal in file sharing anyway. It's just a Russian friend lending you a book.

8 2021-03-18 13:45 *

>>7
Russian friends lending me child porn and top secret leaks.

9 2021-03-18 20:48

>>6
I haven't heard anything yet :/

10 2021-03-18 21:35

>>9
I checked the epub, it claims to be CC-BY-SA 4.0, we are all good.

11 2021-03-18 22:57

Why don't you have a seat?

12 2021-03-20 03:20 *

Gauche's Shiro Kawai is working through it:

https://nitter.1d4.us/anohana/status/1372375694999658497

My Japanese is nicht so gut, but roughly,

Software Design for Flexibility, 2.3: Up until now compose was only defined with two arguments but without saying anything they passed it three.

Ah, so the idea is to write it in Exercise 2.5c?

Old /prog/ celebrity The Ginger (who still refuses to release Croma) also tweeted about it:

https://nitter.1d4.us/patrickc/status/1371985525960151040

13 2021-03-20 10:34

>>12
I have also started reading it.

14 2021-03-21 18:09

I'm a bit confused about 2.3 Wrappers and exercise 2.11, there's more missing to get it working than what the exercise asks for. Am I supposed to just make something up for those myself? I'm doing that anyway I was just wondering if I missed something.

15 2021-03-22 18:18 *

>>14
I have yet to start exercise 2.1 and 2.2 which don't seem too hard.

16 2021-03-23 03:26 *

>>14
Kawai's support library for SDfF: https://github.com/shirok/Gauche-compat-sdff

17 2021-03-23 07:30

>>14-16
Appendix A explains where the code is and how to use it. I remember in SICP you could just type in most of the code, I really liked that, but this is nice too.

18 2021-03-23 22:20

I can't get the management software to work with Geiser. It works with plain Scheme mode but with Geiser if I evaluate a definition in a buffer it does not reach the REPL. For example, I have this this in a file outside the `sdf' directory:

(load "sdf/manager/load")
(manage 'new-environment 'combinators)

(define (foo x) x)

When I evaluate the second line with C-x C-e, I don't get any result in the echo area. If I evaluate the last line with C-x C-e after, it does echo back

=> foo

But when I try to use it in the REPL, it fails:

1 (user) => (foo 1)

;Unbound variable: foo
;To continue, call RESTART with an option number:
; (RESTART 3) => Specify a value to use instead of foo.
; (RESTART 2) => Define foo to a given value.
; (RESTART 1) => Return to read-eval-print level 1.

2 error> 

The same thing works with plain Scheme-mode (without Geiser).

19 2021-03-23 23:15

>>18
I'm also having weird issues with Geiser but I don't see any problems with your example. Evaluating the second line with C-x C-e echoes:

=>new-environment

Using Emacs 27.1 with this minimal configuration for Scheme and Geiser:

;;;Scheme
(setq auto-mode-alist
      (cons '("\\.scm$" . scheme-mode)
	    auto-mode-alist))

(load-file "~/.emacs.d/elpa/geiser-0.12/geiser.el")
(add-hook 'scheme-mode-hook 'geiser-mode)
(setq geiser-default-implementation 'mit)
(setq geiser-active-implementations '(mit))
20 2021-03-24 06:43 *

>>18,19
Geiser is known to be broken, try the r7rs swank distribution.

21 2021-03-24 17:13

https://www.gnu.org/software/mit-scheme/documentation/stable/mit-scheme-user/GNU-Emacs-Interface.html

Or use Edwin!

22 2021-03-24 17:23

This is the output I get when I set geiser-log-verbose-p and geiser-log-verbose-debug-p in emacs:

INFO: REQUEST: <20>: (geiser:eval '#f '(manage 'new-environment 'combinators))

INFO: RETORT: ((error (key . retort-syntax)) (output . "
;Loading \"sdf/common/overrides.scm\"... done
;Loading \"sdf/common/utils.scm\"... done
;Loading \"sdf/common/indexes.scm\"... done
;Loading \"sdf/common/collections.scm\"... done
;Loading \"sdf/common/memoizers.scm\"... done
;Loading \"sdf/common/predicates.scm\"... done
;Loading \"sdf/common/predicate-metadata.scm\"... done
;Loading \"sdf/common/applicability.scm\"... done
;Loading \"sdf/common/generic-procedures.scm\"... done
;Loading \"sdf/common/pretty-printer.scm\"... done
;Loading \"sdf/common/operators.scm\"... done
;Loading \"sdf/common/operations.scm\"... done
;Loading \"sdf/common/package.scm\"... done
;Loading \"sdf/common/predicate-counter.scm\"... done
;Loading \"sdf/common/simple-tests.scm\"... done
;Loading \"sdf/common/trie.scm\"... done
;Loading \"sdf/combinators/function-combinators.scm\"... done
;Value: (combinators)

1 (user) => "))

INFO: <20>: processed

It looks like it confuses the loading messages for errors? I wonder how it works for >>19, I have the latest Geiser from MELPA so it shouldn't be an issue? (Although I don't have the geiser-mit package installed, do I need that?)

23 2021-03-24 17:38 *

Looks like manage somehow breaks from from the eval:

1 (user) => (let ((environment (package/environment (find-package '(user) #t))))
  (eval '(begin (display 1) (manage 'new-environment 'combinators) (display 2)) environment))
1
;Loading "sdf/common/overrides.scm"... done
;Loading "sdf/common/utils.scm"... done
;Loading "sdf/common/indexes.scm"... done
;Loading "sdf/common/collections.scm"... done
;Loading "sdf/common/memoizers.scm"... done
;Loading "sdf/common/predicates.scm"... done
;Loading "sdf/common/predicate-metadata.scm"... done
;Loading "sdf/common/applicability.scm"... done
;Loading "sdf/common/generic-procedures.scm"... done
;Loading "sdf/common/pretty-printer.scm"... done
;Loading "sdf/common/operators.scm"... done
;Loading "sdf/common/operations.scm"... done
;Loading "sdf/common/package.scm"... done
;Loading "sdf/common/predicate-counter.scm"... done
;Loading "sdf/common/simple-tests.scm"... done
;Loading "sdf/common/trie.scm"... done
;Loading "sdf/combinators/function-combinators.scm"... done
;Value: (combinators)

1 (user) => 
24 2021-03-27 13:23

>>18,19,22,23
Geiser is a piece of shit, use xscheme, it's made for mit-scheme and included with Emacs.
M-x load-library xscheme
M-x start-scheme
Keybindings are odd though, make sure you C-h m to see what they are.

25 2021-04-04 20:42

I am not reading this until it gets its own Touhou music video.

26 2021-04-08 02:23 *

>>25
Wich 2hu wud u fuk?

27 2021-04-21 14:09

>>25
So make one, lazy

28 2021-04-29 20:26

>>24
If you like xscheme, edwin seems right up your alley. I believe the emacs mode is adapted from the REPL functionality of that editor.

29 2023-02-05 17:54

https://youtu.be/OgRFOjVzvm0

30 2023-02-06 09:44

>>1
Isn't that what object oriented programming was purported to achieve?

31


VIP:

do not edit these