Guh, someday I am going to have to learn that bracket-based syntax (lisp?) that keeps popping up on particularly interesting projects but I can never be bothered to learn.
Programming
Welcome to the main community in programming.dev! Feel free to post anything relating to programming here!
Cross posting is strongly encouraged in the instance. If you feel your post or another person's post makes sense in another community cross post into it.
Hope you enjoy the instance!
Rules
Rules
- Follow the programming.dev instance rules
- Keep content related to programming in some way
- If you're posting long videos try to add in some form of tldr for those who don't want to watch videos
Wormhole
Follow the wormhole through a path of communities !webdev@programming.dev
it's as simple as
(command argument0 argument1 argument2)
meaning arguments 0, 1 and 2 are applied to command. when an expression is evaluated it dissolves into a value according to its context.
(+ 1 2 3)
; evaluates to 6 in a context where + actually means an addition or sum operation
(* 2 (+ 4 3))
; evaluates to 14 (i think)
the absolute killer feature is the elimination of idiotic, man-made madness excused with the term "operator precedence"
It’s actually really easy.
Plus, any good editor will arrange the indentation to make nesting clear. For experienced Lisp / Scheme programmers, the parens nearly disappear, like commas or semicolons for c++ programmers.
Somehow it's not the bracket syntax that stopped me.
It's the amount of dialects LISP has. Way too many of it. I don't know where to start
As a first approximation, there is not much to learn. The lisp syntax thing is a scarecrow for the uninformed
In Python, you write:
a = atan2(x, y)
b = sin(x)
c = b if x > a else 1
# use values of a, b and c here
Where the indentation is a block.
In Scheme, you write:
(let ((a (atan2 x y))
(b (sin x))
(c (if (> x a) b 1)))
; use values of a, b, and c here
)
Where the outer paren around "let" determines the scope of the binding, and the scope serves as an expression with a value (like in Rust), and scopes can be nested arbitrarily deep.
Other great resource is guix shell: Overview by Andrew.
Although, one thing I'm still trying to understand is the difference between guix.scm and manifest.scm... The posted article only mentions guix.scm, but Andrew talks about both. But... he doesn't really go into why there are two files and when you would use one or the other...
This is similar using nix: https://devenv.sh/
It has a few more features like git hooks and spinning up long-running processes like web servers