Common project: learn Racket programming language

  • 21 Replies
  • 686 Views
*

Zero

  • Trusty Member
  • *******
  • Starship Trooper
  • *
  • 292
  • Fictional character
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
PRO|STAMINA [ programming game ]

*

Zero

  • Trusty Member
  • *******
  • Starship Trooper
  • *
  • 292
  • Fictional character
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: [Select]
(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 »
PRO|STAMINA [ programming game ]

*

Zero

  • Trusty Member
  • *******
  • Starship Trooper
  • *
  • 292
  • Fictional character
Re: Common project: learn Racket programming language
« Reply #2 on: June 28, 2017, 09:53:23 pm »
Using Nodejs REPL from inside Racket:
Code: [Select]
> (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"
>
PRO|STAMINA [ programming game ]

*

infurl

  • Trusty Member
  • *******
  • Starship Trooper
  • *
  • 258
  • 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

  • Trusty Member
  • *******
  • Starship Trooper
  • *
  • 292
  • Fictional character
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 »
PRO|STAMINA [ programming game ]

*

Art

  • At the end of the game, the King and Pawn go into the same box.
  • Global Moderator
  • ******************
  • Hal 4000
  • *
  • 4366
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

  • Trusty Member
  • *******
  • Starship Trooper
  • *
  • 292
  • Fictional character
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
PRO|STAMINA [ programming game ]

*

ivan.moony

  • Trusty Member
  • ********
  • Replicant
  • *
  • 684
  • look, a star is falling
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

  • Trusty Member
  • *******
  • Starship Trooper
  • *
  • 258
  • 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

  • Trusty Member
  • *******
  • Starship Trooper
  • *
  • 292
  • Fictional character
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?
PRO|STAMINA [ programming game ]

*

infurl

  • Trusty Member
  • *******
  • Starship Trooper
  • *
  • 258
  • 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

  • Trusty Member
  • *******
  • Starship Trooper
  • *
  • 292
  • Fictional character
Re: Common project: learn Racket programming language
« Reply #11 on: June 30, 2017, 10:51:29 am »
Ok I understand.
PRO|STAMINA [ programming game ]

*

Zero

  • Trusty Member
  • *******
  • Starship Trooper
  • *
  • 292
  • Fictional character
Re: Common project: learn Racket programming language
« Reply #12 on: July 01, 2017, 09:46:00 am »
A little Datalog in my Racket:
Code: [Select]
#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)))

PRO|STAMINA [ programming game ]

*

Zero

  • Trusty Member
  • *******
  • Starship Trooper
  • *
  • 292
  • Fictional character
Re: Common project: learn Racket programming language
« Reply #13 on: July 04, 2017, 11:20:20 am »
Remember how stuff was defined...
Code: [Select]
#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
>
PRO|STAMINA [ programming game ]

*

Zero

  • Trusty Member
  • *******
  • Starship Trooper
  • *
  • 292
  • Fictional character
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.
PRO|STAMINA [ programming game ]

 


Users Online

18 Guests, 1 User
Users active in past 15 minutes:
Freddy
[Administrator]

Most Online Today: 29. Most Online Ever: 208 (August 27, 2008, 09:36:30 am)

Articles