Common project: learn Racket programming language

  • 21 Replies
  • 7522 Views
*

Zero

  • Eve
  • ***********
  • 1287
Common project: learn Racket programming language
« on: June 26, 2017, 10:35:41 am »
Hi guys,

I want to add Scheme to my toolbox. I began reading Structure and Interpretation Of Computer Programs, but now I want to get my hands dirty.

Racket seems to be a good programming language. Who wants to learn Racket with me? We would read the Racket Guide at the same time, step by step, discuss examples, try things, find other tutorials, ...etc.

So, who's in?  :P

*

Zero

  • Eve
  • ***********
  • 1287
Re: Common project: learn Racket programming language
« Reply #1 on: June 27, 2017, 09:05:54 am »
I'm currently swimming in Racket. Honestly I've rarely seen such a neat and powerful language.

EDIT:
Look ma!
Code
(define make-counter
  (lambda ()
    (let ((n 0))
      (lambda () (set! n (add1 n)) n))))

> (define c1 (make-counter))
> (define c2 (make-counter))
> (c1)
1
> (c1)
2
> (c1)
3
> (c2)
1
> (c2)
2
> (c1)
4
>

Come on guys, water is fresh and fishes are beautiful!!!
« Last Edit: June 27, 2017, 11:57:56 am by Zero »

*

Zero

  • Eve
  • ***********
  • 1287
