Fork me on GitHub

Hi guys! i'm just starting and I'm running it an issues whenever I lein run in my terminal I get the error "Exception in thread "main" java.lang.Exception: Cannot find anything to run for: clojure-noob.core" Ive googled many times, but the best answer I got was to check the project file to see in the main: is there, which it is. I've had my dad, who is a programmer look over it, code looks right, but doesn't know enough about clojure to figure out where the issues is stemming from. help, please.


it needs to be called -main, not main


in the project file or in the core file?


in the namespace, the project file should list the namespace


so if using leiningen in project.clj you would have :main clojure-noob.core and in src/clojure_noob/core.clj you would have (defn -main [& args] ...)


I can't believe how powerful this language is. It's almost terrifying.


OH NOW I SEEE @noisesmith that makes so much more sense thank you


Could anyone link me to some reading material regarding writing highly testable Clojure code? Of course everything's great in the world of pure functions, but I really want to know how things look when things like databases come into the picture. I understand Clojure cares a lot about this kind of thing! 🙂


No link off hand, sorry. A great rule of thumb is to separate logic from IO, most code that does any meaningful logic (that is, something worth testing) should be writable as a pure function, which is optimal for testing. Then the code that interacts with files or the network or other side effects can be a very thin wrapper around some library or built in functionality, using your pure functions for all data processing. There are libraries that help facilitate this approach including stuartsierra/component.


Interesting, I'll check out this library.


Hi, I'm trying to set focus on an form input element by using reagent/create-class and :component-did-mount Not sure if this is the best way to go, so do anyone have a "best practice" for this I can look at? Thanks!


What problems can't be solved by lein or boot but can be solved by clj ?


Hello, why didn’t compile defmacro in Repl? did you see similar?


