Racket / Scheme / Lisp

Discussion about hacker.org's server
Post Reply

Do you use Racket / Scheme / Lisp?

No
10
71%
Sometimes
3
21%
My favourite!
1
7%
 
Total votes: 14

outsider
Posts: 35
Joined: Wed Jan 07, 2009 12:15 pm

Racket / Scheme / Lisp

Post by outsider »

Anyone here who uses Racket as their favourite programming language?
After a struggle with VB, Java and C# I switched to Racket and fell in love with it. Expressive, clean and beautiful code, fast compiler, vast API ...

What are your opinions?
AMindForeverVoyaging
Forum Admin
Posts: 496
Joined: Sat May 28, 2011 9:14 am
Location: Germany

Post by AMindForeverVoyaging »

Eh... no, I don't use it. Should probably give it a try. Then again, that is true for many languages.
Seems like I am stuck with C/C++/Java and the like. :-|
outsider
Posts: 35
Joined: Wed Jan 07, 2009 12:15 pm

Post by outsider »

Seems like almost most people don't use Racket or they don't know it ...
Maybe it's time for some advertising :D :

Most of coding is about transforming data. You have input that you give to a function and you get some results back. You don't need much more to build a turing complete language and that leads to lisp (Racket is just the newest dialect of LISP).

In C(++)/Java/Python/JS ... there are multiple ways of calling a function. You can directly call print(), you can use a index-functions: array[], there are infix-operators like +, -, and you have syntax-forms: if, while, case ...

What about unifying all these ways into one? Instead of

Code: Select all

print("hello")
array[4]
3 + 4
if (x>0) {return "pos"} else {return "not-pos"}
you write

Code: Select all

(print "hello")
(vector-ref array 4)
(+ 3 4)
(if (> x 0) "pos" "not-pos")
*Every* concept can be expressed in the form (operator arg1 arg2 arg3 ...) and why not making this resemblance obvious?

We are hackers, aren't we? Most of the challenges of this sites force you to think differently and to overcome habits. We can feel comfortable with something like 12+ for the HVM, so we can with (+ 1 2) and (print "hello").

When you are interested I can explain some more basic concepts of Lisp.
Valar_Dragon
Posts: 21
Joined: Sun Jan 04, 2015 3:34 pm

Post by Valar_Dragon »

I definitely see the semblance to HVM, and I'm willing to adjust my mind to it, but I personally don't feel the need to shift :), thanks for the example though! I wouldn't have checked it out without it!

At least for project-euler like problems, I'd hate to have to keep track of math operations like that, and it also doesn't seem to cater nicely to 'oneliners' for math.

However, I do like the If, Else construct :)
Also the difference with 12+ being 3, versus 1+2, is I can understand the advantage in the 12+ construct from a circuitry perspective, but I can't see the particular advantage +12, since why would the + operand be leading, the ALU wouldn't go into a new 'mode', and you'd need an end databyte(extra memory) to tell when this operator should execute/terminate and return value. Apologies if this seems like an attack on the language that you like, I don't mean it to be that, and Thank you for suggesting it! It made me think more about it, and am gonna try it out this weekend :)
outsider
Posts: 35
Joined: Wed Jan 07, 2009 12:15 pm

Post by outsider »

I'm glad to hear your opinion. Don't be afraid of criticizing lisp - I'm NOT a missioner on some holy ... :)

You are completely right in your two points: Doing arithmetic maths often awkward and the efficiency on hardware-level is low. In both cases I would prefer another tool, maybe Matlab/Mathematica or C.

So what are the highlights of lisp? As a functional language you can define functions on-the-fly. In maths, you write f(x)=4*x and in lisp you write (lambda (x) (* 4 x)). To square the elements of a list '(1 2 3 4) you can write:

Code: Select all

(map (lambda (x) (* x x)) '(1 2 3 4)) -> '(1 4 9 16)
You can also filter them:

Code: Select all

(filter even? '(1 2 3 4)) -> '(2 4)
Post Reply