Fork me on GitHub
#announcements
<
2021-02-08
>
alexmiller04:02:20

Guaranteed Rate commercial during the Super Bowl had some Clojure on screen ... https://youtu.be/Nf0QvCq3quk?t=38

🏈 39
clojure-spin 115
alexmiller04:02:26

Not sure what editor that is?

prertik04:02:28

Looks like vim(spacevim) to me.

andy.fingerhut04:02:25

Can anyone read it?

Eccentric J04:02:05

I can read parts of it 😅

Eccentric J04:02:43

Is Clojure famous now? 😎

☝️ 3
chucklehead05:02:33

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

djblue05:02:27

That's a lot of chrome tabs!

chucklehead06:02:39

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

6
chucklehead06:02:33

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.

Eccentric J06:02:54

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!

🤯 3
slipset06:02:29

“How did an underdog, always counted out, take down the biggest name?” I think Clojure was a reasonable choice of PL for this add.

metal 45
tony.kay06:02:42

Grokking Fulcro part 2 is now available: https://youtu.be/102nHLzIbE4

🎉 27
Eccentric J10:02:22

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.

🤯 35
👏 18
babashka 18
🙃 6
Eccentric J10:02:12

Major thanks to @borkdude and @U0K064KQV, would not have gotten to this point without your help!

Tomas Brejla10:02:11

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 bbbinary is 70MB..

Tomas Brejla10:02:01

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 😄

borkdude10:02:23

@U01LFP3LA6P 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.

👍 6
Tomas Brejla10:02:09

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)

Tomas Brejla10:02:45

yeah, babashka's httpkit server might actually give quite decent performance

Tomas Brejla10:02:46

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.

jeroenvandijk10:02:20

Nice @U8WFYMFRU! 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 @U01LFP3LA6P mentioned

borkdude10:02:14

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.

jeroenvandijk10:02:29

Yeah good point. Different approach then. Nice to see these developments anyway

Eccentric J10:02:32

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.

jeroenvandijk11:02:32

Thanks for the explanation! And thanks for exploring this use of Babashka!

truestory 3
👍 6
jeroenvandijk11:02:17

Next step is to convince the php hoster companies to make babashka available on their servers 🙂 (I forgot the name for these companies 🙈)

Eccentric J11:02:16

@U01LFP3LA6P 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.

Eccentric J11:02:23

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.

borkdude11:02:47

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)

metal 3
Tomas Brejla11:02:55

> 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.

Eccentric J16:02:57

That would be great! I’d be interested in seeing how it’s done for the future.

borkdude16:02:48

I usually use multitime to test multiple invocations of a script

borkdude16:02:51

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

Eccentric J16:02:05

I see so create a script that creates a request and waits for a response then run it with multitime?

borkdude16:02:39

I think you should just test the script itself preferably

borkdude16:02:08

and not include other tools, to discount their startup time overhead

kschltz16:02:41

btw, Just loved to see Igorrr referenced in front page

val_waeselynck17:02:01

@U8WFYMFRU 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.

Shantanu Kumar18:02:10

Could this idea be extended to run serverless scripts using bb?

borkdude18:02:50

@U066J7E2U You mean like AWS Lambda-ish?

borkdude18:02:05

@U066J7E2U 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/ @U0FT43GKV 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

3
borkdude18:02:58

The blog approach might need updating, maybe best to discuss in #babashka. People like @U0JEFEZH6 have mentioned that you can now do this more easily perhaps without "layers".

Eccentric J18:02:50

@UNAPH1QMN 💯 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.

Eccentric J18:02:35

@U06GS6P1N 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.

Sam Ritchie18:02:14

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!

🙏 12
🚀 27
🎉 9
👏 3