This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-03-06
Channels
- # aleph (2)
- # arachne (4)
- # aws (3)
- # beginners (196)
- # cider (131)
- # cljs-dev (208)
- # clojure (193)
- # clojure-boston (1)
- # clojure-dev (26)
- # clojure-greece (4)
- # clojure-italy (26)
- # clojure-losangeles (1)
- # clojure-russia (11)
- # clojure-spec (40)
- # clojure-uk (78)
- # clojurescript (168)
- # cursive (25)
- # datascript (1)
- # datomic (31)
- # docker (8)
- # docs (1)
- # emacs (20)
- # fulcro (62)
- # hoplon (3)
- # jobs (1)
- # leiningen (3)
- # luminus (1)
- # nrepl (25)
- # off-topic (10)
- # other-languages (3)
- # parinfer (11)
- # planck (37)
- # portkey (54)
- # protorepl (11)
- # re-frame (2)
- # reagent (19)
- # remote-jobs (1)
- # ring (2)
- # rum (8)
- # shadow-cljs (23)
- # spacemacs (4)
- # uncomplicate (6)
- # unrepl (77)
- # vim (56)
- # yada (2)
When I try importing a class definined in the same project I get "class not found" errors
is the class created by a namespace?
if so, you must require the ns, or otherwise cause it to be loaded, before using a class it defines
where does the class come from?
what I mean is, how is the class generated? from clojure? from java? who compiles it? when?
so the workflow is that you compiled the java, then started the repl, and it couldn't find the class?
maybe an issue with the classpath in the process running java and using clojure.java?
@emccue a start would be to see if the target-path lein / lein-javac are compiling to is on the classpath of the java process
unless the java process is using your jar
if a clojure class is generated twice (via reload for example) the two classes have the same name but aren't the same class
similar issue with methods/protocols
this can cause similar but not identical bug behaviors
This started as a AOT compile project and im pretty glad that the requirements were bendable to the point where I could make it all dynamic
rebel-readline @petrus
itβs not merged yet but you can check out this branch locally and try it yourself π
No matter now. Found this https://github.com/clojure/data.json.
I'm probably still not grokking clojure symbols properly...in clojure.reflect, how would I go from the symbol returned for the parameter-types
to the actual class, i.e.:
(let [type (first
(:parameter-types
(first
(filter #(= (str (:name %)) "matches")
(:members (reflect/type-reflect String))))))]
(prn :type type :class (class type)))
=>
:type java.lang.String :class clojure.lang.Symbol
where I want class java.lang.String
?ah (resolve symbol)
seems to do it...ok I retract my question and advance to the rear
Does anyone here recall a demo of Pedestal showing a sales funnel, with dots migrating between pulsating circles that showed customers in various stages of their shopping experience? It was shown at a ClojureConj a few years agoβ¦..
if you have questions about that demo, I can probably point you to someone useful
is there a shorthand of doing something like this?
(defn generate-players
[user computer]
{:user user
:computer computer})
records are pretty close:
(defrecord Player [user computer])
(into {} (Player. "foo" "bar"))
{:user "foo", :computer "bar"}
Not something that maps file extensions to mime types, but something that really looks into the file searching for headers/blocks?
I have found http://tika.apache.org/
And it's clojure wrapper https://github.com/michaelklishin/pantomime
I use pantomime, it's cool
Is there a channel here to discuss: https://github.com/clojure-vim/acid.nvim https://github.com/clojure-vim/neovim-client https://github.com/jebberjeb/clojure-socketrepl.nvim #clojure itself is probably too general
@qqq There's a #vim-fireplace channel -- maybe that should have its focus expanded to other vim stuff?
@seancorfield moving over; thanks!
I am having a bizarre experience where the falling returns false
at my repl: (= "Date" (first ["ο»ΏDate" "Apple" "Orange"]))
I suspect it is because the vector is read in from a CSV so perhaps there is some kind of encoding that makes the letters of the word actually different than they appear? Is there a way to convert the imported text into a "standard" encoding?
it would appear that if you copy/paste my code snippet exactly, you will also get false
at any repl, but if you type it out yourself, then you will get the expected true
@ajs to debug you could look at (seq (.getBytes s))
and compare for each string
@ajs I see this in my repl:
so there is an underscore there, that is not appearing anywhere in my repl? why would yours show that?
sorry, not sure that worked, slack gave me some complaint about storage space
I bet it's a non-printing unicode
@noisesmith was trying to figure out what thatβs called, one of those gave me no end of trouble a little while ago
@ajs one approach is to use a regex to strip that garbage out
Β―\(γ)/Β―
Iβm in cider, could be an emacs vs. terminal repl thing
yeah, dunno
(String. (byte-array [-17 -69 -65]) "UTF-8")
=> ""
looks like something along the lines of (re-find #"[a-zA-Z]+" (first ["ο»ΏDate" "Apple" "Orange"]))
(.replaceAll "Date" "\\p{C}" "?" )
=> "?Date"
so you could use "" instead of "?", maybe there's something more elegant
(Character/codePointAt "ο»Ώ" 0)
=> 65279
(Character/getName 65279)
=> "ZERO WIDTH NO-BREAK SPACE"
@lxsameer my first recommendation is to always use the Java libs, unless they don't do what you want. There's just not enough eyes on Clojure wrapper libs.
Java libs are often produced by the vendor themselves, that helps a lot when trying to find tutorials, and troubleshooting, and even when talking to the vendor themselves.
3rd party wrappers will often be blamed by the vendor when there's some bug that appears. When you use the vendor's libs, they can't blame that layer anymore π
@tbaldridge Yeah good points. I'll go with the java client then. Thanks
tricky bastards: vmware won't let you run vmware console from within a vm
^ emoji game on point, @kenrestivo @zylox!
I'm trying to reset a private atom for testing. I'm using alter-meta! and it seems to work just fine at the repl but it blows up when compiling
I suspect that the compiler sees the private atom and freaks out, but it should work at runtime
so you are trying to update the metadata on a private atom, which works in a repl, but this doesn't work when running your tests?
FYI the compiler used in the repl is the same one that is used when running tests, and clojure doesn't have an interpreted mode
Best thoughts on/resources for making Clojureβs flavor of simple also beginner-friendly (not easy, mind you π)? I fell in love with the language and its primitives/view on development because I had the great luck to land on a team of awesome senior devs using it effectively. I want to have a goto set of resources to help people experience that banana without also having to bring the monkey (pushing through tooling setup), the tree (pre-existing team), and the jungle (sorry I stretched this metaphor too far). Will ask this differently phrased in #beginners as well.
what do you mean by 'Clojure's flavor of simple'? 'simple' in the context of Clojure is merely one of the lesser-used meanings of the word: 'Composed of a single element; not compound.' (i.e. 'simplex')
Yes, that one. Itβs maybe obvious that one of the side effects of making things simplex is that you also make them separate, but Iβve been thinking about the consequences of that kind of simplification a lot recently. For someone starting out one consequence is that it makes for many entry points at each level of simplification, e.g. I read the Rationale at https://clojure.org/about/rationale and at the end it takes me at the end to Features (https://clojure.org/about/features). I think itβs possible because of this branching factor for people to spend inordinate time down minor branches of the path, and have observed this when introducing people to the language/libs/tools: Iβm looking for something that teaches how to learn Clojure, i.e. gives a strong heuristic for searching the frontier.
More concisely: resources/unifying values to help people see the forest (a bunch of possible DAGs of learning to go follow) for the tree (the reasons the languageβs DNA caused it to branch out into these separate paths here) at each juncture.
Something like a digest of Clojureβs instantiations of SICPβs 3 language mechanisms: - primitive expressions, which represent the simplest entities the language is concerned with, - means of combination, by which compound elements are built from simpler ones, and - means of abstraction, by which compound elements can be named and manipulated as units.
I don't think it's the 'simple' that makes it hard to learn, it's the garbage-in-garbage out, and also the host leaking through. But lots of people want to paint by numbers and plenty of other languages do a good job at that. The thing that 'simple' itself is responsible for is delaying gratification.
Simplicity doesn't necessitate something having many 'entry points'. The reason Clojure has all those features is that Clojure isn't merely an academic exercise: it's a practical language designed to be used to solve real-world problems, robustly and effectively, and those features are what Rich Hickey considers important in achieving that goal. They are a separate concern to its underlying philosophy of simplicity (in syntax or in semantics). Dynamic development doesn't follow from simplicity; nor does concurrent programming; or being a hosted language. They're orthogonal decisions.
Scheme might be a better choice for learning, since even though it doesn't do any better at 'simple', there's just less stuff, and it's introduced gradually in a well-considered order by people who thought a lot about teaching. ML might be a better choice because interacting with a complex compiler is probably going to help a lot for the earliest and most trivial kinds of mistakes.
In addition, the SICP mechanisms are just about the core language (e.g. def
, let
, fn
) are they not? Are you asking about Clojure's core, or about Clojure's features beyond that?
Or about how the http://clojure.org website is structured (Rationale leading through to Features etc.)?
Clojure has a tiny amount of operators built into the compiler (https://clojure.org/reference/special_forms), but that's barely scratching the surface of Clojure as a whole
I think the way https://aphyr.com/tags/Clojure-from-the-ground-up approaches explaining Clojure is quite good
@U61HA86AG thanks for your notes and questions! I think βfeaturesβ is indeed what I mean by entry points: each simplex feature is an entry point for a learner (e.g. vars vs refs vs agents vs atoms) at each point of considered language simplification (although note that in this case https://clojure.org/about/state is an ideal guide/motivation!). Itβs in this sense that I mean there are many entry points at different language junctures due to simplification (which yet again is a good thing: it lays bare the false dilemma between Pythonβs one obvious Pythonic way and Rubyβs AllTheThingsAndSyntaxes design choices at important points in language design).
Understand that I am entirely in agreement with:
> The reason Clojure has all those features is that Clojure isnβt merely an academic exercise: itβs a practical language designed to be used to solve real-world problems, robustly and effectively, and those features are what Rich Hickey considers important in achieving that goal.
but I am also a teacher by trade and disposition: I want to show and motivate and enable people as efficiently as possible, and with as high a conversion rate as possible, to see whatβs so beautiful and useful about this sort of simplification cum pragmatism.
So Iβm just trying to find high leverage tools and paths and principles so that people can join in the fn
.
Re: SICPβs mechanisms, yes absolutely, itβs about def
, let
, and fn
(actually values, lists, and def
/`let`/`fn`/application to be precise pointwise) but (recursively) much more too: itβs about the basic things you introduce at any level of abstraction, the ways you can put them together to express/do useful things, and how you can then name/manipulate/generalize/export that usefulness to other realms.
I had forgotten about aphyrβs project: thanks so much for the reminder! Will post back here with the completed list/introductory structure I get out of this exercise.
I dabble in teaching myself, and I completely get where you're coming from! Please know I'm merely trying to get to the core of your question, so that I can better answer it π
Awesome, I sensed as much, but neither text conversations nor S-expressions is very often sufficient to imply shared goals, so figured I would try to make them explicit π really grateful for your questions and thoughts here.
One thing I feel is that the full scope of Clojure isn't really relevant to a learner. The only bits of Clojure they need to learn are those they're going to use; they can learn about the rest on an as-needed basis. It doesn't matter that Clojure has refs, agents, and atoms until you're in a position where you need to know about all of them. I have a vague sense of the differences between them, but since I've only ever needed to use atoms and vars so far, I don't actually need to
you can get very far only knowing about the language fundamentals, and perhaps a small but mighty subset of the standard library - the rest you can learn as you go
Whereas trying to isolate a minimal subset of, say, Ruby might be more difficult, since everything is built into the language, so you need to know about them, with Clojure, being a lisp, you can get by just fine without knowing most (or even all) of clojure.core, since you can write it all yourself once you've grasped how to write macros
the only time you need to know about clojure.core functions is when reading other people's code really, but that's rather far into the learning process
Thatβs a great point. Core of my question: what language features, ancillary tools/materials, ideas, and experiences have you found unusually effective in teaching newcomers to Clojure to ()
for themselves, and complementarily: is there anywhere you have observed people disproportionately getting stuck and dropping out? Any of three audiences: people coming from Javascript/web development; people coming from programming servers, especially in OO/OO+scripting languages; and beginners to programming. Iβm not yet ready to believe that JS or Python is better to begin in π
I actually think JS/Python are worse to begin in, due to their inherent complexity/largeness
Likewise, but I think more people successfully begin there, at least by observation, thus driving me to this question.
Well, one thing i've observed is that beginners don't necessarily need simplicity. What they need is small, easy, chunks to get their head around (which sure, it's helpful if the language itself adheres to those chunks, but it's far from a necessity). That's where their teachers come in - how you're being taught a language is vastly more important than the language itself
JavaScript is a very large language, but as long as you can start with console.log("hello world")
and then move on to functions, it's not really an issue
teaching is a UX problem - doesn't matter that Wikipedia is vast, since its interface lets you explore it bit by bit, starting with the specific article you need at that given moment
a teacher is the interface between the student and what they're learning, and so the same sorts of approaches apply
@gtrak important point about the host leaking through. Re garbage-in-garbage-out, do you mean malformed/mistaken expressions -> yucky errors
? If so thanks for the reminder that I have highly tuned stacktrace filters by now: really easy to forget as a blocker to interactive learning.
the biggest reason Python and JavaScript see so much success among beginners is that they're popular, so there's a lot of people teaching it and wanting to learn it (rather than any inherent learnability)
Yes, and good teachers also deftly redirect requests to get themselves out of the picture and to get students to the right resources/habits of resource finding at the right time. This is both to scale teaching as well as to self-obsolesce as a teacher! Want to keep growing my bag of tricks π 301 Knowledge Moved Permanently
Some insightful things to read: http://worrydream.com/LearnableProgramming/ https://www.maa.org/external_archive/devlin/LockhartsLament.pdf Don Norman's The Design of Everyday Things (designing a user interface to be intuitive, approachable and delightful is isomorphic to teaching a given subject to be intuitive, approachable, and delightful: they're both about learning)
Eric Normand's https://www.youtube.com/watch?v=jJIUoaIvD20 is also quite good (in particular, the part about using physical metaphors to drive intuition)
An excellent example of using real-world metaphors is in Eric Normand's course on Category Theory: https://purelyfunctional.tv/courses/category-theory/
Nice, thanks, I think I was at the conj talk above; thanks @U050P0ACR!
very good point about self-obsolescence by the way. it's vital to teach learners how to become more adept and more self-sufficient learners; to become their own teachers. give a man a fish and whatnot π
though there's somewhat of an art to balancing student agency and teacher aid: too much of one and the students don't learn enough about the subject to be self-sufficient, too much of the other and the students never learn to be self-sufficient
i recently had a teacher who left too much to the students, and needless to say my knowledge of and confidence in the subject suffered greatly
re: 'what language features, ancillary tools/materials, ideas, and experiences have you found unusually effective in teaching newcomers to Clojure to ()
for themselves, and complementarily'
i think the repl is really important for this. it's one thing to talk at someone, but when that person is trying things for themselves and seeing the specific results of their own exploration, it really helps them to piece it all together. especially with things like https://www.maria.cloud/ and https://github.com/google/clojure-turtle, since they turn Clojure code into something more tangible
and that's also a major reason behind JavaScript and Python's success with beginners I feel. JavaScript has the browser, and Python has a REPL (albeit less interactive than Clojure's, though IDLE makes it somewhat better)
(do (alter-meta! #'ns1/testatom assoc :private false) (reset! cirrus.domains.database/testatom "yo"))
oh, so you aren't altering meta on the atom, you are altering meta on the var holding the atom
Exception in thread "main" java.lang.IllegalStateException: var: ns1/testatom is not public, compiling:(proj/test.clj:134:15)
is the do at the top level of the ns? I know there are special case rules for top-level do
that too
@datran that is, (do ...) at the repl, or at the top level of an ns, doesn't act exactly like (do ...) inside a defn
because deref of a var ignores the metadata on the var
right, deref of a var gets its contents - a var is just another mutable container
thanks very much @noisesmith @zylox! π
arguably needing to do something like that exposes a design flaw in the original code - a mutable singleton that determines the correctness of your code is usually a bad idea - many prefer to pass such a thing as an argument rather than hard-code the global availability
that makes testing much easier
Re: the top down part, Iβm doing some sort of CBT self-talk therapy on a thread at https://clojurians.slack.com/archives/C03S1KBA2/p1520375632000516?thread_ts=1520373219.000385&cid=C03S1KBA2; let me know if you have any insight there too π
here's a construct that comes up all the time, and I'm wondering if there's some kind of shorthand for it: (if (pred x) (f x) x)