Live data from Hacker News

A Friendly Introduction to Racket

geometridae.bearblog.dev

81–90 of 195 posts

Re: A Friendly Introduction to Racket

#82
post #78

> 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)" #())

You forgot hash table and regular expression literals.

It looks like Racket nerfed the shared-structure / "Datum Labels" for circular lists and the like (I see it is still in section 2.4 of r7rs):

  '#0=(0 . #0#)
...and I should have included `#|block comments|#`, datum `#;comments`, and probably `|symbols with spaces|`.

  (let ((|1 + 2| (+ 1 2)))
    (display |1 + 2|))

Re: A Friendly Introduction to Racket

#83
As the article correctly mentions, Lisp as a concept is much older than any of the popular languages used these days; so are the attempts to get more people use it. Most of them are, unfortunately, unsuccessful, because it's probably impossible to understand Lisp after a quick and friendly introduction.

I first met Common Lisp during my college years in early 2000s: we had an enthusiast teacher who taught it for free, in his free time; it was interesting for me as a freshman to learn something new, but also I literally had no idea how to write Lisp code properly, without resorting to using `progn` here and there. For those not aware, `progn` is a form that allows you to write expressions in a sequential way, pretty much like you use the C compound statement, a `{ ... }` block. It works, and after some time you find that you're writing in some crappy imperative programming language with a lot of brackets but you don't learn much about the functional programming.

It took me more than a year, and definitely more than any short “friendly introduction”, to understand the functional approach.

Now, Racket. I first noticed it while doing my daily LeetCode; they added Racket as a supported language and you can go use it to solve a task. After not using Lisp for 20-something years, I appreciated the opportunity, but I found the type contract syntax infuriating. This is LeetCode #1, “Two sum”:

  (define/contract (two-sum nums target)
    (-> (listof exact-integer?) exact-integer? (listof exact-integer?))
    )
I don't know what you feel, but this makes me want to close this tab and never return. So if I find myself wanting to write some Lisp and there's a daily LeetCode task I want to solve, the first thing I do is I delete all this garbage and come back to the clean option:

  (define (two-sum nums target) ...)
which, except for the minor syntax differences, brings me back to my college Lisp years and I can actually enjoy it.

Re: A Friendly Introduction to Racket

#85
post #78

Earlier quoted context omitted.

You forgot hash table and regular expression literals.

It looks like Racket nerfed the shared-structure / "Datum Labels" for circular lists and the like (I see it is still in section 2.4 of r7rs): '#0=(0 . #0#) ...and I should have included `#|block comments|#`, datum `#;comments`, and probably `|symbols with spaces|`. (let ((|1 + 2| (+ 1 2))) (display |1 + 2|))

That has been in Racket for a long time.

Re: A Friendly Introduction to Racket

#87
post #38

Earlier quoted context omitted.

C has homoiconicity: you can represent C source code as C strings.

You can show this is possible, but it is extremely onerous in comparison.

see also:

https://wiki.c2.com/?GreenspunsTenthRuleOfProgramming

Re: A Friendly Introduction to Racket

#88

Earlier quoted context omitted.

It looks like Racket nerfed the shared-structure / "Datum Labels" for circular lists and the like (I see it is still in section 2.4 of r7rs): '#0=(0 . #0#) ...and I should have included `#|block comments|#`, datum `#;comments`, and probably `|symbols with spaces|`. (let ((|1 + 2| (+ 1 2))) (display |1 + 2|))

That has been in Racket for a long time.

I tried:

  #lang racket/base
  (let ((a '#0=(0 . #0#)))
    (display (car a)))
...over at

https://onecompiler.com/racket

...and it didn't compile, complaining:

  read-syntax: `#...=` forms not  enabled for `read-syntax` mode
...maybe there is a switch needed to enable it?

Re: A Friendly Introduction to Racket

#89
post #16

While the language is interesting, sadly, nobody is using it in the wild. Maybe due to cumbersome deployment options? The ability to produce native standalone executables would boost its usage I believe.

I wrote my own AI coding harness in Racket, it works fine, meets my own needs. I did earlier versions in Common Lisp and Python but the Racket version is the most full featured.

Re: A Friendly Introduction to Racket

#90

Earlier quoted context omitted.

That has been in Racket for a long time.

I tried: #lang racket/base (let ((a '#0=(0 . #0#))) (display (car a))) ...over at https://onecompiler.com/racket ...and it didn't compile, complaining: read-syntax: `#...=` forms not enabled for `read-syntax` mode ...maybe there is a switch needed to enable it?

I am not 100% sure what's going on, but you can use `read` mode this way:

    #lang racket
    (let ((a (read (open-input-string "#0=(0 . #0#)"))))
      (display (car a)))
I think the problem is that `read` / `write` support shared data constructed using `shared`. But programs (read by `read-syntax` are not allow to have cycles.
Post reply on HN