Live data from Hacker News

A Friendly Introduction to Racket

geometridae.bearblog.dev

141–150 of 195 posts

Re: A Friendly Introduction to Racket

#141

Earlier quoted context omitted.

miniKanren is a replacement for a Prolog like a shitty tree-walking sexpr interpreter that doesn't even have modules is a replacement for Racket. I don't even know what to say to you for suggesting that, frankly. Anyways the embedded inference engine as an idea failed a long time ago, Americans convinced themselves it was the way to do things and just refused to ever let it go. It's just extra baggage on the importan…

Instead of us two milling about: https://minikanren.org/minikanren-and-prolog.html (and this is both informed and pretty impartial from what I can read)

I don't see where the above says that Prolog is a "poor general purpose language"? I'd instead say that claim is incompatible with the following paragraphs that rather sing the praises of Prolog as a programming language:

Prolog is one of the two classic languages for symbolic artificial intelligence programming (the other classic language being Lisp). Prolog excels at implementing symbolic rule-based systems in which declarative knowledge is encoded in first-order logic. The language is optimized for expressiveness and efficiency for these types of applications, sometimes at the expense of logical purity. For example, by default Prolog does not use the "occur check" in unification. From a math/logic standpoint, this version of unification is incorrect. However, the occur check is expensive, and in most cases the lack of the occur check is not a problem. This is a very pragmatic design decision, as is Prolog's use of depth-first search, and use of cut (!) to control backtracking. I'm sure these decisions were absolutely necessary when running on the hardware of the 1970s, and today are very useful when working on large problems, and when dealing with huge (often infinite!) search spaces.

Prolog supports many "extra-logical" or "non-logical" features, including cut, assert and retract, projection of variables for arithmetic using is, and so forth. Many of these features make it easier to express complex control flow, and to manipulate Prolog's global database of facts. One very interesting feature of Prolog is that Prolog code is itself stored in the global database of facts, and can be queried against at run time. This makes it trivial to write meta-interpreters that modify the behavior of Prolog code under interpretation. For example, it is possible to encode breadth-first search in Prolog using a meta-interpreter that changes the search order. This is an extremely powerful technique that is not well known outside of the Prolog world. 'The Art of Prolog' describes this technique in detail.

Tremendous effort has gone into improving Prolog implementations, most of which are based on the Warren Abstract Machine (WAM). The WAM uses a side-effecting model in which values are destructively assigned to logic variables, with these side-effects being undone upon backtracking. Many features can be added to Prolog by extending the instructions of the WAM. One disadvantage of this approach is that Prolog implementation papers can be difficult to read without a solid understanding of the WAM. On the other hand, Prolog implementer have a common model for discussing implementation issues. There has been a great deal of research in parallel Prolog, culminating in Andorra Prolog in the 1990s. At least some of these ideas live on in Ciao Prolog. (Ciao Prolog is full of interesting ideas, many of which go far beyond the Prolog standard.)

Prolog has a beautiful unification-based "pattern-matching"-style syntax that results in very succinct programs. Prologers love their syntax, just like Lispers love their s-expressions. Prolog also has a large library of standard predicates. Due to all of the engineering that has gone into making the WAM fast, there are very capable and mature Prolog implementations. As a result, many large knowledge-based systems have been written entirely in Prolog.

So, why do you say that Prolog is a "poor general purpose language"?

Re: A Friendly Introduction to Racket

#142

Earlier quoted context omitted.

Isn't at least one of them undefined? `(1 ,@2) It's always surprising to me how many things Scheme leaves undefined. Other examples are evaluation order (in some rather surprising places) or the value of: (make-bytevector 4)

> `(1 ,@2) '(1 . 2) This is a pair. The notations is called "dotted pair".

But 2 isn't a list, and the argument to unqoute-splicing must be a list:

> If an (unquote-splicing ...) form appears inside a , then the s must evaluate to lists; the opening and closing parentheses of the lists are then “stripped away” and the elements of the lists are inserted in place of the unquote-splicing form.

Re: A Friendly Introduction to Racket

#143

Earlier quoted context omitted.

Isn't at least one of them undefined? `(1 ,@2) It's always surprising to me how many things Scheme leaves undefined. Other examples are evaluation order (in some rather surprising places) or the value of: (make-bytevector 4)

> `(1 ,@2) '(1 . 2) This is a pair. The notations is called "dotted pair".

Looks like fweimer is correct for scheme. I admit to being very surprised. Here is the verbiage from various rXrs:

r3rs, r4rs & r5rs (section 4.2.6):

https://standards.scheme.org/official/r3rs.pdf

https://standards.scheme.org/official/r4rs.pdf

https://conservatory.scheme.org/schemers/Documents/Standards...

"If a comma appears followed immediately by an at- sign (@), then the following expression must evaluate to a list;"

r6rs (section 11.17):

https://standards.scheme.org/official/r6rs.pdf

"If an (unquote-splicing 〈expression〉 . . . ) form appears inside a〈qq template〉, then the〈expression〉s must evaluate to lists;"

r7rs (4.2.8):

https://standards.scheme.org/official/r7rs.pdf

"If a comma appears followed without intervening whitespace by a commercial at-sign (@), then it is an error if the following expression does not evaluate to a list;"

Re: A Friendly Introduction to Racket

#144

Earlier quoted context omitted.

> `(1 ,@2) '(1 . 2) This is a pair. The notations is called "dotted pair".

