oh, awesome, that seems to be exactly what I was looking for. Thanks!
Thank you @philip.mcgrath for your patient and thorough explanation. I believe that the server I use is running Apache. With Clojurescript, I can compile something and move the resulting folder to the server, and then anyone can point a browser to the index.html
file in the folder on the server and it runs. Long ago I did something similar using a combination of C++ and Common Lisp. Do I understand correctly that nothing like this is possible using Racket? If so, then I guess I would indeed need to run a command on the server to start up the Racket part of the server, and set something up so that that it runs automatically when the server is rebooted, or get my sysadmin to do those things. If this is right, then is there a concise description of the needed command/setup that can be conveyed to someone who doesn’t already have much knowledge beyond Racket? I ask both for my own projects and for my teaching of new programmers, for whom I gather Racket is intended to serve as a good environment. If the student has made a thing that they want to share, by making it run on the web, and they have a public_html
directory on a university server, what is the magic to make the thing run online, where their friends and family can check it out?
Compiling ClojureScript makes a JS file that you can include into an html file via script
tags, in your case index.html
. When you were running C++/Common Lisp was this via cgi bin perchance?
Racket does have bindings for CGI (https://docs.racket-lang.org/net/cgi.html) which is a real old school way of generating dynamic web content
(Also, if you want to share smaller one-off scripts online, there is http://pasterack.org/)
Yeah, my C++/Common Lisp approach did involve cgi. I don’t remember the details though. Do you think this is a reasonable approach for the need I’ve outlined above?
The pasterack thing does look like it could be helpful for some of my purposes, albeit awkward and limited, I’m guessing.
I think if you want to get something simple up, and your current server environment supports CGI then it might be a good bet to experiment with. Would ask your admin if CGI is available.
Thanks. Do you know of simple instructions/examples that show how to take a simple thing that runs locally and use the CGI approach to put it in a public_html directory, assuming that CGI is available?
Unfortunately I don’t. I’ve never really used CGI. My understanding from way back when I used to work with shared hosts was that there was usually a /cgi_bin
directory to put scripts in.
Got it. I guess the more reasonable way forward would be to run the Racket server command on the server, and set things up so that happens automatically when the server is rebooted. That being the case, is there documentation for doing this that a new Racket programmer could follow? Based on what I see of the Racket community’s interest in new programmers (who will be motivated by being able to share their creations), I would think that this would be appreciated by people other than me (and me! :slightly_smiling_face:)
I actually used Racket for CGI programming before I learned the web-server
library. The good part about CGI programming in Racket is that you’re doing it in Racket. The bad part about it is that you’re doing CGI programming and you have to live with all of its limitations, without the innovations of the web-server
library for managing interactive programs in particular. More practically, using CGI still means you need to have Racket installed on your server, including all of the packages you’re using. (You could also compile your program into a stand-alone executable and install that on your server, but that doesn’t get you much farther.) If your server administrator is willing to do that, then putting #!/usr/bin/env racket
on the first line of your script (before the #lang
line) and making it executable with chmod +x
will make it work the way CGI expects, though where you have to put it depends on how Apache is configured on your specific server. But, if your server administrator is willing to do that, they’re most of the way toward letting you run a Racket web-server
program on a local port, which is much better in most circumstances.
Thanks for the additional detail! This reinforces my impression that CGI isn’t really the way to go, and running a Racket web-server
program on a local port is better… So it’d be great to have instructions for that that could be followed by someone who doesn’t know much more than how to write a simple Racket program.
@lspector This is the systemd
unit file I use to automatically run the Racket web server for https://digitalricoeur.org [Unit]
Description=Digital Ricoeur portal web server
[Service]
User=ricoeurd
Group=ricoeurd
AmbientCapabilities=CAP_NET_BIND_SERVICE
WorkingDirectory=/home/ubuntu/ricoeur-portal/
ExecStart=/usr/local/bin/ricoeur-portal --production
[Install]
WantedBy=multi-user.target
The ricoeur-portal
program is created by raco setup
: https://docs.racket-lang.org/raco/setup-info.html#(idx._(gentag._13._(lib._scribblings%2Fraco%2Fraco..scrbl)))
Interesting! Not least because of the Ricoeur I read back in my philosophy major days :slightly_smiling_face:. I think I would have to take a big step back, though, to figure out what to do with a systemd
file and how/where to use the raco material to which you linked.
There is also some basic guidance on running behind Apache in the web-server
documentation: https://docs.racket-lang.org/web-server-internal/Troubleshooting_and_Tips.html
Thanks. For the moment that’s going in my collection of tabs with stuff I don’t yet understand, but I will try to look back at all of this and see if I can figure out how to use it.
I watched William Byrd’s lecture on interpreters in LISP. Very informative. I lost complete comprehension about 60% of the way through, but was impressed I made it that far. I had no idea LISP was so powerful.
yep!
Thanks for the recommendation, I’ll watch it when I have some time.
Hi! How to get the name of a procedure? For example: #<procedure:number?> -> “number?” thx!
@benjamin.clos You may look at the threading
package. (require threading)
...
(define (lisp input)
(~> input
success
((lift check_input) _)
((lift check_operation_code) _)
((lift check_arguments_length) _)
((lift check_arguments_types) _)
((lift apply_operation) _)))
The ~>
is the threading macro that kind of works like the \|>
elixir operator.
@contact you want object-name
thank you !
ah yeah, that was the one recommended above, it looked perfect, but I appreciate you double checking
@thegobinath has joined the channel
It’s really fun and very mind-blowing.
I am liking LISP/Racket so much I am making a blog about my learning journey lol.
@hey.calmdown has joined the channel
A very dumb question from a very newbie here (~> '(1 2 3) (map writeln _))
;;; 1
;;; 2
;;; 3
;;; '(#<void> #<void> #<void>)
Where do the #<void>
s came from?
writeln
has a side effect, which is to write the data to the current output port (e.g., stdout), but the output of writeln
itself is (void)
Perhaps what you want is (~> '(1 2 3) (for-each writeln _))
oh!
Unlike map
, which will collect outputs from the function together to create a list, for-each
discards them. Hence, for-each
is useful when the function is primarily invoked for side-effect
got it
:pray:
works like a charm!
I believe writeln
returns void
@hey.calmdown So the return value of the map is a list of the void return values from doing each writeln.