Found 93960 results
Q: does anyone know about literature that discusses the effect of single-pass vs. multi-pass compilers on code structure? I was wondering whether there ever has been some quantification of "entangledness" in for example a Java code base vs. a clojure (or other) code base as a result of what the compiler allows in terms of circular deps etc...
In any case I'm not sure how to build java interop with this specific part of the example they give:
public static void main(String[] args) {
launch(new Main());
}
how does this translate in Clojure? https://github.com/SpaiR/imgui-javaHas anybody ever used dear imgui
in clojure? I've found these java bindings for it https://github.com/SpaiR/imgui-java but no clojure ones
The monthly HackerNews “Who’s Hiring” topic is another one I know some clojure people look into
what is the best way to do this same operation in clojure?
how would I mutate a string in clojure, get the result, and then mutate the result in a loop?
One use-case that I think can be super useful is calling native APIs from the REPL. I had to build a custom camera component in Swift and I felt like going back to the dark ages, using the debugger, setting break points, etc. If I had a Clojure REPL into Swift/Objective-C (ideally Swift) the experience could potentially be much better.
I don't think copilot necessarily implies that the target languages/frameworks have too much boilerplate. It certainly helps with spitting out boiler plate, but it's really common to have some starter code for specific tasks (eg. requiring the right namespaces and making a place to fill in data/functionality). In many cases, I wouldn't consider that "too much" boilerplate. Basically, anything that you would copy and paste from a Readme would be convenient as an auto suggestion from your IDE. IMO, Just about every clojure library has something like that.
I highly recommend this clojure D talk by the great Paula Gearon, if your interested in learning about how immutable datastructures are implemented. https://youtu.be/oD1WONpv6Xc I recommenced everything by her actually.
You could also build an uberjar of your Clojure project -- without AOT -- and put that in lib
(you wouldn't need the Clojure JARs in lib
then because Clojure would be in your uberjar) and, again, access the Clojure code via require
as above.
What I'm trying to help you avoid is having to write all the gen-class stuff since that's so painful and also it requires the compiled Java classes to be on your Clojure classpath -- which would mean your Clojure project would have to live in that same tree so it could be on your :paths
. Code compiled per above, into the WEB-INF/classes
folder, would then be on the classpath when the Java code runs so that your Java code could require it -- but I worry that classes
folder gets cleaned out each time to build the Java code (which would erase your Clojure code).
If you have a small, simple Clojure project, you can ask Clojure to compile a namespace to .class
files in a specific target directory from the REPL:
user=> (binding [*compile-path* "/home/jacekp/code/AAA-java/reportgenerator/build/web/WEB-INF/classes"]
(compile "your.namespace"))
That would let you write Clojure in a separate folder, and compile it into that classes
folder so it would be accessible to the Java code (via the var
/`invoke` calls).It looked like you were using ant
to actually run the code for testing that the Clojure invocation worked.
When we were adding Clojure to our legacy app, we edited the app's config to add an additional folder to the classpath at startup (our Clojure src
folder).
Yeah, expected. I was hoping for some other folder where you could safely put Clojure source code 🙂
i have created clojure-src folder at the root of java project and uses the properties/sources dialog to add it to the project
You're using Clojure source code inside the Java project, and relying on the require
invocation to load and compile it.
You're not building Clojure to a JAR or compiling it to classes.
or just src of the clojure project?
Then you just write your Clojure code in that folder, and use var
/`require` to make it accessible to Java.
now how do i invoke real clojure code?
before trying clojure 3 after trying clo
public static String passTheHash(SalXmlDocument info) { System.out.println("before trying clojure"); IFn plus = Clojure.var("clojure.core", "+"); plus.invoke(1, 2); System.out.println("after trying clojure");
Hi everyone. Brand new to Clojure and can't stop reading for the last two weeks. Interested to start a SaaS (learning) project with Clojure and was wondering if it is considered OK to use Vue or React without going the SPA road. A bit like adding some React or Vue components only in the html templates (using Semler). I guess it is possible but would like to hear about your experiences.
ant -f /home/jacekp/code/AAA-java/reportgenerator -Djavac.includes=servlets/GeneratorServlet.java -Dnb.internal.action.name=debug.single -Ddirectory.deployment.supported=false -DforceRedeploy=false -Dbrowser.context=/home/jacekp/code/AAA-java/reportgenerator/src/java/servlets/GeneratorServlet.java -Ddebug.class=servlets.GeneratorServlet debug-single-main init: deps-module-jar: deps-ear-jar: deps-jar: compile-single: Generating Report - ReportID : 1388907 - Report Type : +44 - UserName : jacekp - Location : Concept Loading KeyStore File URL: http://localhost:10000/xml/report/generate/1388907Converting stream to string Starting loading groups from XML group = Pesticide Screen (GC CSOPP611 & LC CSOPP603 Reg) group = Fosetyl-Al (sum fosetyl + phosphorous acid and their salts, express as fosetyl) group = Miscellaneous group = Miscellaneous group = Pesticide Screen (GC CSOPP611 & LC CSOPP603 Reg) Finished Loading Groups from XML Report Unit : 1' : kg Report Unit : 3' : mg for 5 : null Parsing new report : before trying clojure after trying clojur
you think about the question i was asking myself about the src for clojure
As for writing your own Clojure code and being able to require and invoke that, you'll need your (Clojure) src
folder to be on the project's classpath but I'm sure where to suggest putting that or how to configure the app to add it...
I can also just store all desired created objects in an atom. This may be more Clojuric, but I also want to understand the js->cljs translation as well.
It'll be painful to add any new Clojure libraries or update Clojure etc but it should at least get you to a working state for something basic.
If you download those manually from Maven, like you did for Clojure, and put them in lib
, you should at least be able to try the Java -> Clojure calls into clojure.core
per the example linked somewhere above.
OK, so since you've gotten as far as manually downloading Clojure 1.10.2, here are the other libs you'll need to download to at least move forward:
org.clojure/clojure 1.10.2
. org.clojure/spec.alpha 0.2.194
. org.clojure/core.specs.alpha 0.2.56
I'm sure there are a lot of legacy projects that would benefit from clojure, but why is is so hard, are people so fed up with the old projects so that they rewrite them from scratch?
Well, then you're probably not going to be able to mix Clojure and Java if you can't find out or figure out how to add Maven-style dependencies to that existing project, sorry.
NetBeans itself definitely lets you add new dependencies to a project (not JAR files, not class libraries, actual dependencies). You need something that understands Maven-style dependencies to fetch Clojure for you, so that transitive dependencies are also fetched.
As I keep saying, I know nothing about NetBeans. Somehow, somewhere, your existing Java project must have a way of declaring/specifying its existing dependencies. Those are being fetched from Maven. Clojure is on Maven. So you can add Clojure as a dependency to the existing Java project somehow and that's all you need.
And that sort of question is going to get you better answers in #beginners (because the folks there have opted in to helping folks learning Clojure in depth -- which is not the case in this channel).
Please figure out how to add dependencies to your Java project and add Clojure that way.
Clojure itself depends on two other libraries. Downloading the JAR will not give you those libraries so your code will fail (in ways you will find hard to debug).
That will not work. You need to specify Clojure as a dependency not a downloaded library.
general clojure question, what's the proper way to emulate a for loop with a conditional break statement in clojure?
because in particular here, a lot of clojure idioms are going to be terrible / unreadable / very poor in performance when directly copied to go
Hi 👋 I think that my vscode config (shared mutable state, amirite?) is messing with the jack-in command.
Symptoms:
1. When I execute the jack-in command from a deps.edn
file, I get the prompt to choose my repl type; when I choose Clojure CLI nothing happens and this message appears Running the contributed command: 'calva.jackIn' failed.
2. When I execute the jack-in command from a clojure file, nothing happens altogether
I found this https://github.com/BetterThanTomorrow/calva/issues/1182 that looks similar so I tried to debug It like bpringe suggested
even so, clojure-lsp should start, this could be other issue
hum, could you paste the clojure-lsp log?
@U01P6LWQD1S clojure and go are different enough that I don't think the answer will be a code oriented one. If I were undertaking that translation I'd start with diagram (on paper or whiteboard) of the big pieces, and the relationships between them (what they share, how they transfer data to one another, which code crosses the boundaries between those pieces). often times with real world apps the answer is that the boundaries are crossed everywhere and you don't actually have separate pieces, but in that case the process of making the diagram helps you realize how you should have written it and can guide the new version. of course this is a clojure forum so most answers are going to be attempts to argue you don't need to switch
it should be installed, I the clj
command works fine. the version of clojure installed is 1.10.2.774
I suspect you don't have clojure
installed, but I'd like to config in the logs
Could you get the clojure-lsp log?
hello, i am having an issue initializing the clojure-lsp. I have a plugin installed for vscode called calva, but when I have a deps.edn
file the clojure-lsp never initializes. Without the file it initializes just fine. the only dependency I have in deps.edn is clojurescript. any ideas what the problem might be?
ah, makes a loot of sense! Thanks @U051SS2EU, and clojure ftw!!
Well, something somewhere in the project has to have the list of dependencies. When you find that, you can add Clojure to it.
And you should be able to rebuild your Java project and it will add Clojure to it.
Clojure is "just" a dependency like:
<groupId>org.clojure</groupId>
<artifactId>clojure</artifactId>
<version>1.10.3</version>
deps.clj: A faithful port of the clojure
bash script to Clojure
Used as native CLI, deps resolver in babashka and getting started REPL in Calva.
New release: v0.0.16
https://github.com/borkdude/deps.clj/releases/tag/v0.0.16
Excellent! So you can add Clojure to that.
No, you don't want deps.edn
for this: just add Clojure to your existing Java project. You'll use whatever tool your Java project uses to build the Java code already.
Accessing arbitrary paths outside the project root is a potential security issue and the Clojure CLI will currently print a warning if you do this (and eventually we plan to error in this case)
@U0C5DE6RK (class MessageEvent)
should be just returns Class
, you actually want MessageEvent
which is the clojure equivalent of java's MessageEvent.class
Okay, one more esoteric java noob q:
import com.slack.api.methods.response.chat.ChatPostMessageResponse;
import com.slack.api.model.event.ReactionAddedEvent;
app.event(ReactionAddedEvent.class, (payload, ctx) -> {
If I wanted to convert this to clojure, how would I convert passing in ReactionAddedEvent.class
?
I am trying:
(.event app
(class MessageEvent)
(reify BoltEventHandler
(apply [this evt ctx]
(log/info "ctx")
(log/info ctx))))
But am getting:
{:type java.lang.IllegalArgumentException
:message Unexpectedly failed to register the handler
:at [<http://com.slack.api.bolt.App|com.slack.api.bolt.App> event App.java 564]}]
Which makes me think I am not correctly converting MessageEvent.class
https://github.com/slackapi/java-slack-sdk/blob/416ab0415983c42c88ff3b266858462edebf8c91/bolt/src/main/java/com/slack/api/bolt/App.javai did some testing, it seems that when I have a deps.edn
file, on my installation calva is not able to initialize the clojure-lsp for proper linting, but without deps.edn I cant connect to the repl
So if I understand correctly:
• The above interface is only understood by java, as it uses generics
• From clojure side, it doesn’t know the class
of CTX
when our SlashCommandHandler
runs, and defaults to the base Context
type
[Hiring][Remote] Software Engineer (Clojure) at rentpath RentPath is looking for an experienced Software Engineer (Clojure) to join our team. Engage in an encouraging work hard/play hard company culture and become a part of an Interesting and charismatic group of professionals who love what they do! Reporting to the Services Engineering Manager, and in primary service to RentPath’s search engine optimization (SEO), internal data, and analytics teams, the Clojure Software Engineer is responsible for the delivery of the best in class technical solutions to meet the needs of our customers. https://arbeitnow.com/view/software-engineer-clojure-rentpath-352066
You don't need any of that if you call into Clojure from Java via Clojure's Java API that I linked to.
And the Clojure code is just regular Clojure code.
that page does not say what should be the corresponding code on clojure side
maybe its an issue with my machine, I see Initializning Clojure Language Features via clojure-lsp
in the bottom left corner of the editor. Maybe that's why im not getting having issues?
Did you read the page I linked, explaining Clojure's Java API?
but how do i pass to clojure an instance of a class?
public static String passTheData(SalXmlDocument info) { // use the new class for more talking to clojure hmm.report.foo("hello"); hmm.report.passdata(info);
The problem is calling clojure from java side
I had success with trivial app https://github.com/bigos/JavaApplication3 also at some point I was able to import legacy java classes to my clojure app, but for some reason it stopped working.
@U0C5DE6RK Java generics only exist in the (Java) compiler. They don't exist at runtime -- they're not in the .class
files -- which is what Clojure has to work with.
that is what I had in mind. to some extent you confirm my idea. But I am stuck at the clojure being a library of my legacy app. For some hope of success that clojure library has to work and finding the examples is not easy. to have a woking library for the legacy app I need to be able to import some classes.
Thanks team! > I think the issue here is that those types are available via generics to the Java compiler -- but generic types don’t exist in compiled code -- they are erased -- so the information that Clojure has available only has the raw types. Appreciate the depth Sean. Would love to understand this more. Which type is being erased here? (i.e I am not sure what you mean by “this type is available via generics to the Java compiler”, but not to our compiled code via Clojure) (indeed http api may be best, but am trying to smack a few things together as demo, and ideally would like to get this guy to work. Though yeah — oof — very darn convoluted)
Yes, that's how we interact with Slack from Clojure. Far easier than their ridiculously convoluted Java SDK.
I think the issue here is that those types are available via generics to the Java compiler -- but generic types don't exist in compiled code -- they are erased -- so the information that Clojure has available only has the raw types.
You would also need your Clojure project's src
folder added to the classpath of your legacy app (so the legacy project could "see" your Clojure code when it is referenced via the Java API).
You can start by adding Clojure as a regular dependency on your legacy app -- Clojure is "just" a library, like anything else you're already using in the legacy code. And gradually, as you write more Clojure to replace the Java code, start adding more Clojure libraries as dependencies.
There are two or three possible approaches but the one I prefer -- because it's how we refactored our legacy app to use Clojure (and then, ultimately, replaced the legacy app completely with Clojure) is to leverage Clojure's Java API https://clojure.org/reference/java_interop#_calling_clojure_from_java
(and ultimately replacing the Java code with Clojure, working from the ground up)
It sounds like you are really more interested in calling into Clojure from the legacy NetBeans app?
is it possible to gradually refactor the old app into clojure? or should I quit the job?
I have a legacy netbeans app and I was thinking about using it's classes to import to clojure and create a jar file from clojure code to be used by the netbeans app
Some of the recommendations/observations from my side as the author of holy-lambda would be: • use language, a tool which guarantees low cold starts: if Clojure then babashka, native runtime, otherwise python/nodejs/golang/rust • don't use AWS Lambda for your core functionality, since you will probably pay more for AWS Lambda than you would for Kubernetes cluster + don’t use AWS Lambda for APIs which are heavily used, it's not cost-efficient, • If you think that the AWS Lambda stack is easy to manage and you don't need any “DevOps” skills then you are tremendously wrong! • Use AWS Lambda for async/not core stuff (mostly as a glue between the AWS services) to save 15/20% compared to regular compute options, • Monitor memory/invocation time to optimize the cost even further,
I have deps.edn with :paths ["src" "resources" "../reportgenerator/build/web/WEB-INF/classes"] . In the classes folder I have itils folder and in it I have several classes that I want to import into clojure project. I import it like this (:import (utils Result SalXmlDocument Sample)) , but that gives me errors :clojure.error/class java.lang.ClassNotFoundException, :clojure.error/cause "java.lang.SalXmlDocument"},
It mirrors when I learned Clojure as one of my first languages. I didn't have to "unlearn" the bad OOP habits or whatever. TBH, I still struggled a lot until I did Harvard's CS50 course (using C and then Python) but now I feel I have the skills to be a junior developer if I wanted to (I don't, I want to create my own Clojure web apps for fun and profit)
We are pinning the versions of most of our dependencies with Nix, so babashka might have a slightly different version in every project directory. At least that's the case with Clojure CLI versions, so it's not great that I have to pick - manually - one of those versions and use it for all projects within IntelliJ... We only had minor issues though, maybe twice over the last 1.5year, because of this manual version specification.
@U012GN57FJ9 with-transaction
is like with-open
in Clojure: it introduces a new local binding with either a new connection drawn from the specified datasource, or by starting a transaction on the specified connection (which is why it is recommended to use a datasource there).
Despite that, I also can't fight the temptation to chat with my fellow clojure slack folks about these things before I'm ready. haha
I've chosen datomic for my greenfield project last year (+ datomic ions) and I'm very happy. But a friend of mine went with crux in his project and it seems very cool as well. So I'd say, if you want to go the Open Source route - choose Crux or Postgres, otherwise datomic. > If you could just go all Clojure, what would your whole stack look like? The stuff that's in the RAD demo is a nice start. I went with that + some minor modifications. > have the time freedom to do so even though I recognize I've bitten off way more than I can handle already in learning Fulcro with my already limited web dev experience You'll be in for a ride and I think you should at least skim the following thread 😉 https://clojurians.slack.com/archives/C68M60S4F/p1625065156313600?thread_ts=1625054514.312100&cid=C68M60S4F
I just tested against the latest issue-66 version and it works fine:
(! 504)-> clojure -Sforce -M:poly info
stable since: 2e956be
projects: 1 interfaces: 1
bases: 1 components: 1
project alias status dev
---------------------------- ---
development * dev x-- x--
interface brick dev
----------------- ---
schema schema x--
- api * x--
(! 505)-> clojure -Sforce -M:poly check
OK
but you do have to make some changes: add workspace.edn
and add deps.edn
to each base and component.Basically I just want to see if I can learn full stack web applications from top to bottom in Clojure. If you could just go all Clojure, what would your whole stack look like?
What (clojure datalog or not?) db would you folks suggest to use with Fulcro if you had the freedom in a greenfield project? I'm thinking of learning Crux because that seems cool. I'm also looking at this Datahike one, or maybe Asami...or datalevin. What do you think is the most "Fulcro-ish"?
That's what my question was aiming at. Since Clojure is more GC intensive than other langs I was wondering what kind of heaps you need to keep with ZGC for it to not keel over under the GC pressure
Sorry, I didn't know Calva would bump clojure-lsp today as well 😅
Hi team, how can I create Java local date time in clojure for the given time? #object[java.time.LocalDateTime 0x7af2002a "2021-07-05T15:49:30.051"]
:clojure-lsp: Released https://github.com/clojure-lsp/clojure-lsp/releases/tag/2021.07.05-15.12.14 with a bunch of improvements! 🎉
General
• Add :clean :sort
settings option to disable sorting during clean-ns
.
• Add :keep
value to :ns-indent-blocks-indentation
setting to don't change indentation during clean-ns
.
• Deprecate install-latest-clojure-lsp.sh
in place of install
new script.
• Improve source paths discoverability for leiningen
projects following the same rules as deps.edn
projects. For more information, check the https://clojure-lsp.github.io/clojure-lsp/settings/#source-paths-discovery.
API/CLI
• Add --dry
option to commands, useful on CI to print only diffs instead of making changes.
• Check out the new https://github.com/marketplace/actions/setup-clojure-lsp Github Action to run clojure-lsp on CI!
• Add format
feature using cljfmt.
• Now, every release is available in clojars :clojars: as com.github.clojure-lsp/clojure-lsp
.
This release allow clojure-lsp to be configured on CI/scripts to format/clean your code or just warn if not formatted/cleaned 🎉
@U9Q7C6G4C one thing you might be confused about is that clojure is not an interpreter - value storage is not implemented on top of let and var, it's done via java viirtual machine bytecode instructions
From my experience, Clojure applications with performance issues have a metric ton of performance lying on the floor. There are lots of easy improvements without sacrificing readability or idiomatic code
although typically for Clojure programs you would generate more garbage due to lazy seqs / FP style programming
I see FaaS as useful for some workloads and not so useful for others. We use FaaS quite a lot at work - specifically AWS Lambda - albeit with Kotlin (on JVM) rather than Clojure. We find that it works pretty well for asynchronous work (basically the lambda handles messages from an SQS queue) in situations where we don’t mind occasionally having to wait for a cold start but we don’t use it for anything that needs good interactive performance and/or guaranteed low latency.
there's a monthly post on the clojure subreddit where you can add your job. probably not what you mean, though
If this is a big (e.g. multi-week migration) project, you could do it gradually by creating some clojure<->go interop/bridge code then slowly replacing the service piece by piece.
this way user could have the target on classpath, and tell clojure-lsp to really ignore the target
we had a update where clojure-lsp resolve the source-paths checking the deps.edn
Figwheel seems to require that the "target" directory is on the classpath:
[Figwheel:WARNING] Attempting to dynamically add "target" to classpath!
[Figwheel:WARNING] Target directory "target" is not on the classpath
[Figwheel:WARNING] Please fix this by adding "target" to your classpath
I.E.
For Clojure CLI Tools in your deps.edn file:
ensure "target" is in your :paths key
so other clojurescript users might run into this problemIt was a fun, nice, resource for learning clojure
Now i finally noticed that my project actually includes the target dir in :paths
. clojure-lsp using this setting seems to have been added after the February edition i was using previously, so it makes sense now
Do you have Clojure in the tech stack?
Hiring Clojure Developer Full-Time Remote: Aceplace is a brand new booking platform launching in Dubai. Customers will be able to book all kinds of spaces for example meeting rooms, events halls, and yachts. We're a very small team so the work you'll be doing will have an enormous impact on the success of the company. If interested please DM me directly.
Hiring Clojure Developer Full-Time Remote: Aceplace is a brand new booking platform launching in Dubai. Customers will be able to book all kinds of spaces for example meeting rooms, events halls, and yachts. We're a very small team so the work you'll be doing will have an enormous impact on the success of the company. If interested please DM me directly.
I'd suggest you try Calva for VSCode or Emacs if you want the better clojure development experience 😕
Not clojure related. Plus I don’t want to specifically bash anyone’s work. I observed this as a general, recent trend.
There is an open source graph / triplestore implemented in Clojure that can deal with sparql
if the clojure service has integration tests, you might hack them so that they work over http so that you can exercise the Go version is in fact equivalent to the old one
I want to convert a clojure service to Go. What is the most optimal way to do this?
BTW try to disable that timeout, that will not work as sometimes (first time) clojure-lsp will take a while to scan the project and other times it will be fast
above is what clojure -Spath
returns. The plugin uses Url
to handle those, which can’t
@U016JRE24NL the 2. seems a issue with clojure-lsp right? For some reason with IDEA it returns wrong urls
Hiring! Permanent Currently hiring for a Fullstack Clojure developer to be working in the UK (Can sponsor for this position also for the right candidate) 100% Remote work in the UK only Joining a team of 3 Developers working on a learning platform Using Dataomics, re-agent, re-frame and AWS Salary between £40,000 - £60,000 dependant on experience Message me directly for more information Thanks
Hiring! Permanent Currently hiring for a Fullstack Clojure developer to be working in the UK (Can sponsor for this position also for the right candidate) 100% Remote work in the UK only Joining a team of 3 Developers working on a learning platform Using Dataomics, re-agent, re-frame and AWS Salary between £40,000 - £60,000 dependant on experience Message me directly for more information Thanks
Last chance to sign up for tomorrow's talk at the London Clojurians: FSet: a faster set library (by Renzo Borgatti) https://www.meetup.com/London-Clojurians/events/278421075/ Renzo will take us through a set of techniques and tools to consistently achieve higher performances with your Clojure programs. Join us and we will make sure to finish in time for the Euro 2020 Italy vs Spain match ⚽
➜ malli git:(malli.instrument) ✗ clojure -Spath
src:resources:/Users/tommi/.m2/repository/borkdude/dynaload/0.2.2/dynaload-0.2.2.jar:/Users/tommi/.m2/repository/borkdude/edamame/0.0.11/edamame-0.0.11.jar:/Users/tommi/.m2/repository/org/clojure/clojure/1.10.3/clojure-1.10.3.jar:/Users/tommi/.m2/repository/org/clojure/test.check/1.1.0/test.check-1.1.0.jar:/Users/tommi/.m2/repository/org/clojure/tools.reader/1.3.4/tools.reader-1.3.4.jar:/Users/tommi/.m2/repository/org/clojure/core.specs.alpha/0.2.56/core.specs.alpha-0.2.56.jar:/Users/tommi/.m2/repository/org/clojure/spec.alpha/0.2.194/spec.alpha-0.2.194.jar
so:
1. IDEA doesn’t set the PATH correctly
2. clojure -Spath
returns URLs that the plugin doesn’t understand (uses java.net.Url
.
tested from command line, the PATH is corrrect, but still doesn’t work, timeouts after 30sec:
2021-07-05T07:46:22.505Z UnknownHost INFO [clojure-lsp.crawler:27] - Finding classpath via ` clojure -Spath `
2021-07-05T07:46:22.566Z UnknownHost INFO [clojure-lsp.crawler:27] - Finding classpath via ` npx shadow-cljs classpath `
2021-07-05T07:46:51.574Z UnknownHost INFO [clojure-lsp.crawler:204] - Analyzing classpath for project root /Users/tommi/projects/metosin/malli
2021-07-05T07:46:51.575Z UnknownHost INFO [clojure-lsp.crawler:88] - Analyzing 15 paths with clj-kondo with batch size of 1 ...
Calva 2.0.203 is released: • Fix: https://github.com/BetterThanTomorrow/calva/issues/1203 • Improvement: https://github.com/BetterThanTomorrow/calva/issues/942 • Fix: https://github.com/BetterThanTomorrow/calva/issues/1222 • Bump clojure-lsp https://github.com/clojure-lsp/clojure-lsp/releases/tag/2021.07.01-13.46.18
I don't think I'm using the built in indent for clojure.
Yeah, maybe try to start Intellij from a terminal which has clojure on it
@U055NJ5CC I can try to setup Intellij later, what plugins for intellij are you using to setup clojure-lsp?
➜ ~ which clojure
/usr/local/bin/clojure
➜ ~ clojure
Clojure 1.10.3
user=>
it seems clojure
cannot be found? what do you get for which clojure
in the shell?
and copied clojure
there too just for making sure
(currently, it might be something it could borrow from clojure-lsp in the future)
Then clojure-lsp doesn't cache the analysis
This is how clojure-lsp call that command: https://github.com/clojure-lsp/clojure-lsp/blob/master/src/clojure_lsp/crawler.clj#L32
So it's not a issue with clojure-lsp, probably something with your OS not finding Clojure command
As clojure-lsp
not sure how can I pass any PATH to LSP, copied clojure
executable to the directory, still doesn’t see that.
You need clojure installed
I do have clojure
available :thinking_face:
2021-07-04T20:54:19.454Z UnknownHost INFO [clojure-lsp.crawler:236] - Automatically resolved source-paths from deps.edn: #{"src" "resources" "test"}
2021-07-04T20:54:19.971Z UnknownHost WARN [clojure-lsp.db:55] - Could not load db [SQLITE_ERROR] SQL error or missing database (no such table: project)
2021-07-04T20:54:19.972Z UnknownHost INFO [clojure-lsp.crawler:27] - Finding classpath via ` clojure -A:dev -Spath `
2021-07-04T20:54:19.979Z UnknownHost ERROR [clojure-lsp.crawler:38] - Error while looking up classpath info in /Users/tommi/projects/metosin/malli Cannot run program "clojure" (in directory "/Users/tommi/projects/metosin/malli"): error=2, No such file or directory
The lookup is directly related with clojure-lsp running lein classpath
or clojure -Spath
Alright, check the clojure-lsp log file, you can set it with :log-path setting on .lsp/config.edn
➜ clojure-lsp --version
clojure-lsp 2021.07.01-19.49.02
clj-kondo 2021.06.18
Are you using the clojure-lsp official brew one?
hmm.. says classpath lookup failed in clojure-lsp
. tried to add brew-installed clojure-lsp
as the server.
I'd suggest test clojure-lsp on intellij and confirm if that issue happens
true. clojure-lsp might already have that and it could be ported
actually I wrote part of that diffing code in clojure-lsp ;) (not sure if that code is still used)
I think it can be improved by borrowing some ideas from clojure-lsp, especially the implementation of incremental diffing. or you might want to try clojure-lsp altogether in Cursive, it uses clj-kondo so you would get that for free as well.
(we have a ten year old codebase -- we have a lot of code that we would now write differently, especially as we were just learning Clojure as a team in those early days!)
How could I write a let in a clojure test and in the body some is statements?
That’s conditional compilation, yes. It can only go into a`.cljc` file. It won’t work in .clj
files (those are for Clojure only), .cljs
files (ClojureScript only), or at a repl (which is whatever type of repl it is)
There's also :pre
in Clojure, but it would probably be just as verbose.
For me at least it works locally now:
borkdude@MBP2019 /tmp $ bb -e '@(babashka.deps/clojure ["-Sforce" "-M" "-r"] {:dir "proj1"})'
Clojure 1.10.1
user=> (require 'medley.core)
nil
Dear Calva friends. http://calva.io/merch is just updated with a new design. It’s the Calva symbol at the front, and some silly Clojure code at the back, I named it “We do it with Rich Comments” 😀. Also some more availability of the existing designs. Please check it out! Amazon only lets me add a design or a market per day so it is slow populating with t-shirts. If there is some particular design you want to see in some particular Amazon store, please let me know and I’ll prioritise accordingly. While at it I’d like to highlight this from the Merch page: > To keep the admin of this shop to a minimum the merch is sold at production prize. There is no royalty going to anyone in the Calva team when you buy one of these t-shirts. You will represent, which is certainly a way to support the project. You are of course encouraged to support us via sponsoring as well: > > * https://github.com/sponsors/PEZ > * https://github.com/sponsors/bpringe
@U04V70XH6 hey Sean! going well, diving into my first Clojure job! Quite quite exciting! :the_horns: How about you?
I was browsing for wireframing tools and found one called Whimsical, was surprised to find out it was made in Clojure! Looks like it might be a good alternative to Balsamiq. Has anyone tried it?
So, has anyone tried Github's Copilot with Clojure yet?
This happens because the clojure task is a 2 step process: 1) deps resolved using tools.deps.alpha, 2) the actual clojure JVM process. But the options currently only apply against the second step where the process is launched.
It's still a rough plan, but the idea is to have clj->objc
and objc->clj
functions for structures like NSDictionary, NSArray, NSString, etc. For classes, you can use https://developer.apple.com/library/archive/documentation/Cocoa/Conceptual/KeyValueCoding/index.html, to set and get properties. That should make working with objective-c APIs possible from clojure, but not necessarily pleasant. There will probably be some amount of effort needed to make working with platform APIs more comfortable.
Clojure JVM emits one global function object per anonymous function expression, i.e. it doesn't create new functions in a loop, it re-uses the one global function and passes parameters as needed
This might be the best contributor patch I ever saw to Clojure: https://clojure.atlassian.net/browse/CLJ-2637
That's neat, the Apple documentation API, creating stubs would be straight forward. But I'm not able wrap my head around how the data structures will move in and out of the G+C compiled code to ObjC/Swift, if you get what I mean. Not sure how to put it clearly, but with stubs I'll know the types and signatures and all that metadata but how do I program against those data-structures when I'm writing in Clojure.
I ought to sell my team on jet vs jq. we're a clojure shop anyways and our mildly complicated jq is basically unmaintaintable
and I "trust" jvm clojure more
> I'm also curious why people are interested in using graalvm+clojure vs cljs+react native
@U8QBZBHGD You could, but jet
also already has a query language and the --func
option for normal Clojure functions
:bananadance::toot::clojure-spin:
is there a way to set environment variables? more specific: can I have clojure load environment variables from an .env file, at least for when I use the repl?
kinda curious about how well it would do with clojure
Where would you ask aws questions that aren't very clojure specific? Meanwhile, do Rest Api Gateway endpoints support websockets? The https://docs.aws.amazon.com/apigateway/latest/developerguide/apigateway-websocket-api-overview.html on websockets says it's for HTTP endpoints, as where the https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-vs-rest.html doesn't mention them all. Thanks for any help in advance,
I will make a post about this on Ask Clojure as soon as I have a chance.
I'm mostly interested in using guix as a dependency source. Guix packages many java libraries (and some clojure libraries, despite the above issues with building CLJS) that use the class path. The idea behind guix integration is that a classpath library in guix could be packaged to have a dependency on a non-classpath package.
yep, those are interesting cases, but considering the amount of traffic/questions I get from re-find.web I didn't think such a tool would be very much used. once you get the basics of Clojure you tend to not need such a tool anymore I think
is it possible to use java source when compiling clojure jars to be used by java app? https://github.com/bigos/JavaApplication3/blob/master/src/clojure/responder/src/jac/responder.clj
Does it happen when you use (shell {:dir ...} "clojure ...")
instead? if not, then it might be a bug somewhere in bb
Related to previous but different. For very common tasks that end up pretty much in all subprojects (eg. test
), I am trying to define them in my root bb.edn
and specify a :dir
when calling (clojure ...)
(where a subproject lives and has its deps.edn
file).
However I am having an issue with a dep that points to a :local/root
:
Error building classpath. Manifest type not detected when finding deps ...
In spite of the path to that jar being correct. Doesn't happen when executing directly from the subproject dirA list of random thoughts: There has been much discussion about GitHub Copilot. Assessments are ranging from “Hey this is useful for boilerplate code” to “A senior programmer doesn’t want this, also GPL”. I think there is something here that is worth exploring or learning about. I think Copilot might be the wrong approach, or rather too fuzzy and hand-wavy, but I think there is a real issue that is surfacing in these discussions: What we as programmers actually want to do is communicate intent, and this might or might not be accommodated by language facilities and abstractions of our platforms. For one, I think if we need tools to write boilerplate for us, based on previously written code, then we are just not using the right tool for the job, except if the intent is to actually write boilerplate so we can see the right abstractions emerging. In expressive, dynamic languages like Clojure we have the tools to semantically compress code - avoiding boilperlate. The actual problem is not writing code, but reading and understanding it. A REPL, first class data and functions, immutable data structures, metadata and so on can help us with that. Which is fantastic! But we’re still doing a kind of low level expression based reasoning by understanding smaller things and composing smaller things to larger ones. This bottom up, expression based reasoning is paramount to really understand a given program (or parts of it). But we have nothing to guide us through. This is maybe where some form of AI could help? It doesn’t need to be the kind of ML AI that is discussed above. What comes to mind first is spec and instrumentation. We have a way of saying “This piece of lego doesn’t fit on that piece of lego, because of this assertion.” - where the pieces are not just basic types, but very expressive shapes that declare assumptions and guarantees. What we cannot say is “Which assumptions are likely to be wrong?” and “What might be a piece that is missing between these lego tiles to satisfy these guarantees?“. Say I go from A -> B -> D, there is a tool that says: Try putting in C between B and D.
It started and we see a super a good attendance. You can also join and learn about “clj-fdb | Designing a Clojure library for working with databases (FoundationDB) by @U051S5XR3 Quick link here https://meet.google.com/qdf-jbpj-yrp
Now because it's annoying to wrap the List in a List calling the quote special form, Clojure also has a reader macro character for it, and so everything that is prefixed by '
is read as if it was wrapped in a List calling quote.
Alright, so what is this:
"hello"
If you don't know programming, you'd tell me it's the word hello surrounded by double quotes.
If you know programming you'd tell me it's a String whose value is hello
But in actuality it's just a bunch of characters, they take on a meaning based on some contextual semantics.
In the context of English reading, it is the word hello surrounded by double quotes.
In the context of Clojure reading, it is a Unicode String whose value is hello. That's because characters surrounded by double quotes in Clojure mean that they represent a Unicode String.
From this point on, lets remain in the realm of Clojure reading, so with that in mind, what is this:
:hello
It is an unqualified Keyword whose name is hello. That's because characters starting with a colon mean that they represent a Keyword.
So what is this:
hello
This is a Symbol whose name is hello. That's because characters not prefixed or surrounded by anything special mean that they represent a Symbol.
What is this:
("hello" "John")
This is a List with two Strings as elements. You know this because anything wrapped between open/close parenthesis represent a List in the context of reading Clojure.
Now what is this:
(hello "John")
This is a List where the first element is a Symbol and the second a String.
Now you might ask me, but isn't hello
in this case a function?
Well, no it is not, because I'm the context of reading Clojure, as we saw, this is a list of two elements, the first one is read as a Symbol, and the second as a String.
But after you read source text in Clojure, you get back what you read. So after reading the text (hello "John"
you now have a List of Symbol and String, this is no longer text, you hold now in memory an instance of a List object whose first element is an instance of a Symbol object and second element is an instance of a String object.
Once you have an instance of a List, you can ask Clojure to evaluate this List as code. Now we are in the context of Clojure evaluation, and as you see, Clojure can evaluate a data-structure like a List, that's why people say in Clojure "code is data(structure)". Because code is what can be evaluated, and in Clojure that can be, among other things, a List data-structure.
So if I were to represent this List in text once again, I would write (in the Clojure language):
(hello "John")
Now, after reading this and getting the List of Symbol and String, if I call eval
on it, which Clojure will do automatically when given a source file to run, or when sending a piece of source to the REPL (where it will Read and then Eval), well what Clojure evaluation semantics will do is that they'll take the first element of any list and look it up to see if there is a function of that name and then replace it by that function, where the rest of the elements in the list will become the arguments to it.
So when evaluating the List:
(hello "John")
Clojure will actually execute the hello function, now let's pretend the hello function is this:
(defn hello [name] (println "Hello " name))
That will return nil
. So after evaluating our list, we get nil
back.
Okay, but now we have a problem, because we read a List, but as soon as Clojure evaluates it, it'll become a function (or macro) call. So what if we want the List itself?
Imagine we had:
(def sum [numbers]
(reduce + numbers))
And so I wanted to write:
(sum (1 2 3))
See the issue? When we read this, we see that we have a two element List where first element is a Symbol (sum) and second element another List. That nested List contains three Numbers.
But now when Clojure evaluates this List, it'll consider sum
a function, which is correct, and pass it as an argument the nested Lists, and prior to function executing, their arguments are also evaluated, so now we have a List being evaluated again, and Clojure will consider 1
to be a function and it'll call it with 2 and 3 as arguments, this will fail obviously.
The problem is that since Lists represent function or macro calls when evaluated, how do you evaluate something to get a List back? And not have it be treated as a function or macro?
That's where quote
comes into the picture. You tell the Clojure compiler, the following form, please skip evaluating it, treat it simply for what it was read as.
So now you can do:
(sum (quote (1 2 3)))
And Clojure will evaluate this where it'll consider sum
a function, but this time it'll see that (1 2 3)
is quoted, and so it won't evaluate it, it'll just take the List as-is and pass it to sum as the argument.
It's a little meta, because of the homoiconicity, it makes it so that the textual representation for a List is the same as that for a function call, which means that you need a way to tell the compiler when it should be treated as a List or when it should be treated as a function call, and quote let's you do that, by saying don't evaluate what's quoted, treat them as-is the same as they were read.Ah, it has a Clojure CLI alias too, I'll add that to the practicali/clojure-deps-edn project. Thanks, this is a very useful starting point.
Is there any possibility/interest in integrating deps.edn with https://guix.gnu.org/? As a functional package manager, Guix seems to be relatively in-line with Clojure principles. There are a few advantages that I can think of to a guix integration. First, Guix allows an application/library to define dependencies on non-jvm components. Second, because packaging is a solved (ish) problem in Guix, many of the problems with Uberjars, such as diffuclty of embedding a JVM/JRE can be avoided. Finally, because Guix allows for more complex pacakge definitions than deps.edn, clojure code can (and currently is) automatically compiled by Guix upon installation. However, there is one major drawback to this integration. guix (at least in officially endorsed package channels) requires that all packages be built from source using a Guix build system. However, Clojurescript (which is depended on by many Clojure libraries via core.async) depends on many Google java libraries which are currently cumbersome to build from source in an automated fashion. Because of this, I have chosen to submit the clojure-tools package to an unofficial third-party package channel for now. I think, assuming we can overcome this build requirement (this is a one time cost), a Guix integration could be a major advantage for Clojure. Ideally, this would work in a similar manner to gitdeps, where a dep map could be specified like {my-guix-dep {:guix/package clojure-my-guix-dep}}
.
And think about what (list + 1 2)
returns and how evaling a list can really do anything at all. if you're familiar with C# or Java, consider how weird it would be to eval(IEnumerable<Object>)
or the like. And then recognize that (list + 1 2)
is using just regular clojure functions and a regular clojure datastructure
I’ve been learning iOS too lately and story boarding is different from HTML/CSS. Currently finding it better than the flow-spoiling experience of tweaking HTML/CSS. But that could just be the high of learning something new. But not sure how the tooling will work for this since the swift code and story boarding experience seem very coupled. Graalvm+Clojure native than Cljs+react since I think intuitively that the former might be far more performant. I think the interop with platform API is extremely important and a sustainable way of maintaining the bridge must be thought of. Java objC bridges have failed to be maintained in the past. It would also be an interesting approach if I could write the UI bits in Xcode and controllerish logic in Clojure. If perf is great with g+c then it would be the best thing ever.
I've been thinking about the best way to target mobile with clojure for a while. I saw a couple people join and thought it might be worth sharing what I've learned so far. Now that graalvm has added iOS and android targets, I don't think there are any technical roadblocks that would prevent clojure on mobile, but there is plenty of work to do. Recently, I was able to build a simple todo app in clojure that ran on my iPhone. I intend to publish the example once I clean it up. I published a very bare bones proof of concept at https://github.com/phronmophobic/mobiletest. It even can eval clojure code at runtime thanks to sci, :sci: . The next steps, as I see them, are: • Decide on a strategy for UI graphics and events (SwiftUI, Epoxy, React Native, membrane, something else?) • Decide on a strategy to interop with platform APIs • Improve tooling and documentation • Decide on a strategy for repl driven development (or else, why bother 😛). I've started with iOS since that's the mobile device I regularly use, but I haven't seen anything to indicate that the same process wouldn't apply to android (before clojure, I was working on cross-platform mobile games in c++). I would love to hear any feedback or ideas: • What do people think would be a good fit for building UIs? • What kinds of apps are folks hoping to build? • I'm also curious why people are interested in using graalvm+clojure vs cljs+react native. Personally, I just don't like html/css/javascript, but realistically, it seems like folks have found cljs+react native to be productive.
odd, everything seems correct, and I use hooks with clojure-lsp and they work fine
The only thing logged at an ERROR level is clojure-lsp crawler saying it imported some of my config to the clj-kondo folder
You can get it via the :log-path of the return of lsp-clojure-server-info
That's odd, any errors on the clojure-lsp log?
So I'm just trying out clojure lsp for the first time on a machine that can actually run it, and it's looking pretty cool so far! One question: I have hooks set up with clj-kondo to resolve a particular macro, but it appears that clojure-lsp isn't recognizing that hook and is giving me a warning about an unresolved macro. Is there some configuration I need to add to have it pay attention to the clj-kondo config?
defn
is just shorthand or the long-form fn
invocation.
ps. that’s a first for me, seeing a todo
in the source.
Clojure 1.10.3
user=> (source defn)
(def
...
defn (fn defn [&form &env name & fdecl]
...
;;todo - restore propagation of fn name
...
I've been updating depstar
so it has multiple "tasks" that can be run individually via -X
or together, but I'm waiting for tools.build
to become available so I can finish that work off in a way that is compatible (with tools.build
) so you should be able to swap out some of the built-in tasks for depstar
s version of them (sync pom.xml
, compile Clojure, build a JAR or uberjar).
Ironically I decided not to use clj-new
this time to force myself to learn these things myself. haha. Yeah I have all those clojureD talks lined up to watch, they all look interesting.
(and soon these tools will be even easier to install and use -- see Alex's clojureD talk that was just released to YouTube today)
If you have the :new
alias (from clj-new
) and run clojure -X:new :template app :name chase/example
you'll get a small, simple project that uses -X
for most stuff.
Clojure loads that when it starts up.
I've found the clojure-goes-fast blog posts generally helpful, http://clojure-goes-fast.com/blog/
(! 738)-> clj -A:bench
Downloading: criterium/criterium/maven-metadata.xml from clojars
Clojure 1.10.3
user=> (require '[criterium.core :refer [bench quick-bench]])
nil
user=> (bench (reduce + (range 10000)))