6 ms·
It's not a PURE functional language, but it's certainly functional.
by jgn 14y ago
It's not a PURE functional language, but it's certainly functional.
- mahmud 14y agoRacket also has an Algol mode :-P
- Locke1689 14y agoIt also has a dataflow language, a typed language, a lazy language, etc. Racket is not one language, it's a language family platform (or language laboratory). Matthias summarized this pretty well[1]. [1] http://www.ccs.neu.edu/home/matthias/Thoughts/Racket_is____.html http://www.ccs.neu.edu/home/matthias/Thoughts/Racket_is____....
- mahmud 14y agoI found that essay most enjoyable. Thank you for the link, mate! :-)
- dsrguru 14y agoThat just becomes a debate about the definition of a functional language. The point is that unlike Haskell, SML, and OCaml (the last two aren't "pure" in the sense of syntactically enforcing referential transparency like Haskell, but they strongly encourage a functional design), Racket is first and foremost a LISP. You can use it to write and make use of a lot of functional abstractions, and it certainly is better suited to that style of programming than C or Java is, but Python and Ruby are just about equally suited for that style of programming, and they even have equivalents of map, filter, fold, lambda, etc. Racket code doesn't look like Haskell, the MLs, or even dynamically typed "functional" languages (like Erlang). It looks like LISP. What drives your coding is not functional abstractions or object-oriented data structures (which it can do equally well) or anything like that. What drives your coding is the fact that syntax itself is a first-class data structure. You have access to the reader. You can write macros that adapt the language to anything you want. You can write a DSL in a few hundred lines that might save you tens of thousands of lines. Now, Racket is certainly good for functional programming. In fact, some Racket developers prefer the Scheme-style tail recursion method of iteration (via the named let or letrec) to the looping constructs provided in the library, even when for loops would be just as effective. In the same way, not all Common Lisp programmers like the loop macro, and some (e.g. pg) actually use Common Lisp in a style that resembles functional programming. However, don't think of Racket as a functional language. That's as misleading as calling C++ a procedural one, even though you could write all your code C-style without ever using objects. Racket is a LISP, which means it can be adapted to fit virtually any paradigm. Racket is far closer to Common Lisp and Clojure than it is to literally any non-LISP.
- Locke1689 14y agoAside from the fact that I still don't think that "a Lisp" is a thing, Racket is not bound to s-expr syntax. The racklog/prolog #langs make that very clear.
- dsrguru 14y agoI'm talking about the racket #lang, not the collection of all languages that the distribution can interpret. R5RS, for example, is included in the distribution, but the R5RS found in the Racket distribution is identical to that of any other Scheme interpreter or compiler, so discussion about its features has nothing to do with discussions specific to Racket. There are also experimental variations of the main racket language like typed racket and lazy racket, but I don't have enough familiarity with them to discuss their classification. I'd assume lazy racket is mainly used in a functional style. But anyway, the main Racket language is very much an s-expression based language (the typed and lazy varieties are as well). What do you mean by not believing in LISP as a classification of languages? Are you saying you don't think s-expression based languages are at least as similar to each other as, say, OOP languages or logic languages are too each other?
- Locke1689 14y agoWhat do you mean by not believing in LISP as a classification of languages? Are you saying you don't think s-expression based languages are at least as similar to each other as, say, OOP languages or logic languages are too each other? I'm saying exactly that. Qi/Shen are basically Haskell with parentheses but because of those parens we call them Lisps. My Scheme->x86 compiler uses an s-expr assembly language as its final IR. That language has about as much in common with Lisp as C does.
- elibarzilay 14y agoAll of this sounds like you're one of these people who see parens and run away screaming "LISP!". Yes, the default Racket syntax uses S-expressions, but concluding that it's in some way lumped with Emacs Lisp is extremely wrong. And yes, Racket has syntax that can be tweaked using macros -- but it's a far stretch to go from this to that being the thing that drives all Racket coding. After all, OCaml now has CamlP4 as something that is an integral part of the language -- does that mean that meta-programming is now the thing that drives OCaml coding??? Another point: yes, Racket programmers know and use tail-calls, but that has nothing to do with "the looping constructs provided in the library" since those are implemented in terms of the same facility. The existence of these loops is therefore not making the language any less functional than the fact that you can implement a while loop in Haskell. The bottom line is that Racket is as functional a language as the interpretation of the term was before Haskell kidnapped it and turned it into some religious point. (BTW, if you want to bash lisps, do yourself a favor and drop the all-caps "LISP" -- it immediately demonstrates the kind of limited knowledge you have on it.)