Is there any recommended Java runtime/version for CLJS? I installed openjdk-16-jre-headless
, I'm on Ubuntu.
Running yarn build
with shadow-cljs
takes 65.12s user 1.44s system 99% cpu 1:06.97 total
.
Is that normal? It's a hello world app, generated by yarn create cljs-app
, the react-start-app
alternative for CLJS if I understand it correctly.
And I'm running out of memory with yarn start
pretty much immediately.
OK, my server is very basic, it's an AWS EC2 free micro instance, so it's got only 1 GB of RAM. I added additional 2.5 GB of swap, but it'd cause exception saying it run out of memory without touching the swap much. And there's NOTHING else running on it.
That feels weird to me. Is it really THAT slow or is it just OpenJDK? Should I be using different Java?
Is AWS EC2 free micro instance performant? the oracle cloud equivalent is probably similar in performance and it is not very good for development.
Slack failed me on notifications here. Looking into it now!
@zengxh so I just switched to CJ. Before I was using Ruby/Node.js/Deno, ocassionally Common Lisp, Elm etc. and it was never an issue. Using Emacs and Mosh (rather than plain SSH), all works without any lags or delay. Of course JVM (and Graal even more so), are pretty hungry beasts, so I do not know if it's performant enough. I will do my best to stick to it, would rather not spend any extra money – I'm not working at the moment. (But it's likely that JVM will leave me with no other choice, but let's first give it a go.)
@zengxh you said in another thread that the Oracle cloud offers more memory than AWS (although it might have been a typo? I kinda think it was.) All I found for the free tier of the Oracle cloud was 2 Compute VMs, each with 1/8 OCPU and 1 GB memory. I suppose that's all Oracle gives you, isn't it? Still it looks better than AWS, as it's unlimited vs. 1 year, so I might switch ... but it doesn't solve the problem with the memory though.
@thheller man that fixed it! Thanks so much!! 600 MB did the trick. Now it seems to work pretty smooth.
https://www.oracle.com/cloud/free/#always-free 4 Arm-based Ampere A1 cores and 24 GB of memory usable as one VM or up to 4 VMs.
you can tweak the memory by setting :jvm-opts ["-Xmx700m"]
in shadow-cljs.edn
(max 700mb of ram). build times pretty much depend on what you are building and it should only be that slow once. after that the cache should kick in and make things much faster.
you can go lower with memory settings but going too low can make things slower. 500m is usually fine
Is there a linter for ensuring that each ns having deftests is included in a given project's cljs.test/run-tests
call?
Have always wanted that
Absolute beginner here, first day with ClojureScript. Stuck on this
Haha what a lot to unpackage!
you have a talent for clear, thorough explanations quoll!
(= 25 ((fn [n] (* n n) 5))
I would think it’s more:
(= 25 (#(% 5) (fn [n] (* n n))))
The question is looking for a function that takes a function as an argument…
That's the answer, but the syntax is mind-bending. I understand # declares a function and % is a placeholder. 5 is the argument?
i've been doing clojure/script for quite some time and that is a very confusing question. and i don't really see any benefit to it
I discovered Clojure/script last night from a job posting for a position at Roam Research
I love the product and thought it would be nice to learn to language they use
5
is the argument passed to the function subbed in for %
, namely (fn [n] (* n n))
. So... yes.
But it's not an argument of #(% 5)
(a.k.a. (fn [f] (f 5))
), just a hardcoded value.
Thank you guys!
The question is just trying to show you can pass a function as an argument… but it certainly is done in a confusing way. 🙂 It might have made more sense to provide the #(% %)
, and have the user create any function to pass in that satisfies the answer 25.
I know that this has been explained, but I feel like I want to explain it differently…
Talking about arguments for functions may make it unclear that there are multiple levels of function call, and different arguments at each level. That’s adding complexity over the actual task, making it much less clear.
Abstracting it down, it comes to:
(answer (fn [n] (* n n)))
Where the value of answer
is what we’re looking for. This says that answer
takes a single argument, and it’s the function that’s defined.
When looking at the correct answer:
#(% 5)
I’d rather use the long form to explain, so an equivalent is:
(fn [f] (f 5))
This is an anonymous function that takes another function and uses it on the number 5.
We know that the answer is 25, and the function being provided is a squaring function, so that’s how we know that we want to apply to 5.
The final expression is:
((fn [f] (f 5)) (fn [n] (* n n)))
What a mess.
What it says is:
• calculate the first expression to obtain a function that takes a function and applies it to 5
• calculate the second expression to obtain a function that takes a number and squares it
• calculate the result of applying the first expression (which evaluated as a function) to the second expression (which also evaluated as a function)
That’s a lot for one expression. Not difficult when you’re used to it, but really tough for someone who is new to the ideas
I think your explanation adds a LOT of value, thanks! :thumbsup:
Thank you