Guaranteed Rate commercial during the Super Bowl had some Clojure on screen ...Β https://youtu.be/Nf0QvCq3quk?t=38
Not sure what editor that is?
Looks like vim(spacevim) to me.
Can anyone read it?
I can read parts of it π
Is Clojure famous now? π
this frame has a reasonably legible view of the left pane w/ create- and update-loan! functions, middle pane is some functions for rates, can't read anything on the right
That's a lot of chrome tabs!
I'll often have multiple instances with at least that many tab open and I think it makes my girlfriend physically ill when she happens to look over my shoulder
on the other hand, the only thing on my desktop is my recycle bin and I'm suspicious of anyone who leaves documents and folders all over theirs.
Grokking Fulcro part 2 is now available: https://youtu.be/102nHLzIbE4
Ooh I just learned about the ,
and .
keys on youtube to go back and forward a single frame. You can definitely get clearer screenshots that way!
βHow did an underdog, always counted out, take down the biggest name?β I think Clojure was a reasonable choice of PL for this add.
Ever want to use Clojure like it was PHP on cheap servers? Now you can by combining Babashka with cgi-scripts on shared hosts! Learn more about the process at https://eccentric-j.com/blog/clojure-like-its-php.html. See an example at https://cgi.eccentric-j.com/metal.clj. View the source, then discover some helpful scripts, docker-files, and hints at https://github.com/eccentric-j/clj-cgi-example.
Did you perform any benchmarks of such solution? I'd be a bit afraid of the fact that you need to spawn new bb
instance for every single request (right?). And bb
binary is 70MB..
I mean I like the fact that it's possible to execute bb
this way :thumbsup: , I'd just hope that people will not start trying to create full-blown webapps this way π
@brdloush I'm not sure if the binary size matter for memory usage. E.g. bb -e '(+ 1 2 3)'
give me:
max memory: 17516 MB
You can even set -Xmx
as the first command line arg to bb if you are worried about this. For max performance CGI isn't the best solution. You will go to a proper HTTP server (babashka also has one btw) and probably run JVM Clojure. I think you should consider this an experimental approach for personal side projects / low traffic websites.Yes, the memory usage will be probably lower than the actual size of the binary. But still, even ~17MB per request is quite a huge overhead (when compared to handling a request in a long-running http server)
yeah, babashka's httpkit server might actually give quite decent performance
still, Eccentric J's solution might be a nice alternative for many personal side-projects, where you need to quickly hack together some http-accessible scripts backed by clojure code and you're not limited by performance. It's nice that you don't have to keep any additional server running -> don't have to monitor its status etc.
Nice @jayzawrotny! Iβm curious if you know https://github.com/alekcz/pcp and how you would compare it. Iβm guessing your approach fully exploits the features in babashka whereas PCP is based on Sci, but not as fully featured as Babashka. PCP might counter the memory issues @brdloush mentioned
From the blog post: > Github user alekcz (Alexander Oloo) has begun drafting PCP: A Clojure processor that runs a SCGI server that can act as a replacement for a long-running php-fpm process. This may not be best suited for a shared hosting service but would definitely be good for a VPS hosting service. I look forward to seeing it progress! Afaik PCP also needs a JVM to run.
Yeah good point. Different approach then. Nice to see these developments anyway
Yes found it the other day and linked to PCP in my article as an alternative. This solution with bb works with SimpleCGI. Where the script runs cold. PCP is more like FastCGI where there is a continuous process that a request client communicates with like how php-fpm works. You cannot run PCP on shared hosts, you will need at least a VPS.
Thanks for the explanation! And thanks for exploring this use of Babashka!
Next step is to convince the php hoster companies to make babashka available on their servers π (I forgot the name for these companies π)
@brdloush I did not benchmark it but I doubt it would be reliable. Shared hosts are unpredictable, like a bathroom shared amongst many roommates π While editing it I probably refreshed the page in the triple digits and it certainly wasnβt the fastest but itβs loading < 1 s for me which is sufficient given that Iβm loading bb, Postgres pod, running a query, transforming css with gaka, and html with hiccup. I wouldnβt launch an enterprise, high-availability service with it but it seems very promising for putting together some MVPs.
The setup I am using for now is also the least optimized, might be a bit more performant to uberscript the entire project and run it through that as a single bundle and use carve to trim it down.
And then when you want to optimize it even further you can GraalVM compile it without using bb, or just produce static HTML for pages that don't need user input (if you want to continue going the CGI route)
> I did not benchmark it but I doubt it would be reliable. Shared hosts are unpredictable, Agreed. But one can still perform such benchmark on his local machine. Maybe someone will try it. It's not that important to do such benchmark. I was just curious, as I have no idea (nor a good estimate) of how poorly (or perhaps surprisingly well) this hacky-but-nice solution would scale. Maybe I'll try to benchmark this myself if I find some spare time.
That would be great! Iβd be interested in seeing how itβs done for the future.
I usually use multitime
to test multiple invocations of a script
e.g.:
$ multitime -n10 -s0 /usr/local/bin/bb tmp/meander.clj
===> multitime results
1: /usr/local/bin/bb tmp/meander.clj
Mean Std.Dev. Min Median Max
real 0.152 0.004 0.148 0.151 0.159
user 0.108 0.002 0.106 0.107 0.110
sys 0.041 0.002 0.037 0.040 0.045
I see so create a script that creates a request and waits for a response then run it with multitime?
I think you should just test the script itself preferably
and not include other tools, to discount their startup time overhead
Good point
btw, Just loved to see Igorrr referenced in front page
@jayzawrotny I love this stuff. I've been really bothered by the infrastructure footprint of keeping live Clojure runtimes online, and this approach looks very promising.
Could this idea be extended to run serverless scripts using bb
?
@kumarshantanu You mean like AWS Lambda-ish?
Yes, @borkdude
@kumarshantanu I've seen several mentions of babashka on AWS Lambda. I think it works. There's also a blog post about it here: https://www.jocas.lt/blog/post/babashka-aws-lambda/ @dainius.jocas I think it's the first time I see this blog post. Here is a specific setting for AWS Lambda: https://github.com/babashka/babashka#package-babashka-script-as-a-aws-lambda
The blog approach might need updating, maybe best to discuss in #babashka. People like @lukaszkorecki have mentioned that you can now do this more easily perhaps without "layers".
@schultzkaue π― I underestimated how difficult it would be to make a meaningful database for this example that demonstrates the power without it becoming overcomplicated. Fortunately I was listening to my Igorrr playlist at the time.
@val_waeselynck Iβm glad to hear that! There are many small side projects I can just start busting out now instead of having to plan a whole stack, deploy system, and cloud platform research. Itβs amazing how big of a difference removing those decisions make.
Announcing the 0.15.0 release of the #sicmutils computer algebra system for Clojure(script): https://github.com/sicmutils/sicmutils/ SICMUtils is a system built for interactive math and physics explorations in Clojure; itβs also got smoking fast numerical method implementations for when you do want to go fast. The latest release is fully compatible with #sci , and therefore easy to add to any environment (#nextjournal anyone?) that uses SCI for clj(s) evaluation. Weβve also upgraded the automatic differentiation implementation to handle higher order functions, and comparison and equality, so you can differentiate functions with internal conditional. Lots more in the release notes here: https://github.com/sicmutils/sicmutils/releases/tag/v0.15.0 Thanks to @mkvlr, @borkdude and @hcarvalhoaves for your help and contributions in the latest release. Please come say hi in #sicmutils if any of this sounds intriguing!