Products > Computers
'RACKET' Programming Language. Say-what!?
brucehoult:
There are compilers for a number of other languages that need proper tail-call elimination according to their specification and that compile to C as a portable assembly language. They depend on gcc doing it. The conditions under which gcc will and will not do tail-call elimination are well documented and can be depended on.
Similarly for llvm.
If you use some other C compiler then of course all bets are off.
GlennSprigg:
--- Quote from: janoc on January 26, 2020, 02:05:05 pm ---You are welcome and enjoy your learning experience. Lisp and (Racket specifically) are well known for the ability to define your own languages in them, thanks to the extremely powerful macro system. That's what you are seeing in DrRacket.
Even if you never use functional programming or Lisp "in anger" to solve a real problem, it is always beneficial to learn a different approach to solving problems. It will make you a better programmer/engineer because it adds another set of tools to your professional toolbox.
Btw, that (define x ...) doesn't work for redefining variables is normal. It is not meant to. Redefining variables is a bad practice that leads to buggy code - by redefining a variable you would be essentially saying that: "this train is a bicycle now".
Define binds a symbol to a value (think declaring variable and assigning it an initial value) - i.e. declares a variable. If you try to declare the same variable again, it is an error ("identifier already defined ..."). If you want to perform an assignment (to mutate a value), there is set! instead, which works only on previously defined variables (but then see the part on mutating state and functional programming - it is a poor practice to mutate state unless there is no other way).
--- End quote ---
I understand what you are saying, my friend.
However, when you quoted....
Btw, that (define x ...) doesn't work for redefining variables is normal. It is not meant to. Redefining variables is a bad practice that leads to buggy code - by redefining a variable you would be essentially saying that: "this train is a bicycle now".
That s what I understood/meant about the limitations with the 'Lesser' versions of 'Dr.Racket'.
For instance, the utilization of the likes of (let! ....) Yes, you are FORCING a new value, but in the
'beginner' modes, it is not allowed. Again aimed at instilling 'good' programming styles.
Thanks so much mate!!
frogg:
In reality, the practical features of all lambda languages and functional programming have already been implemented in one way or another by other larger, more commercially pervasive languages.
That's not to say that Lisp / Scheme / Racket are not good languages. However, it's because of the reason above that these languages are nowadays used almost exclusively for teaching purposes.
janoc:
--- Quote from: frogg on January 28, 2020, 04:55:20 pm ---In reality, the practical features of all lambda languages and functional programming have already been implemented in one way or another by other larger, more commercially pervasive languages.
That's not to say that Lisp / Scheme / Racket are not good languages. However, it's because of the reason above that these languages are nowadays used almost exclusively for teaching purposes.
--- End quote ---
You could be quite badly mistaken there with that argument. E.g. Lisp's macro system pretty much doesn't exist in another mainstream language. In C# you get half-assed generics, in C++ messy templates, which are pretty much a second, completely different Turing-complete language implemented inside of C++. In Lisp you have macros written in Lisp itself that work directly at the syntax tree level (because the language source code is effectively its own AST, unlike in e.g. C).
That concept is very much what makes Lisp (and derivatives) so powerful and allows extending the language "from within" - e.g. you like await/async style programming? There is a library for that. You want coroutines? Serve yourself, another library implements them. Etc.
Can you do without it? Sure, there are tools for code generation, even at runtime for other languages too. In the worst case you can always generate a string and call eval() on it. However it makes a big difference whether code generation is an integral part of the language or an error-prone kludge like this.
Also, while Lisp certainly doesn't have the popularity of C, C# or Javascript these days, it is still widely used, both the native Common Lisp implementations and things like Clojure (which runs on top of Java's JVM and interoperates with Java). Just look at the number of job ads looking for Common Lisp/Clojure/AutoLisp programmers.
And when it comes to functional languages as such - Erlang & Elixir are big in telecom industry, Haskell in finance where performance and correctness are kings (it is said that if you get a Haskell program to compile, it is almost certainly going to work correctly due to the extremely strong type system of the language), Scala is widely used in the Java ecosystem, etc.
These are very far from "almost exclusively teaching languages". In fact, the opposite is true - any of the above would be pretty unsuitable as a teaching (not research!) language because they are way too complex for that. You certainly won't find an university using Common Lisp as a Programming 101 language. In fact, this complexity is exactly why Scheme/Racket were originally created - Common Lisp specification is over 1100 pages. Scheme spec is less than 100.
djnz:
Racket (PLT Scheme and the Dr.Scheme environment) was what was used at MIT till the last decade to teach the introductory CS class based on SICP book:
https://mitpress.mit.edu/sites/default/files/sicp/full-text/book/book.html
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version