Fork me on GitHub
#clojurescript
<
2018-03-04
>
misha15:03:58

greetings! Is there a way to have reduced in areduce? For now I use usual reduce, but I have an uneasy feeling about this.

mfikes15:03:05

@misha Do (source areduce). You can see that it is a fairly simple macro.

mfikes15:03:37

It keeps going until the indices are consumed.

misha15:03:44

@mfikes are you suggesting I should just loop/recur?

mfikes15:03:08

Well, it sounded like you were asking whether you could get areduce to terminate early

misha15:03:13

I sort of did, yes :)

misha15:03:26

I hoped there were some combination of reduced and some higher level function/macro for reducing arrays and terminating earlier.

misha15:03:59

falling back on loop is fine, though

mfikes15:03:06

@misha If it makes you feel less uneasy, reduce calls array-reduce which is a loop/recur honoring reduced?

misha15:03:21

true! thanks

noisesmith15:03:08

yeah, areduce dates back before reduce was optimized like it is today - now it doesn't need to call seq on the last arg

misha15:03:57

so, there is no point in using areduce anymore? @noisesmith

noisesmith15:03:09

I'm not sure of that - but I suspect it

noisesmith15:03:38

if you have performance problems, make sure you profile, then figure out what actually needs fixing, then benchmark your improvement

noisesmith15:03:32

too often you see someone make a 70% improvement on something that takes 3% of runtime, while ignoring a simple fix that would fix the thing taking 50% of their runtime...

mfikes15:03:39

Yeah, if you are reducing a lot of arrays and you don't need early termination, areduce might be faster

mfikes15:03:15

http://blog.fikesfarm.com/posts/2017-11-18-clojurescript-performance-measurement.html if it helps... (especially with respect to testing :advanced code in different JS engines)

misha15:03:24

I am interoping heavily with paper.js right now, and just being in the "as close to js everywhere as possible" mode. Reduces amount of decisions I have to make right now (no performance concerns yet)

noisesmith15:03:31

"as close to js as possible" is js :/

misha15:03:57

to an extent opieop

noisesmith15:03:17

not saying you should switch to js, just that optimizing before you know what needs to be sped up is not an ideal use of time

dnolen15:03:29

@misha in your case I don’t see why reduce + reduced won’t work for you

dnolen15:03:44

I don’t see what areduce would offer here

misha15:03:57

@dnolen it makes sense now, when I know reduce calls array-reduce under the hood, and saw code of both. thanks!

dnolen15:03:00

the next major release of ClojureScript is looming - it’s pretty massive

dnolen15:03:14

but probably the thing we’re looking most forward to is how much easier it is to use

dnolen15:03:47

This WIP for the new Quick Start which is significantly more straight forward than what we had before - please give it a try

dnolen15:03:06

you should be able to work through this, we cut a pre-release (1.10.126) so that this Quick Start can be tested

dnolen15:03:28

this is how people will build their first impressions so very interested in making this as compelling as possible

hlolli16:03:36

I have a .clj macro file, it has error. (:require-macros [panaeolus.macros :refer [definstrument]] :reload) I don't see the :reload working, is this expected? Other ways to reload a macro namespace? I'm useing node repl.

dnolen16:03:10

@hlolli I believe there’s still an edgecase around triggering reloads for macro nses

dnolen16:03:37

probably something simple, but somebody needs to look into that

hlolli16:03:11

@dnolen ok, then I continue to restart the repl. Not big deal 🙂

octahedrion16:03:02

clj -m cljs.main
-- fast and straightforward

dnolen16:03:15

@bhauman great idea here was to make the browser REPL the default, and then of course I was like why don’t we just open a browser - duh! 🙂

sekao16:03:06

FYI it appears clara rules does not work with 1.10.126, lots of warnings about Wrong number of args (3) passed to MapEntry and Use of undeclared Var schema.core/MapEntry in its schema.core ns. fails at runtime too. if it's just a var that was moved/renamed then i assume itll need to be fixed on their end

dnolen16:03:11

right probably a conflict with cljs.core/MapEntry now

noisesmith16:03:53

for the first error, I bet it's something like this

+cljs.user=> ([:a 0] 2 :not-found)
:not-found
- where the code used to work before proper MapEntry objects

noisesmith16:03:46

never mind, not that, that's only two args :/

dnolen16:03:35

yeah I don’t know about that anyway

dnolen16:03:48

but we’ll see how many people are relying on weird tricks

mengu17:03:16

i'm trying to use the new npm-deps feature, i'm using cljs 1.10.126

mengu17:03:48

this is in my project.clj: :npm-deps {:react "16.2.0" :react-router-dom "4.2.2"}

mengu17:03:56

i also have install-deps set to true

mengu17:03:45

when i run lein figwheel, it creates the package.json and also npm packages under node_modules

mengu17:03:01

however when i would like to require the libs, this is what i get: https://gist.github.com/mengu/78f4220ef19f7892af2867635b39582c

mengu17:03:20

does anyone have any idea?

justinlee17:03:59

Hopefully someone can help you with this, but I have never had any luck with that feature and I have found it hard to debug what’s wrong. I’d suggest either using foreign-libs or shadow-cljs.

mengu17:03:13

@U8ES68TGX well, i just realized that the packages i want to use are already in CLJSJS repo. but i'm still going to try this as a means of helping

justinlee17:03:46

@U4P01L831 here are my thoughts on this issue to date. i’m not an expert, and this is an incomplete and probably inaccurate take on things, so take this with a grain of salt. but maybe you find this helpful. https://gist.github.com/jmlsf/f41b46c43a31224f46a41b361356f04d

eggsyntax18:03:10

Question: in clj it's easy to extend a protocol to all types of maps (ArrayMap, HashMap...) by extending it to the interface java.util.Map. That's nice because it spares you the hassle of extending it to each map type separately. As far as I can tell, I can't do the same in cljs by extending the protocol to cljs.core/IMap, because there's not a reified interface for cljs protocols. Is that correct? And is there any other way to do the equivalent in cljs?

danielstockton20:03:51

Has anyone come across errors like Caused by: java.lang.RuntimeException: Unable to find static field: STRING_KEY in class com.google.javascript.rhino.Token ?