Re: Common project: learn Racket programming language
« Reply #2 on: June 28, 2017, 09:53:23 pm »
Using Nodejs REPL from inside Racket:
Code
> (define-values (p out in err)
    (subprocess #f #f #f "C:/Hangar/nodejs/node.exe"))
> (display "console.log('hello from node');" in)
> (close-output-port in)
> (read-line out)
"hello from node"
>

*

infurl

  • Administrator
  • ***********
  • Eve
  • *
  • 1372
  • Humans will disappoint you.
    • Home Page
Re: Common project: learn Racket programming language
« Reply #3 on: June 28, 2017, 11:05:54 pm »
Honestly I've rarely seen such a neat and powerful language.

How many languages have you seen?
How many languages have you been using for more than five years?

*

Zero

  • Eve
  • ***********
  • 1287
Re: Common project: learn Racket programming language
« Reply #4 on: June 29, 2017, 07:41:06 am »
Am I supposed to answer gently?  :)

EDIT:

I've seen C, C++, Ada, Python, Prolog, Io, Joy, Forth, Cat, Raven, Om, Brainfuck, Unlambda, False, Thue, Julia, Euphoria, Lua, Angelscript, Scriptbasic, Logo, Smalltalk and others.

I've been using for more than 5 years Locomotive Basic, Turbo Pascal 6, Perl, Javascript, VBA.

What languages have you been using for more than 5 years, infurl?

In your opinion, which languages are more powerful and neat?
« Last Edit: June 29, 2017, 08:53:42 am by Zero »

*

Art

  • At the end of the game, the King and Pawn go into the same box.
  • Trusty Member
  • **********************
  • Colossus
  • *
  • 5865
Re: Common project: learn Racket programming language
« Reply #5 on: June 29, 2017, 03:30:50 pm »
The nice thing I've noticed about "Standards" is that there are so many from which to choose!  ;)

For your amusement or personal satisfaction:

https://en.wikipedia.org/wiki/List_of_programming_languages_by_type
In the world of AI, it's the thought that counts!

*

Zero

  • Eve
  • ***********
  • 1287
Re: Common project: learn Racket programming language
« Reply #6 on: June 29, 2017, 04:50:57 pm »
Yes, it depends on what you're planning to do. Racket is good for me, since I like to play with languages syntax and semantics (one of my favorite (serious) toys is pegjs, a js parsing expression grammar generator).

I can't imagine how many tera-man-hours this programming languages jungle represents...  :o

*

ivan.moony

  • Trusty Member
  • ************
  • Bishop
  • *
  • 1729
    • mind-child
Re: Common project: learn Racket programming language
« Reply #7 on: June 29, 2017, 07:03:22 pm »
There is some vibe in lisp-ish languages that has always been fascinating to me.

*

infurl

  • Administrator
  • ***********
  • Eve
  • *
  • 1372
  • Humans will disappoint you.
    • Home Page
Re: Common project: learn Racket programming language
« Reply #8 on: June 30, 2017, 02:11:15 am »
There is some vibe in lisp-ish languages that has always been fascinating to me.

You are surely right about that. I was programming with Common Lisp professionally for more than 10 years, wrote some very big projects some of which are still running big businesses.

In the end I had to stop using Common Lisp for my AI work because while I could often produce a kickass solution with a few days work, I'd then have to waste months trying to make it fast enough for the intended purpose. It turned out to be a lot quicker to just write it in C in the first place, even if it took three weeks instead of three days to get something working. I still miss Common Lisp though, and would like to have a good reason to go back to it.

*

Zero

  • Eve
  • ***********
  • 1287
Re: Common project: learn Racket programming language
« Reply #9 on: June 30, 2017, 09:28:59 am »
And you didn't find a variant of lisp that would be fast enough? Are they all too slow for your requirements? That's sad... Isn't there a lisp with JIT compilation somewhere?

*

infurl

  • Administrator
  • ***********
  • Eve
  • *
  • 1372
  • Humans will disappoint you.
    • Home Page
Re: Common project: learn Racket programming language
« Reply #10 on: June 30, 2017, 10:12:32 am »
JIT compilers? Haha that's not the issue. There are a number of excellent optimising compilers for Common Lisp, even open source ones such as Steel Bank Common Lisp (SBCL) which you can get from http://www.sbcl.org/

No, the problem is memory management. When you are working with many gigabytes of memory, garbage collection becomes prohibitively expensive and even reusing the same algorithms, you can make enormous performance gains by taking over memory management in ways that are more closely attuned to the problem that you are solving.

*

Zero

  • Eve
  • ***********
  • 1287
Re: Common project: learn Racket programming language
« Reply #11 on: June 30, 2017, 10:51:29 am »
Ok I understand.

*

Zero

  • Eve
  • ***********
  • 1287
Re: Common project: learn Racket programming language
« Reply #12 on: July 01, 2017, 09:46:00 am »
A little Datalog in my Racket:
Code
#lang racket

(require datalog)

(define geo (make-theory))

(datalog geo
         (! (edge a b))
         (! (edge b c))
         (! (edge a d))
         (! (edge b d))
         (! (edge d e))
         (! (edge d f))
         (! (edge f g))
         (! (:- (path X Y) (edge X Y)))
         (! (:- (path X Y) (edge X Z) (path Z Y))))

> (datalog geo (? (path X g)))
'(#hasheq((X . f)) #hasheq((X . a)) #hasheq((X . b)) #hasheq((X . d)))


*

Zero

  • Eve
  • ***********
  • 1287
Re: Common project: learn Racket programming language
« Reply #13 on: July 04, 2017, 11:20:20 am »
Remember how stuff was defined...
Code
#lang racket

(define user-function (make-hash))

(define (definition id)
  (hash-ref user-function id))

(define-syntax-rule (define/keep id expr)
  (begin
    (hash-set! user-function 'id 'expr)
    (define id expr)))


> (define/keep double (lambda (x) (* 2 x)))
> (double 5)
10
> (definition 'double)
'(lambda (x) (* 2 x))
> (eval (list (definition 'double) 10))
20
>

*

Zero

  • Eve
  • ***********
  • 1287
Re: Common project: learn Racket programming language
« Reply #14 on: July 16, 2017, 02:36:47 pm »
Well, I'm fed-up.

I think it really became obvious when I had to explicitly state that I wanted my struct to be mutable. I don't feel the sexy' anymore.

And by the way, Javascript is homoiconic too. Yeah, the code can be represented by strings! Or the AST by an object.

Lispish feels old. No offence, it's purely personal taste. And, starting a lot of parens at the beginning of something, whitout knowing which goes where, really doesn't feel right.

 


LLaMA2 Meta's chatbot released
by spydaz (AI News )
August 24, 2024, 02:58:36 pm
ollama and llama3
by spydaz (AI News )
August 24, 2024, 02:55:13 pm
AI controlled F-16, for real!
by frankinstien (AI News )
June 15, 2024, 05:40:28 am
Open AI GPT-4o - audio, vision, text combined reasoning
by MikeB (AI News )
May 14, 2024, 05:46:48 am
OpenAI Speech-to-Speech Reasoning Demo
by MikeB (AI News )
March 31, 2024, 01:00:53 pm
Say good-bye to GPUs...
by MikeB (AI News )
March 23, 2024, 09:23:52 am
Google Bard report
by ivan.moony (AI News )
February 14, 2024, 04:42:23 pm
Elon Musk's xAI Grok Chatbot
by MikeB (AI News )
December 11, 2023, 06:26:33 am

Users Online

305 Guests, 0 Users

Most Online Today: 464. Most Online Ever: 2369 (November 21, 2020, 04:08:13 pm)

Articles