This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-01-12
Channels
- # arachne (1)
- # aws (2)
- # beginners (123)
- # boot (22)
- # boot-dev (8)
- # chestnut (3)
- # cider (38)
- # clara (36)
- # cljs-dev (148)
- # clojars (2)
- # clojure (76)
- # clojure-austin (2)
- # clojure-greece (1)
- # clojure-italy (6)
- # clojure-russia (5)
- # clojure-spec (8)
- # clojure-uk (65)
- # clojurescript (45)
- # core-async (38)
- # cursive (9)
- # data-science (5)
- # datomic (28)
- # docs (1)
- # emacs (2)
- # fulcro (34)
- # hoplon (18)
- # jobs-discuss (7)
- # keechma (8)
- # lumo (5)
- # om (3)
- # onyx (31)
- # parinfer (1)
- # pedestal (1)
- # re-frame (20)
- # reagent (5)
- # ring-swagger (16)
- # shadow-cljs (56)
- # spacemacs (11)
- # specter (8)
- # sql (5)
- # unrepl (29)
- # yada (6)
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] ...)
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.
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
?
(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
user=> (hello 123)
(hello 123)
124
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?
@boldaslove156 executing standalone clojure scripts without creating a project comes to mind : )
i.e.
$> 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 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 (https://pragprog.com/book/dswdcloj2/web-development-with-clojure-second-edition). 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: https://www.youtube.com/watch?v=lRHPZXKQVLk 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}}
@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
(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}}
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.
@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
that's all
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
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 http://www.luminusweb.net/docs
here's some choices you can make while making a new luminus project http://www.luminusweb.net/docs/profiles.html
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
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
(plus docs)
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
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?
presuming you’re using Cursive with IntelliJ, my experiences have been best with both Maven and Leiningen
and have done both with Java + Clojure
personally, I find Gradle baffling :)
I’m not sure there is any difference between Cursive plugin and Cursive IDE
you might want to ask on #cursive
the author is there and can probably help
it’s there :) you should have a link you can click from those messages
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: http://docs.datomic.com/pull.html#multiple-resultsa) keywords can’t have metadata (they are cached and shared) and b) there is no syntax or function specifically for that
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}
Is there a way to add that information to the entire map though?
What does that mean?
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/m
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"}
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.