This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2024-04-25
Channels
- # announcements (4)
- # beginners (26)
- # calva (18)
- # cider (24)
- # clojure (35)
- # clojure-brasil (9)
- # clojure-dev (6)
- # clojure-europe (39)
- # clojure-madison (1)
- # clojure-nl (1)
- # clojure-norway (100)
- # clojure-uk (6)
- # clojurescript (17)
- # data-science (15)
- # datalevin (5)
- # emacs (1)
- # events (2)
- # introduce-yourself (2)
- # javascript (1)
- # malli (28)
- # missionary (7)
- # off-topic (59)
- # polylith (20)
- # reitit (2)
- # releases (1)
- # remote-jobs (2)
- # rewrite-clj (5)
- # shadow-cljs (27)
- # sql (5)
- # squint (63)
- # xtdb (8)
I'm trying to summarize the various printing functions in clojure. Many functions reference a variable named *flush-on-newline*
but I don't find explicit documentation for this variable.
Are variables documented in https://clojuredocs.org
> When set to true, output will be flushed whenever a newline is printed. > Defaults to true.
It's in its docstring. Clojuredocs is unofficial - community driven. Some things are missing I guess.
I found the following in core.clj
(add-doc-and-meta *flush-on-newline*
"When set to true, output will be flushed whenever a newline is printed.
Defaults to true."
{:added "1.0"})
I guess that means the variable is defined in the underlying java code, and its docstring and meta data are added at the clojure level?
It might be this thing here: https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/RT.java#L230
Is there a function in Clojure to get progressively larger "windows" of some data? Say I have ["a" "b" "c" "d"]
, I'd want to get something like (["a"] ["a" "b"] ["a" "b" "c"] ["a" "b" "c" "d"])
I've done sliding windows before with partition, but this is more expanding than sliding...
Ah interesting. conj
as the reducing function?
sure, or just use whatever you were planning to do with the windows as the reducing function
Thanks 🙂
Why does lein
take so long to run?
time lein
Leiningen is a tool for working with Clojure projects.
Several tasks are available:
change Rewrite project.clj with f applied to the value at key-or-path.
check Check syntax and warn on reflection.
classpath Write the classpath of the current project to output-file.
clean Removes all files from paths in clean-targets for a project
compile Compile Clojure source into .class files.
deploy Deploy jar and pom to remote repository.
deps Download and examine dependencies.
do Higher-order task to perform other tasks in succession.
help Display a list of tasks or help for a given task or subtask.
install Install jar and pom to the local repository; typically ~/.m2.
jar Package up all the project's files into a jar file.
javac Compile Java source files.
new Generate scaffolding for a new project based on a template.
plugin DEPRECATED. Please use the :user profile instead.
pom Write a pom.xml file to disk for Maven interoperability.
release Perform release tasks.
repl Start a repl session either with the current project or standalone.
retest Run only the test namespaces which failed last time around.
run Run the project's -main function.
search Search Central and Clojars for published artifacts.
show-profiles List all available profiles or display one if given an argument.
test Run the project's tests.
trampoline Run a task without nesting the project's JVM inside Leiningen's.
uberjar Package up the project files and all dependencies into a jar file.
update-in Perform arbitrary transformations on your project map.
upgrade Upgrade Leiningen to specified version or latest stable.
vcs Interact with the version control system.
version Print version for Leiningen and the current JVM.
with-profile Apply the given task with the profile(s) specified.
Run `lein help $TASK` for details.
Global Options:
-o Run a task offline.
-U Run a task after forcing update of snapshots.
-h, --help Print this help or help for a specific task.
-v, --version Print Leiningen's version.
These aliases are available:
downgrade, expands to upgrade
See also: readme, faq, tutorial, news, sample, profiles, deploying, gpg,
mixed-source, templates, and copying.
________________________________________________________
Executed in 3.24 secs fish external
usr time 3.54 secs 0.22 millis 3.54 secs
sys time 0.50 secs 1.89 millis 0.50 secs
If this is indicative of Clojure's performance, I'm shopping elsewhere.For compiled projects, it isn’t. The breakdown of the flamegraph here gives some insights into what lein
is doing under the hood.
http://clojure-goes-fast.com/blog/clojures-slow-start/
A broader performance comparison is offered here: https://stuartsierra.com/2019/12/21/clojure-start-time-in-2019
those are distractions really. shopping for trying to do what? Clojure's primary use case is either running a long-running REPL for interactive development, or long-running situated server programs. In both cases, these often run for hours, days, weeks. If your goal is short command line programs, there are faster paths using babashka for scripting uses, or Graal for fast starting server programs
that timing for lein looks slow to me, but you are generally running a JVM to do anything with Clojure. there are other tools like the official Clojure CLI, and faster versions of that using babashka or native if you need it
This is using Graal, for context.
not sure what that means, is "this" what you want to do or referring to lein (which does not use Graal afaik)?
So my ultimate goal here is to figure out how to get an AWS Lambda function running using Clojure. I'm very new to Clojure, and I'm starting with Leiningen. Cold start times are a huge problem with Lambda and Java.
there is a lot of prior art specifically about this, maybe check out #C1AL322AJ here, should find some good links
What's the reason for it being called max-key
instead of, say, max-by
? It seems that the "key" can be any function that returns an integer, so really it's about finding the max by some computation, not exclusively by some key/property. Any historical insights?
Hmm... I see. The docs show it as (max-key k x)
which I thought implies that the first argument is meant to be a literal key. I expected something more like (max-by f x)
Would you say it's common to name function parameters around what they're logically for (in this case, generating a key for comparison) rather than what they literally are (a function of x->int)?