11 ms·
Why I haven't jumped ship from Common Lisp to Racket just yet
- peatmoss 9y agoI really like this article, because it manages to be a love letter to both Racket and Common Lisp.
- mjmein 9y agoRacket is a really exciting language, especially with its focus on building small languages to solve problems. However, where it fails for me is in its lack of interactive development. When I investigated it, there seemed to be no way to actually connect a repl to a running program. Unlike with common lisp or clojure, with racket if you make changes to your code you have to restart the REPL, which destroys your state. This was a big disappointment to me, because even python with ipython and autoreload allows for more interactive development. I suspect that this decision was made because of racket's start as a teaching language, because it is simpler, but way less powerful.
- sigstoat 9y ago> When I investigated it, there seemed to be no way to actually connect a repl to a running program. i (poorly) implemented conditions for racket once, including the ability to drop into a repl at the point of error. so i think you could put in place some macros that would let you get at a repl wherever you wanted. probably not the sort of thing to leave in place all the time, though > Unlike with common lisp or clojure, with racket if you make changes to your code you have to restart the REPL, which destroys your state. that's a different issue. i believe matthias has commented on the mailing list (some years back) that the semantics associated with doing something like that are a mess, and that's why they weren't interested in implementing it.
- mjmein 9y agoTo me, being able to make changes to your code while keeping the current state in the REPL is key to interactive development. My workflow is generally to build up state, and then experiment with functions on that state until I get the correct output. This workflow is very natural in Clojure, Common Lisp and even Python (with IPython and autoreload). However, in Racket you have to restart everything on every change. This works ok for smaller applications, but if for example, your state is a large dataset that you pull from a remote database, it becomes a little more difficult. There are possibly workarounds, and I'm not saying that Racket is bad because of this. There are definite advantages to this approach, mainly for keeping everything simple and predictable. However, this was a roadblock for me, and the main reason why I didn't spend more time working on it. I also miss the ability to make changes to code, refresh the browser and instantly see the changes (instead of having to restart the server after each change). Here's a good discussion (in my opinion) of what makes a good REPL for interactive development: http://vvvvalvalval.github.io/posts/what-makes-a-good-repl.html http://vvvvalvalval.github.io/posts/what-makes-a-good-repl.h...
- stonemetal 9y agoIt isn't in DrRacket by default but it is a common enough requested feature that they keep an example of how to add it in the documentation. https://docs.racket-lang.org/drracket/Keyboard_Shortcuts.html#%28part._.Sending_.Program_.Fragments_to_the_.R.E.P.L%29 https://docs.racket-lang.org/drracket/Keyboard_Shortcuts.htm...
- mjmein 9y agoThanks. Do you know if it works with the module system - for example, if I edit function definition in a module, and then send that module definition to the REPL, would any code using that module start using the new definition?
- bad_login 9y agoIt works in geiser-mode, i don't know if it works with drracket or racket-mode. http://docs.racket-lang.org/guide/eval.html?q=namespace#%28part._.Namespaces_and_.Modules%29 http://docs.racket-lang.org/guide/eval.html?q=namespace#%28p...
- sillysaurus3 9y agoI'm surprised no one has mentioned geiser. It sounds like exactly what you want for racket. http://nongnu.org/geiser/geiser_3.html http://nongnu.org/geiser/geiser_3.html
- maxiepoo 9y agoI believe this is a design decision, because relying on some enormous implicit repl state and updating the code in place is a good way to get yourself into states that are impossible to reach in an actual running program. Racket is a functional language and it is their belief that you should just make predictable ways to startup your interactive development than rely on the entire state of some repl image.
- pera 9y agoI'm not sure if this is exactly what you are talking about, but with racket-mode in Emacs you can write some program, run it (C-c C-k), then add some s-expr and evaluate only that (C-x C-e) in the current context.
- mikelevins 9y agoYou're right; it's a conscious decision. I had a little discussion with Eli Barzilay and Matthew Flatt about some related matters a little while back. It was a nice discussion, but image-based or live programming is just not something they found particularly compelling. It pretty much keeps me from using Racket, and a bunch of other things that are otherwise very nice. Given a choice, I will always choose the tools that support me in building things by modifying programs as they run. I'm just happier and more productive that way. So one of my axes of optimization is selecting projects that enable me to work that way.
- mjmein 9y agoMy thoughts exactly. Once you are used to this way of developing, it is really difficult to be happy with less.
- maxiepoo 9y agoAh yes, I remember seeing an interaction that was probably yours, tried to find it for my comment, but never did.
- elibarzilay 9y ago
- i_feel_great 9y agoThat Racket module functionality where you can add unit tests right with your code ("module+"), but will get stripped when compiled - that thing is quite magical. Is there another system that has this?
- thescribe 9y agoI don't think it is an official part of the language but the Pragmatic Programmers Elixir book does this in one of their examples code sections.
- bglusman 9y agoIt is an official part of the language, and is automatically part of the compiled docs, which are also an official part of the language! https://elixir-lang.org/getting-started/mix-otp/docs-tests-and-with.html#doctests https://elixir-lang.org/getting-started/mix-otp/docs-tests-a...
- deckiedan 9y agoRust. https://doc.rust-lang.org/book/second-edition/ch11-03-test-organization.html https://doc.rust-lang.org/book/second-edition/ch11-03-test-o...
- bglusman 9y agoFrom thescribe's parallel comment it sounds like you're describing doctests which is a built in feature in Elixir, and I believe in Python also. Many languages have doctest libraries available, though not many support it being part of canonical documentation... I've been meaning to try the ruby-rspec doctest library https://github.com/doctest/doctest-rspec https://github.com/doctest/doctest-rspec though there's several others besides that one
- zem 9y agohttps://dlang.org/spec/unittest.html https://dlang.org/spec/unittest.html for D
- farray 9y agoInterestingly, I just added a section on Gerbil, the Lisp dialect I have adopted instead of PLT, for many personal reasons.
- bad_login 9y agoWhat is your setup working with gerbil compared to emacs/slime?
- farray 9y agoMy current setup does not compare favorably with Emacs/slime at this point. I use screen, I call a build script in one shell REPL, I use gerbil-mode in Emacs in the other, reload'ing things that I rebuild, or restarting the M-x run-scheme when too much has changed, copy-pasting from a gerbil-scratch.ss file, or repeatedly loading a .ss file with on-going tests. This is less than satisfactory. We hope to improve the situation this year so we can use geiser or slime or something similar.
- jlarocco 9y agoI use Common Lisp quite a bit, and I'm just not interested in switching to another Lisp. I've looked at most of them, and haven't seen anything compelling. CL still wins on everything that I care about (performance, portability, libraries, ease of use, books/documentation, etc.). Even the article's list of areas where Racket is "vastly superior" is questionable, IME. Granted, the author wrote ASDF, so he has a very different perspective than I do on the module system, but in practice nothing on that list has been a problem for me, and a few of them I'd actually consider to be anti-features (like a built-in GUI library).
- criddell 9y agoWhat domains are you using CL in? The last time I used a Lisp was inside AutoCAD and it was a lot of fun.
- jlarocco 9y agoAt work I mainly write C++, but I have a little library in CL that I've been working on for a while that can call our REST API, access and filter our log files, connect to our test infrastructure, and some other miscellaneous stuff. It started because I wanted to call our product's REST API from inside Emacs (in the Slime REPL) to make debugging and testing easier, but over time it's grown to about 1500 lines of CL to automate common tasks. Outside of work it's my go-to language for learning new stuff. I use it for a bunch of little programming projects that I put on Github (https://github.com/jl2?tab=repositories https://github.com/jl2?tab=repositories). They're mostly just playing around with whatever topic I'm interested in at a given time. Lots of animations and (simple) computer graphics, some simple games, one or two libraries for the Raspberry Pi, etc. Nothing too exciting. I want to start contributing to some of the open source libraries and projects (like stumpwm and sbcl) that I use a lot, but so far the few commits I've made to other projects have been really small bug fixes or trivial documentation fixes.
- ClFromEmacs 9y agoDo you run items in CL that return to an emacs buffer? Like say, slime-eval/run? Or are these just run in the repl itself and displayed there? Been toying with making some async stuff run via swank/slime and then display in emacs in a custom mode and buffer.
- flavio81 9y agoThe author, a famous and well-liked lisper, is not consider ing portability features. CL is an ANSI standard and code often runs with no changes in many distinct CL implementations/compilers/interpreters. Also, related to that point: There are many different CL implementations out there that satisfy different use cases, like for example JVM deployment (ABCL), embedded systems (ECL), speed(SBCL), fast compile times (Clozure), pro-level support (LispWorks, ACL), etc. So the same code has a huge amount of options for deployment. It really makes Common Lisp be "write once, run anywhere". Then speed is also never mentioned. Lisp can be seriously fast; under SBCL it is generally 0.3x to 1x C speed; LispWorks might be faster, and there's a PDF out there called "How to make Lisp go faster than C", so that should give an idea of Lisp speed potential. CL wasn't created by philosophing about what a programming language should be for many years; CL was basically created by merging Lisps that were already proven in the industry (Maclisp, Zetalisp, etc), already proven to be good for AI, heavy computation, symbolic computation, launching rockets, writing full operating systems, etc. CL is a "you want it, you got it" programming language. You want to circumvent the garbage collector? need to use GOTOs for a particular function? want to produce better assembly out? need side effects? Multiple inheritance? Want to write an OS? CL will deliver the goods. In short, i would guess that from a computer scientist or reseacher point of view, Racket is certainly more atttactive, but for the engineer or start-up owner that wants to have killer production systems done in short time, or to create really complex, innovative systems that can be deployed to the real world, Common Lisp ought to be the weapon of choice!
- cwyers 9y ago> Then speed is also never mentioned. What? There's five points on the numbered list, #4 is entirely about speed.
- flavio81 9y agoSorry. Speed is mentioned but overlooked, because the figures are not mentioned. It should be 2x-8x speed increase in favor of CL. For some people this truly doesn't matter (after all, Ruby is successful and loved), for other applications, it does matter a lot.
- 9y ago
- zerr 9y agoAnyone using Racket in the wild? (Besides the Racket team)
- sclangdon 9y agoI believe some games companys use it. Naughty Dog of Uncharted and The Last of Us fame, being the most famous. I think they used it to create some game logic DSL or something of that sort. More info here - https://www.reddit.com/r/Racket/comments/5g8xse/are_there_any_examples_of_racket_being_used_in/daqliyf/ https://www.reddit.com/r/Racket/comments/5g8xse/are_there_an...
- _delirium 9y agoHacker News runs on Racket. :-)
- flavio81 9y agowasn't HN in Arc?
- farray 9y agoAnd what is Arc in?
- _pmf_ 9y agoAh, Arc, the No Man's Sky of Lisp derivatives
- flavio81 9y agoThe CPython JIT/compiler is written in C. Does this mean that a Python program is then a C program? Arc is not Racket.
- _delirium 9y agoI suppose the original poster could clarify whether they were interested primarily in examples of the Scheme-derivative language "Racket" being used in production, or in the system/VM/runtime "Racket" being used in production. Since Racket (the system) now makes it very easy to define new languages on top of it with the #lang keyword, it might be nice to get more clearly distinct terms for these. The way the Java world uses JVM vs. Java, e.g. you'd say that a Clojure app runs "on the JVM", but it's not in Java.
- bjoli 9y agoOne thing that makes racket shine is it's macro facilities. Syntax case is nice and all that, but Jesus Christ in a chicken basket I wish scheme would have standardised on syntax-parse. Syntax case vs. syntax parse isn't and will never be close to a fair comparison. Not only is it more powerful, it also provides the users of your macros with proper error messages. It blows both unhygienic and other hygienic macro systems out of the water for anything more complex than very basic macros.
- laxentasken 9y agoIf you do work in CL for a living, may I ask what kind of applications and which area? The reason for my question is that CL (and racket) seems like a very good idea to put some time into but the market for such jobs is dead where I live (sweden). Or those jobs might be held by lispers on a lifetime ...
- aerique 9y agoI don't work in CL for a living but it is my main go-to language (also at work). It is worth it to put some time into even though there's not a big market asking for CL directly.
- lottin 9y ago> trivial utilities for interactive use from the shell command-line with an "instantaneous" feel Last time I checked CL images were huge though. Something like 24MB for a "hello world" executable, even bigger with some compilers.
- aerique 9y agoYou are correct, but why is this a problem in the case mentioned by the author? $ cat > hello-world.lisp (defun main () (format t "Hello, World!~%")) $ sbcl * (load "hello-world.lisp") T * (save-lisp-and-die "hello-world" :toplevel #'main :executable t) [undoing binding stack and other enclosing state... done] [defragmenting immobile space... 1110+19908+28500+22601 objects... done] [saving current Lisp image into hello-world: writing 4816 bytes from the read-only space at 0x20000000 writing 2320 bytes from the static space at 0x20100000 writing 2383872 bytes from the immobile space at 0x20300000 writing 15190112 bytes from the immobile space at 0x21b00000 writing 39911424 bytes from the dynamic space at 0x1000000000 done] $ ./hello-world Hello, World! $ ls -lh hello-world -rwxr-xr-x 1 user user 56M Aug 23 10:23 hello-world
- lottin 9y agoIt's not necessarily a problem, but personally for small utilities I much prefer something that supports #!-style scripts, like Guile or Racket, or that can be compiled into small, efficient executables. Let's say it's a matter of personal preference.
- juki 9y agoYou can use CL for #!-scripts too. SBCL has a `--script` option for running scripts. You'll probably want to create a core with whatever libraries you need for scrips, so that the start-up time will be fast. The core will be big, but it can be shared for all scripts, so that's not much of a problem.
- ebzzry 9y ago
- myth_drannon 9y agoFor anyone interested in Racket, excellent book/online tutorials http://beautifulracket.com/ http://beautifulracket.com/