Re:Probabilistic Models of Cognition
by tbenst on Thursday February 02, 2017 @11:29AM
(#13551764)
Just a heads up that church has now been replaced by webppl: http://webppl.org.
[ Parent
| on HN ]
Indeed. And there is now a webppl version of the probmods textbook: http://probmods.org/v2
Re:Probabilistic Models of Cognition
by wodenokoto on Friday February 03, 2017 @03:15AM
(#13558500)
Thank you for sharing. I have tried completing probmods twice, but gone sour in the syntax twice.
Third times the charm :)
You mean replaced as a language, or just replaced in a new version of the book?
Either way, :(.
Both. (source: I've worked on both languages and versions of the book).
But give webppl a shot -- it's a good language!
Re:Probabilistic Models of Cognition
by shanusmagnus on Thursday February 02, 2017 @03:05PM
(#13554082)
Curious -- do you have any insider perspective on the reason for the changeover from Church?
A non-exhaustive list:
1. Pedagogically, the lispy syntax was a big stumbling block for beginners. Probabilistic programming is hard enough as it is; prefix notation and parens only added difficulties (and these difficulties were unrelated to the conceptual material).
2. webchurch compiled to Javascript anyway, so it was nice to be closer to the target language.
3. Lisp can be a bit awkward for certain contemporary programming idioms (e.g., accessing object properties).
Re:Probabilistic Models of Cognition
by kazinator on Thursday February 02, 2017 @09:36PM
(#13557180)
Some Lisp designers are listening:
$ cat animal.tl
(defstruct animal nil
(:static legs nil)
(:method speak (self something)
(pprinl something)))
(defstruct dog animal
(:static legs 4)
(:method speak (self something)
(call-super-method self 'speak something)
(pprinl "Woof!")))
$ txr -i animal.tl
1> (defvar d1 (new dog))
d1
2> (defvar d2 (new dog))
d2
3> d1.legs
4
4> (set d2.legs 5) ;; legs is static: i.e. class-wide
5
5> d1.legs ;; all dogs have 5 legs now
5
6> d1.(speak "hey!")
hey!
Woof!
"Woof!"
7>
Next: 7> 'a.b.c.d
a.b.c.d
8> (car 'a.b.c.d)
qref
9> (cdr 'a.b.c.d)
(a b c d)
10> '(qref a b c d) ;; qref ::= "qualified reference"
a.b.c.d
11> '(qref a b (c x y) d)
a.b.(c x y).d
12> '(qref (qref a b) c)
(qref a.b c)
qref is syntax, targetted by a macro definition: 13> (macroexpand '(qref a b c))
(slot (slot a 'b)
'c)
We can hijack it in data for our own use: 14> '(www.google.com "blah")
(www.google.com "blah")
15> (caar '(www.google.com "blah"))
qref
16> (cdar '(www.google.com "blah"))
(www google com)
The TXR Lisp scripting language removes most of the Lisp micro-stumbling-blocks in everyday coding, providing the above notation, plus array access with ranges, and nice "string quasiliteral" notation for interpolated strings. 17> [mapcar succ "abcd"]
"bcde"
18> ["abcdefg" 0]
#\a
19> ["abcdefg" 0..3]
"abc"
20> ["abcdefg" -2..:]
"fg"
21> (car 'a..b)
rcons
22> (cdr 'a..b)
(a b)
23> '(rcons a b)
a..b
24> (rcons 1 2)
#R(1 2)
25> ["abcd" #R(1 3)]
"bc"
26> ["abcde" '(0 2 4 6)]
"ace"