Fork me on GitHub
#clojurescript
<
2017-03-08
>
tbaldridge00:03:51

@mobileink connected perhaps, but I doubt it has much of a real impact. It's a problem fairly common in programming, we can sit an argue if something is a co-monad or a lens, or a byfunctor-plasmatic-rebounder, but in the end all that really matters is how it enables me to write better code, and if the gain is worth the cost.

tbaldridge00:03:47

side note: hence why I use a "good enough" functional language. If the compiler forced me to keep my functions pure, it would be more trouble than it would be worth.

tbaldridge00:03:30

So when we discuss these things I'm more interested in stuff like "do this and we can automate testing, do that and you get parallelism for almost free". Pure functions are just a tool that helps me with those goals.

mobileink00:03:57

@tbaldridge my original concern was to understand just what people mean by SSR, and you have helped clarify that, so thanks.

josh.freckleton02:03:16

in hiccup, I can add a class like [:div.blue], but if I have hiccup-producing fn (defn custom [] ...), is there a convenient way to do [custom.blue]?

qqq02:03:17

does using a (go ... ) basically force all exceptions within the block to the line where the go is defined ?

rm02:03:18

@josh.freckleton I think convetient way is [tag_name {:class "blue"}]

rm02:03:29

I mean if custom is a function you can just pass attributes there and merge them with attributes you set inside

josh.freckleton02:03:54

@rm thanks, that makes sense

josh.freckleton02:03:13

I was sorta hoping there was something as clean as [tag.blue], but ah well 🙂

qqq03:03:07

https://gist.github.com/anonymous/e5a9075a8f9c4f20eba7be22c8770915 <-- anyone know why I'm getting a blank screen? 😞

tbaldridge03:03:11

rofl, welcome to OpenGL

tbaldridge03:03:37

getting a triangle to show on a black screen is the "Hello World!" of OpenGL, and yes it will probably take a ton of time to debug

tbaldridge03:03:51

Look for log messages/check every thing that returns an error code for an error code

qqq03:03:10

@tbaldridge : weird thing is: I got textured triangle working -- except that tdemo code didn't use any vertices (it hard coded the vertex location based on the vertex shader [i.e. x, y,z were functions of the vertex_id) So then I see another tutorial on rendering a rectangle; and I'm like clearly I can combine these two, and get a textured rectangled and viola, I get a rectangle that is all black (which is not the texture)

qqq04:03:10

woot got it working 🙂

qqq06:03:21

with binaryage/oops, is it possible to get things like a[2][3] ?

urbanslug06:03:20

When running a clojure script repl in emacs I tried (.log js/console "foo") I got

CompilerException java.lang.RuntimeException: No such namespace: js, compiling:(*cider-repl CLJS zebra*:45:21) 
Which is the whole point, no?

qqq07:03:44

is this a browser connected repl or a rhino powered repl?

urbanslug07:03:52

qqq Ok I got it to work with in-ns

urbanslug07:03:20

@qqq but it won't find the symbols in the namespace when I call them

urbanslug07:03:23

It's neither

urbanslug07:03:40

I just ran cider-jack-in-clojurescript

urbanslug07:03:53

From your answer it seems I haven't done enough setting up

magomimmo16:03:06

take into account that few colleagues of mine are upgrading the modern-cljs series to the latest available boot version and used libs. It should take a couple of days to have the job done.

qqq22:03:26

@U0EH09SLX : (1) thanks for creating this series! this is what made boot click for me, (2) you probably want to send this to @urbanslug , as that's the person who's looking to learn 🙂

magomimmo09:03:44

@qqq @urbanslug 🙂 I did not verify every single tutorial of the series that has been updated by 3 internals of my company. Aside from few details I should correct, hopefully everything should work with the updated boot, boot tasks and dependencies as expected.

qqq11:03:20

@U0EH09SLX : I'm a big fan of your writing style; I wish you would write more tutorials.

magomimmo11:03:58

I wish to....do not despair, sooner or later I'll be back with some new tutorial

timvisher13:03:03

is it possible to get lein cljsbuild test to not run every build before running the tests? i'd like it to just run the test build.

timvisher13:03:19

i think i should be able to do it using profiles but i don't know if that's idiomatic

timvisher14:03:05

has anyone else encountered this error?

SyntaxError: Invalid regular expression: range out of order in character class
referencing a line in the compiled js:
goog.i18n.bidi.rtlCharReg_ = new RegExp("[" + goog.i18n.bidi.rtlChars_ + "]");

manutter5114:03:02

I’m guessing there’s a “-” in goog.i18n.bidi.rtlChars_ that’s making the regex unhappy?

manutter5114:03:49

If so you’ll need to remove it from goog.i18n.bidi.rtlChars_ and make it the first or last character in the string.

timvisher14:03:23