But 2 isn't a list, and the argument to unqoute-splicing must be a list: > If an (unquote-splicing ...) form appears inside a , then the s must evaluate to lists; the opening and closing parentheses of the lists are then “stripped away” and the elements of the lists are inserted in place of the unquote-splicing form.

See https://docs.racket-lang.org/reference/quasiquote.html#%28fo...

Re: A Friendly Introduction to Racket

#145

Earlier quoted context omitted.

> `(1 ,@2) '(1 . 2) This is a pair. The notations is called "dotted pair".

Looks like fweimer is correct for scheme. I admit to being very surprised. Here is the verbiage from various rXrs: r3rs, r4rs & r5rs (section 4.2.6): https://standards.scheme.org/official/r3rs.pdf https://standards.scheme.org/official/r4rs.pdf https://conservatory.scheme.org/schemers/Documents/Standards... "If a comma appears followed immediately by an at- sign (@), then the following expression must evaluate to a li…

You need to use the Racket documentation.

Re: A Friendly Introduction to Racket

#146
post #126

On a more personal note, for some weird reason, Racket ended up being the language that got me one of my most important contracts. Through a whole series of butterfly-effect events, that eventually led me into CAD software development, which is where I discovered my love for metamaterials. It’s funny how these things happen!

because autocad is scripted in lisp ?

Never touched AutoCAD, I know they have autoLISP , but yeah maybe

Re: A Friendly Introduction to Racket

#147

Earlier quoted context omitted.

Instead of us two milling about: https://minikanren.org/minikanren-and-prolog.html (and this is both informed and pretty impartial from what I can read)

I don't see where the above says that Prolog is a "poor general purpose language"? I'd instead say that claim is incompatible with the following paragraphs that rather sing the praises of Prolog as a programming language: Prolog is one of the two classic languages for symbolic artificial intelligence programming (the other classic language being Lisp). Prolog excels at implementing symbolic rule-based systems in whic…

That link wasn't an argument to support my claim, just a related comparison.

> So, why do you say that Prolog is a "poor general purpose language"?

Big disclaimer: I have almost no Prolog experience beyond a distant university class, so I've no idea what's possible with a pragmatic impl. like SWI-Prolog. Still, this is my uninformed "Emacs vs vim tier" opinion.

For the same reason as most other people do so: when you're not working with problems suited for it (most of them), Prolog loses much of its power and intuitiveness to become a barebones functional PL without much going for it (needing lots of extensions beyond ISO); bit like Erlang outside distributed/high availability situations. The other way is going full "hammer and nails" and try to hamfist every problem into a logic/declarative one.

Re: A Friendly Introduction to Racket

#148

> no special syntax for anything. (list '(1. . #\#) -5/6+7.s-8i `(1 ,@2) 1@1 ;hmmm, no unquote splicing comma ;-) 10# ;surprised? (list #i+1 +1i 1+i) ;complicated or complex? #e-1e10i ;Old MacDonald? "(* 9 10)" #())

I think you clearly exposed one of the things that I couldn't never describe why I wasn't dragged into Racket/scheme. It's not only annoying is hard to remember all these differences. Obviously the more you use the language these go away but still at least to me it doesn't seem to be a coherent syntax.

Well, to be fair, many/most programs aren't using complex numbers, or concerned with inexact vs. exact numbers, significant digits, or really even scientific notation.

Re: A Friendly Introduction to Racket

#149
post #11

Much as I am a fan of Racket, this is not a friendly intro. It is a speedrun. When an introduction says “friendly”, I don’t expect it to assume that I know what lambda is. When an introduction says “friendly”, I don’t expect syntax rules to appear in it. At all.

Agreed. As someone who hasn’t used Racket it wasn’t clear to me why syntax rules needed to be used over a simple define or what syntax rules even did that define didn’t.

Re: A Friendly Introduction to Racket

#150
post #99

Earlier quoted context omitted.

Most Emacs users I personally know simply treat it as an editor. They're not really aware how it works under the hood.

Still doubt, that they are unaware of Elisp. Bare bones vanilla Emacs is maybe a bit much to get used to these days, so anyone wanting to configure their Emacs will have opened their init.el or so file and will have put some Elisp snippets there.

I've helped such people with their configs. They just know it as "commands" they put in the init file - they don't think of it as a programming language. It's rare for simple init.el files to have things like functions, loops, etc.

And, to be frank, most of them don't customize the init.el file. They just want a text editor - not an IDE. The defaults are ugly, but they're perfectly functional.

None of these people customized Notepad or any other editor either. They're simply solving the problem of "I've SSH'ed into a remote machine. How do I edit this file?"

Post reply on HN