(defmacro hello 
          #_=>   [x]
          #_=>   (prn &form)
          #_=>   `(inc ~x))

CompilerException java.lang.RuntimeException: Unable to resolve symbol: defmacro in this context, compiling:(/private/var/folders/zz/zyxvpxvq6csfxvn_n0000000000000/T/form-init8739309985101977162.clj:1:1) 


works for me:

user=> (defmacro hello [x] (prn &form) `(inc ~x))
user=> (hello 123)
(hello 123)


I see.. Hmm..


did you type it on one line or many lines?


I copied from sublime, but no problem before this. I think, something I installed or else


ok, then I don’t know, sorry 😕


thx 😕 yes that is strange.. I try to find out what happens


ok solved with a restart. sorry


If I was looking to create a web-app in Clojure that needed server-side rendering (e.g. return flat pages, not much Ajax), which clojure-webframework should I pick?


Luminus? Or a there other contenders?


@boldaslove156 executing standalone clojure scripts without creating a project comes to mind : )



$> echo '(println "Hello World!")' > test.clj
$> clj test.clj 
Hello World!
in a past life I was a groovy programmer and even today I write a lot of ad-hoc code for systems automation and command line usage and this kind of light footed ad-hoc write-and-throw-away dev process is perfect for that scenario


@hans378 I'm starting to use Rum. It's a library, not a framework, so not too big


@hans378 Clojure doesn’t necessarily have ‘frameworks’ in the conventional sense, i.e. Django, Rails, etc… More like conglomerates of libraries that come together to solve problems, i.e. Luminus. If you’re just getting started in Clojure web app development, I’d strongly suggest either using Luminus or following Web Development with Clojure ( Luminus will get you up and running faster while WDwC is a much deeper dive into the subject


@stephen067 i like the idea of a webapp toolkit as library, not a framework. Will look into Rum before I go for Luminus, which seems the defacto standard.


to be clear, there is no luminus library, it's a collection of libraries - you can use rum with the libraries luminus provides (just leaving out the lib that renders to the dom)


Cool. Yes, these are all good points. I am basically following along with this talk: but using Rum instead of Hiccup, since I plan on adding React components later.


Is it possible to use clojure.set/intersection with sets of maps given a map of which keywords to compare like in clojure.set/join? ie:

(join #{{:a 1 :b 2}} #{{:c 1 :d 4} {:c 5 :d 7} {:a :c}) => #{{:a 1 :c 1 :b 2 :d 4} {:c 5 :d 7}}


would (apply join set_of_maps) do it?


the code you provided there doesnt work btw


@stephen067 Could you say what luminus actually is for people who are generally familiar with the basic approaches to web development? “micro-framework” as it says on the front page doesn’t mean much to me.


@pablore might be easier if you actually gave an example of what your input is and what your desired output is


I want to intersect sets of maps like I would join them


that’s not what i asked.


im writing the example now


(intersect #{{:id 1 :name "foo"}
                   {:id 2 :name "bar"}}
                #{{:uuid 1 :domain "asd"}
                   {:uuid 5 :domain "sss"}}
                {:id :uuid}) => #{{:id 1 :name "foo" :domain "asd}}


seems like this would be pretty easy to do with reduce


although maybe something like it doesn’t really exist already in the core lib


I don't know of anything in the core lib that does what you want. I would recommend copying clojure.core/intersection's implementation, and modifying it to your liking.


ended up doing a filtering function for that


thanks anyway!


@lee.justin.m it's a large collection of libraries and default settings that you clone to make a new project


(specifically via lein new)


@lee.justin.m I don't have any experience with Luminus. From what I read on the page, it is the closest thing in Clojure to Rails or Django, but not really since it doesn't look like it comes with "batteries included". I'd defer to what the others have said about it.


@noisesmith yea i got that much 😛


what it actually is is a bunch of opinionated choices about libraries to use and how to use them


I was just hoping to understand what flavor of choices they made. Trying to skim through the landing page on the docs it seems like it is a templating language that hooks up to an RDBMS.


it uses a lib that templates


it uses a lib that uses a db


it is nothing but lib choices


okay wait don’t parse my words too finely. i get that it is more than a language


no, it's not even a thing that exists after creating your project


it's a template to clone


the luminus docs will guide you into choices you can make while rendering the template (creating a new project), but there's no luminus that ends up used in your codebase once you have the project


yes, but once you’ve cloned it, it is good to know what style of development you’ve gotten yourself into. it appears that the luminus way is to write some html with tags that get replaced. that’s what i mean by templating.


that's... one thing that one lib luminus gives you does


and it's perfectly valid to make a luminus project that doesn't use that lib


here's some choices you can make while making a new luminus project


I would say that the clojure ecosystem doesn't really have a "rails" or "django," it's got a wide selection of libraries that you can mix and match to build a web app, and what luminus does is give you kind of a jump start on putting together a workable set of libs.


so its like super-lein for a collection of server and client side web development libraries and tools. the value add is to somewhat limit the available choices and do some work to ensure they all have a greater than zero chance of functioning once you install them (?)


there was caribou (I was one of the core devs as my first clojure job half a decade ago) but I don't really recommend it for new work


and a bunch of documentation for what to do once you’ve isntalled


leiningen looks at your project.clj and decides which deps you need, luminus creates a project.clj and a minimal working codebase using those libs


Yeah, actually I'd say the docs are a big value-add actually. Handy to have all in one place like that.


you don't install things with clojure btw (in normal usage)- your dep manager keeps a cache of things you use and fills it as needed, and hooks them up each time you use it


so luminus is a lein add-on/plug-in with a collection of presets that makes it easy to install a variety of functional web development software for both client and sever side development; it also provides extensive documentation on how to use the software once you’ve installed it. something like that? because knowing that accelerates my understanding of what i’m reading by a big factor. it is also lets me know that it is not rails.


I remember caribou! It was pretty cool as I recall.


@lee.justin.m it's a template that gives you a bunch of libs if you clone it


it doesn't provide any add on or plug-in code


and as mentioned previously, it doesn't install anything


(other than leading to some things being cached etc.)


If you look up how to write a leiningen template it might be helpful in understanding what luminus actually is. I've written a lein template or too, it's not really hard.


oh right! - a template is code that generates source files and config


okay. i mean aside from the fact that i’m using the wrong words, the substance seems right.


well words mean things - luminus doesn't have code you use other than by generating your project for you (then you go ahead and edit etc.)


in my feeble brain, “causes stuff to be downloaded and available to the compiler” == install


but it doesn't even do that - it generates a project file, leiningen does all the downloading and such based on that project file


That's roughly the idea, but I personally would say "generate" rather than "install"


oh come on that’s just silly. then you could say leiningen doesn’t really download anything because its really the operating system…


what I'm saying is you run luminus, now you have a project file


after that, you are done with luminus - it doesn't do anything other than generating some start up code and config


you called it a "super lein" eariler - it generates a config file that lein can use but duplicates no lein functionality


When you say lein new foo my-app, leiningen goes and gets the foo template, which contains probably some predefined directory structure and template files, then does the usual variable interpolation to generate the project files for my-app


Anyone here test their specs for validity or is that overkill?


Hey all, anyone here use Java and Clojure in the same project?


I do and successfully have things running and building with Gradle.


However, I have yet to find a way to run the project in my IDE, Intellij, since Intellij’s compilation of my Java code cannot see the compiled Clojure code. Any tips on getting things set up correctly?


are you using cursive?

Alex Miller (Clojure team)21:01:12

presuming you’re using Cursive with IntelliJ, my experiences have been best with both Maven and Leiningen

Alex Miller (Clojure team)21:01:23

and have done both with Java + Clojure


I am using the Intellij Cursive plugin.


It isn’t an option for me at the moment to switch to Maven.

Alex Miller (Clojure team)21:01:12

personally, I find Gradle baffling :)


I am not using the Cursive IDE however.


I have heard that the constraints of Maven are good, which seems pretty accurate.


I just am already used to Gradle so I go forward with that.


Actually, the problem I have isn’t with Gradle. It is with my IntelliJ setup I believe.

Alex Miller (Clojure team)21:01:05

I’m not sure there is any difference between Cursive plugin and Cursive IDE


At least, I think my problem is with IntelliJ

Alex Miller (Clojure team)21:01:28

you might want to ask on #cursive

Alex Miller (Clojure team)21:01:37

the author is there and can probably help


Awesome. Is that a channel in this Slack or in another slack?


I just don’t see the #cursive on the channel list


ok. new to slack, a bit.

Alex Miller (Clojure team)21:01:51

it’s there :) you should have a link you can click from those messages


Ok, thanks!

Drew Verlee23:01:32

Whats the syntax for maps with namespaces? I want to attach data to all keys in a map, is there a shorthand for that?

(f {:name "drew" :age 10}) 
=> {:person/name "drew" :person/age 10}
My immediate problem is that datascript seems to be returning a list contaning a map with the datoms i want and i’m looking for it just to return a list of maps (not a list of lists of maps). I think it might be related to this:

Alex Miller (Clojure team)23:01:17

a) keywords can’t have metadata (they are cached and shared) and b) there is no syntax or function specifically for that

Drew Verlee23:01:46

maybe this isnt the right channel for the later part.


@drewverlee if your clojure version supports it, clojure will show you the shorthand

Clojure 1.9.0
+user=> {:foo/bar 1 :foo/baz 2}
#:foo{:bar 1, :baz 2}

Drew Verlee23:01:04

Is there a way to add that information to the entire map though?


I guess you want to change the namespace of the keys in a map? If so: Specter version:

user=> (def m {:name "drew" :age 10})
user=> (setval [MAP-KEYS NAMESPACE] "person" m)
{:person/age 10 :person/name "drew"}
Vanilla version:
user=> (into {} (for [[k v] m] [(keyword "person" (name k)) v]))
{:person/age 10 :person/name "drew"}

Drew Verlee00:01:34

Sorry Alex, on my phone. I was trying to do o what schmee showed. But it's probably not related to my core issue, I'll hunt around in the datomic docs to understand the behavior better.