yeah. it's not in my code of course. i can't find anything yet on the web that sheds any light on whether i'm doing something wrong 🙂

timvisher14:03:36

except for one other individual in the IRC channel who apparently found this issue.

manutter5114:03:17

Hrm, I probably can’t help then, sry

timvisher14:03:32

no problem 🙂

manutter5114:03:44

@timvisher is there anything in your dependencies you could upgrade to the latest version? I found that IRC conversation (I guess it’s the same one) and it sounds like a case of “new CLJS + old libs"

timvisher14:03:08

@manutter51 i've been in the process of trying to do that. at the moment my deps are clojurescript 1.9.… and clojure 1.8.0

timvisher14:03:33

but my project's an absolute mess of comments at this point. i'm considering trying to just greenfield it and copy stuff in one at a time 🙂

manutter5114:03:29

I’ve done that 🙂

timvisher15:03:03

no shame 🙂

stepugnetti16:03:54

Hi all! Has anybody ever tried to let maven compile a clojurescript project featuring externs-including dependencies? I’m using clojure-maven-plugin, making it run a build script where I just invoke

cljs.build.api/build
. With the
:advanced
optimizations, however, externs are not included. With lein-cljsbuild, externs present inside a dependency jar would be automatically included, and I don’t know how to imitate this behaviour in my script

spinningtopsofdoom16:03:36

What does your build script look like?

spinningtopsofdoom16:03:56

Have you tried running lein run -m clojure.main path/to/your/build/script.clj?

PB16:03:14

Hey all. On a newly generated re-frame project i'm getting the folloiwng error when trying to compile a ns within cider: Caused by: clojure.lang.ExceptionInfo: No such namespace

PB16:03:17

Any ideas?

PB16:03:47

