Fork me on GitHub
#beginners
<
2022-02-07
>
Neil Barrett00:02:25

Thank you so much phronmophobic.

Neil Barrett00:02:04

I didn't get an error message

Neil Barrett00:02:03

I'm running my code in Clojupyter. I tried it in Calva as well, and didn't notice an error there either. How are you running the code?

hiredman00:02:05

I am not aware of that callback ever not taking am argument, but I had recent patch that fixed something deep in the bowels of core.async where it was attaching callbacks that took zero args, so maybe that was the case at one point

Neil Barrett00:02:24

Thanks hiredman - it was a very old presentation, so I'm sure it's because things have changed.

John Bradens03:02:47

I noticed some clojurescript projects have clj files, and some don't. For example, projects made with luminus have clj files. But projects made with figwheel don't, it's only cljs files. Why is this?

lsenjov04:02:44

If you’re using macros of any form, they must be written in Clojure. The cljs compiler uses the clojure to expand the macros first, then transpiles the cljs to js

John Bradens04:02:41

Ok so it sounds like, for the tutorials I've done that are only in cljs it's ok because there aren't any macros, but for a real production application, it would probably use clojure & cljs?

John Bradens04:02:11

I'm a newbie but I'd assume that a real-world application, like a facebook or youtube clone would use some kind of macros right? Or not necessarily?

bbss04:02:33

not necessarily used, macros are a sharp tool, can do awesome stuff but also lead to hard to debug issues if not used carefully. You can mix clojure and clojurescript in a codebase using .cljc, where you can use reader conditionals to say how to evaluate the code depending on the platform reading the file. Many cljs codebases indeed still have .clj files because if you want to use macros in cljs the jvm is still needed because they run at compile time.

bbss04:02:59

however, I think luminus is a project that uses clojure and clojurescript. So perhaps the .clj files there are just clojure?

John Bradens05:02:03

Yes, Luminus has .clj files, and cljc files, and cljs files. Is that normal for a big production application? What I'm trying to understand, is that I've been doing some clojurescript tutorials that use figwheel, and these projects don't have any clj or cljc files. Only cljs. Is that normal, or does it only really happen for little tutorial type apps? :thinking_face:

John Bradens05:02:26

For example, if I want to create a facebook clone, would I have to use clj, cljc and cljs in my final production ready code? Or would it be possible to create something so complicated with only cljs files, similar to the little tutorials I've done with figwheel?

lsenjov05:02:32

If you’re running full-stack clojure, then you’ll probably have a mix of all. If you’re only using it for frontend work, you’ll have mostly cljs files, with a couple clj files around for macros/occasional other scripts

1
teodorlu09:02:01

Yup -- there's absolutely no downside of starting simple with just .cljs files. If you need to write macros/scripts at some point, you can add some .clj files then 🙂

👍 1
Benjamin09:02:15

(condp
      =
      (type my-err)
      clojure.lang.ExceptionInfo
      'fa
      'fo)
  ;; => fa

  (case
      (type my-err)
      clojure.lang.ExceptionInfo
      'fa
      'fo)
  ;; => fo
why is it different and is there a better way?

jkxyz10:02:35

case doesn't evaluate the test expressions, so it gets clojure.lang.ExceptionInfo as a symbol, while type returns a Class. You could get the same behavior by using (symbol (type my-err))

jkxyz10:02:39

But I think it's clearer to use cond or (condp = ,,,) as in your first example for these kinds of expressions where you're checking the type of a value

Benjamin10:02:08

ah I get it thanks

jkxyz11:02:26

Just a correction on the above: to get a symbol from a Class you need to do (symbol (.getName (type x))) . You could do (case (.getName (type x)) "clojure.lang.ExceptionInfo" ,,,) with strings as the test constants, but I still think that (cond (instance? clojure.lang.ExceptionInfo x) ,,,) is clearer

maverick11:02:45

How can I load a pdf file in CLojurescript ?

James Carr17:02:31

Does clojure have some process to run in debug mode and step through execution?

practicalli-johnny18:02:57

I've found the Cider debugger very easy to use. I also use the Cider Inspector to help me understand issues, especially when I need to navigate or page through large results. This can save the need for specific debugging https://practical.li/spacemacs/debug-clojure/ Portal is an editor agnostic way to also navigate larger results

jumar18:02:44

You can also implement a custom support dor a primitive debug repl - an example of that is in Joy of Clojure

James Carr17:02:43

Kinda like I would in Java or python?

James Carr17:02:00

set break points, run my app, hit a url and then I enter debug mode and step through the request.

Alex Miller (Clojure team)17:02:27

several Clojure dev environments provide debuggers - Cursive and CIDER at least

🙌 1
James Carr17:02:15

good to hear, I think most folks around here use cursive.

Alex Miller (Clojure team)17:02:16

see #cursive if you have questions... I use Cursive for this all the time (because I typically do a lot of Java/Clojure interop and you can step through both easily). You do have to keep in mind that a single line of Clojure may expand to a lot of bytecode so "stepping" leaves you in the same line many times in a row. but you can use breakpoints, evaluate Clojure expressions at a breakpoint, etc

JohnJ18:02:08

Curious, what have been your primary obstacles/blockers or tedious/annoying stuff when doing Java interop?

Alex Miller (Clojure team)19:02:02

if you're asking me, no obstacles :)

👌 1
practicalli-johnny18:02:57

I've found the Cider debugger very easy to use. I also use the Cider Inspector to help me understand issues, especially when I need to navigate or page through large results. This can save the need for specific debugging https://practical.li/spacemacs/debug-clojure/ Portal is an editor agnostic way to also navigate larger results

domingues21:02:19

How can i use cider REPL, on emacs ,to evaluate clojure functions on a  `.clj` file that isn't associated to a lein project .