This error as well: `clojure.lang.ExceptionInfo: failed compiling file:/home/me/code/fudge/src/cljs/fudge/core.cljs {:file #object[java.io.File 0x52e7523e "/home/me/code/fudge/src/cljs/fudge/core.cljs"]}

spinningtopsofdoom16:03:07

It looks like you have your source paths set up incorrectly

PB16:03:02

@spinningtopsofdoom this is a brand new project setup by reframe, what should I be looking for?

spinningtopsofdoom17:03:13

@U08UTJ5PB You'll want to check that your :source-paths contains the directory that your ClojureScript in

spinningtopsofdoom17:03:25

and that the directory you are passing in for your ClojureScript build is coorect

spinningtopsofdoom17:03:10

and finally make sure the ClojureScript namespace matches the directory layout (e.g. (ns foo.bar) should be in src/foo/bar.cljs

PB17:03:15

From what I can tell, everything is correct 😕

PB17:03:51

lein figwheel dev works but doing anythign from my cider repl is broken

stepugnetti16:03:40

@spinningtopsofdoom Thanks for your answer. This is my script:

(require 'cljs.build.api)

(cljs.build.api/build "src/main/clojure-app"
                      {:output-to "src/main/webapp/docroot/js/main.js"
                       :output-dir "target/js"
                       :optimizations :advanced})
Running it as you suggested correctly compiles the project (i.e. includes the externs). Unfortunately I cannot rely on leiningen in the environment where this will have to be built...

thheller17:03:20

@stepugnetti how does your project.clj look? something using :profiles?

thheller17:03:33

maven wouldn't know anything you have in your :dev profile for example

thheller17:03:18

cljs.build.api doesn't assume anything about lein so it should be a classpath issue

thheller17:03:10

although it is weird that only externs are missing

stepugnetti17:03:51

@spinningtopsofdoom Right. This is my project.clj

(defproject my-project "0.1.0-SNAPSHOT"
            :dependencies [[org.clojure/clojure "1.8.0"]
                           [org.clojure/clojurescript "1.8.51"]
                           [reagent "0.6.0"]
                           [re-frame "0.9.2"]
                           [cljsjs/react-bootstrap "0.30.7-0"]
                           [cljsjs/react-router "0.13.2-0"]
                           [org.clojure/java.classpath "0.2.3"]]
            :plugins [[lein-figwheel "0.5.9"]
                      [lein-cljsbuild "1.1.5"]]
            :source-paths ["src/main/clojure-app"]
            :clean-targets ["target/js" "src/main/webapp/docroot/js"]
            :cljsbuild {:builds [{:id “mp"
                                  :source-paths ["src/main/clojure-app"]
                                  :compiler {:output-to "src/main/webapp/docroot/js/main.js"
                                             :output-dir "target/js"
                                             :optimizations :advanced}}]}
            :profile {:dev {:cljsbuild {:builds [{:id “mp"
                                                  :figwheel true
                                                  :source-paths ["src/main/clojure-app"]
                                                  :compiler {:output-to "src/main/webapp/docroot/js/main.js"
                                                             :output-dir "src/main/webapp/docroot/js/include"
                                                             :asset-path "src/main/webapp/docroot/js/include"
                                                             :main “my-project.core"
                                                             :optimizations :none}}]}}})

stepugnetti17:03:20

(Sorry fo the bad layout)

thheller17:03:37

except for the ancient versions that looks correct

thheller17:03:57

maybe try bumping [org.clojure/clojurescript "1.8.51"] to something more recent

thheller17:03:18

1.9.494 is the latest

stepugnetti17:03:50

And I misspelled :profiles, so probably the :devmap has no effect

spinningtopsofdoom17:03:29

@stepugnetti I haven't compiled ClojureScript with just maven but I believe David Nolen has. You might want to ask him.

thheller17:03:40

yeah but none of that affects the cljs.build.api script

thheller17:03:04

I assume you get the pom via lein pom?

thheller17:03:12

so it has the same deps?

stepugnetti17:03:36

No, my pom has been assembled manually since it has a complex structure because of some other part of the project entirely developed in Java.

stepugnetti17:03:20

@spinningtopsofdoom Thanks! This means that it is a problem with the classpath indeed.

spinningtopsofdoom17:03:50

No problem glad you found the problem

vinnyataide18:03:02

hello, is there a way to use figwheel inside my own component system? I want to keep only my server up so less overhead is imposed. Is this a good way?

anmonteiro18:03:00

@vinnyataide sure, there’s figwheel-sidecar.system/figwheel-system

vinnyataide18:03:17

@anmonteiro that's awesome! thanks

dnolen18:03:26

@vinnyataide it’s also easy to combine with Socket REPL

dnolen18:03:58

this is how I do my dev - one VM that runs webserver, Figwheel compilation process, 2 Socket REPLs (one Clojure, one Figwheel)

vinnyataide18:03:34

@dnolen do you have an example project?

dnolen18:03:41

sorry I don’t

vinnyataide18:03:47

@dnolen do you use the handler options on figwheel?

dnolen18:03:03

I don’t know what that is

vinnyataide18:03:40

the :ring-handler one

dnolen18:03:20

like I said

dnolen18:03:26

I don’t know what that is and I’ve never used it

vinnyataide18:03:28

I'll think how the pieces fit together and try to understand

dnolen18:03:38

I don’t use Ring, Pedestal

dnolen18:03:27

you can use the tubular bit to integrate with Cursive or Emacs inf-clojure

vinnyataide18:03:04

very cool tool agnostic solution

tech_hutch21:03:10

Do most collection functions work on JavaScript arrays?

tech_hutch21:03:20

It seems like count does.

tech_hutch21:03:02

I'm assuming using CLJS functions like count with arrays is more idiomatic than (.-length array).

jr21:03:13

you need to convert arrays using array-seq to use them as clojure collections IIRC

tech_hutch21:03:45

(count #js[1 2 3]) returns 3, though.

jr21:03:37

count is special cased for js arrays

jr21:03:18

so is nth and a few other non-seq functions

tech_hutch21:03:53

Oh, didn't happen to notice "Also works on strings, arrays, and Maps" in its docstring. Thanks!

tech_hutch21:03:30

Which is more idiomatic to use, (count array) or (alength array)?

darwin21:03:43

depends, if you want to be explicit that you are doing interop and the array is 100% a js array use alength, if you are writing a piece of generic code count should be used instead

joshkh22:03:09

not really cljs specific, but which open source databases do you webdevs use for storing user specific data such as roles/permissions, saved documents, etc?

joshkh22:03:06

monger (mongo) and clojure seems alright from an edn->json / json->edn perspective, but is there a more native solution besides datomic?

akiva23:03:45

I wouldn’t worry about ‘native’. Is it native because it is or because the API layer makes it seem to be? I’d go with whatever the best tool for the job is. If your data access layer API does the job of making it seem native, that should be good enough.

akiva23:03:21

To put it another way, I’ve shifted from Mongo to RethinkDB back to Mongo (after RethinkDB folded) and then finally to Postgres.

akiva23:03:57

My façade layer between my app and the data access layer held up with just adjustments to expected arguments and function names. Boom.

tbaldridge23:03:59

And likewise, I'll probably never be able to use a database besides Datomic again. Having an immutable DB is that good.

joshkh23:03:02

fair point. i went from mongo to couchdb and then back to mongo. but i'm also fond of postgress. i guess i view clojure data structures as documents more than tables... i'm just frustrated with mongo's query engine. perhaps i should look into postgres's document store.

joshkh23:03:31

i wish i could use datomic! but i'm restricted to open source software.

akiva23:03:57

I really like Datomic, mind you. I’ve just never found a use case for personal projects (or even for any professional ones) that it stood to reason to shift to it from whatever was in place. Total greenfield, I’d probably follow @tbaldridge and go with Datomic.