Fork me on GitHub
#clojurescript
<
2017-06-03
>
alexwheeler01:06:22

bit stumped. Why does (js/history.pushState nil nil "pizza") worked, but ((.-pushState js/history) nil nil "pizza")) throw error?

richiardiandrea01:06:46

Oh oops, I have just now read the whole conversation, ignore the above 😁

john01:06:42

@alexwheeler is js/history.pushState a method call or a property access?

fabrao04:06:17

Hello all, how can I see if javascript lib for jQuery was present?

fabrao04:06:33

the library tells to use like this $('selector').packery() and I used like this (.packery ($ ".grid"))

fabrao04:06:59

but is getting ".packery is not a function"

fabrao04:06:36

I included it with <script src="js/asset/packery.pkgd.min.js"></script>

fabrao04:06:45

I used too [jayq.core :only [$ append delegate data]] for jQuery clojurescript

noisesmith04:06:35

if anything it would be js/$

noisesmith04:06:51

javascript globals are not implicitly in clojure scope

rgdelato04:06:30

if jQuery is a global, you could usually also check it with js/jQuery

fabrao04:06:50

but if I log it (js/console.log ($ ".grid")) tell me the element

rgdelato04:06:39

Chrome might be aliasing js/$ to js/document.querySelector... I would explicitly check for js/jQuery

fabrao04:06:20

the ($ "selector") is reading

fabrao04:06:24

the problem is when I call (.packery ($ ".grid")) tells that .packer is not a function

fabrao04:06:38

*`packery`

fabrao04:06:13

don´t you think that the libary was not install as jQuery lib?

fabrao05:06:07

I discovered the problem

fabrao05:06:35

just page reload the lib is in jQuery 🙂

deas05:06:46

wrt jvm/node interop: Wondering if/how j2v8 might help. Any experiences?

Oliver George05:06:27

What's the simplest way to do some generative testing of my CLJS tests in my bitbucket pipeline? I have it setup to do an uberjar build looking for compile problems at the moment. Obviously lein test works (for clj tests) but for CLJS I need to have a JS VM.

Oliver George06:06:59

That is to say I have CLJS specs defined. I'm looking for a non-fiddly way of running stest/check from my docker script.

Oliver George06:06:37

Perhaps this is the answer: use node. (I'd appreciate any other recommendations) https://github.com/clojure/clojurescript/wiki/Quick-Start#running-clojurescript-on-nodejs

noisesmith06:06:49

@olivergeorge I haven't tried this, but I've seen it mentioned https://github.com/bensu/doo

noisesmith06:06:25

some of the environments it supports are built into the vm (or are deps you can pull into the jvm)

Oliver George09:06:02

thanks @noisesmith i'll keep that one in mind.

Oliver George11:06:26

Quick followup. Node works if you're sure your code isn't looking for js/window or the like. That's problematic where logic which sits alongside rendering code.

Oliver George11:06:22

My first bump was that the ns referred to a foreign lib which assumed window existed.

pesterhazy11:06:17

seems like a bug in the library?

joelsanchez12:06:41

I use lein-doo successfully to run cljs tests, recommend it

gmercer12:06:05

@noisesmith @joelsanchez ferret code is embedded in the emacs org-mode file - http://ferret.org

joelsanchez12:06:30

Browsing through the code right now, let's see if I can achieve "hello world"

john14:06:23

Seems most of the ferret code is a bunch of C++ strings wrapped in s-exprs.

john14:06:42

@deas Sounds interesting. Seems like j2v8 would allow Clojure (JVM) to manipulate node/V8 instances. Specifically, though, you wouldn't be using it from ClojureScript but from Clojure. And a lot of the reason some folks want CLJS on node is get rid of their JVM lol

john14:06:00

What other use cases were you thinking of for j2v8?

deas14:06:34

@john Not quite sure yet. I think those targeting the browser should embrace webpack. They say j2v8 supports node modules. And js land can call into jvm as well. Might help wrt potential cljs webpack loader, figwheel, gcl and other goodies which are jvm today.

deas14:06:45

... executing on the jvm only that is.

deas14:06:07

The Nashorn based approach (Avatar) to get node modules executing in the jvm was immature and pretty much dead last time I checked.

john14:06:44

Interesting... Let us know what you find out if you take the plunge.

martinklepsch14:06:49

@olivergeorge uncharted waters but chrome tream recently released a headless version. Guess you could use that with bensu/doo

john14:06:22

Kanaka is one prolific wizard though. Maybe Ferret would be a good way to learn some C++

fabrao15:06:00

Hello all, how do I convert this to cljs ? w2ui['grid']

fabrao15:06:24

(? js/w2ui "grid")

tatut15:06:47

(aget js/w2ui "grid") ?

fabrao15:06:54

hum let me see

fabrao15:06:24

thank you worked

joelsanchez15:06:53

@john Running a wm with Ferret, although the code is 99% C++ and 1% Clojure, but I will improve it now

joelsanchez15:06:01

So happy to see it can be done

joelsanchez15:06:14

window manager

joelsanchez15:06:38

as you can see it totally sucks, it is basically tinywm inside a string http://incise.org/tinywm.html

john15:06:58

Nice, so you should be able to decompose some of that into smaller functions and then make a more composable wm system.

joelsanchez15:06:10

Indeed, indeed

john15:06:12

looks like fun 🙂

joelsanchez15:06:29

You can download the ferret standalone executable and execute that script to build it

joelsanchez15:06:44

Use xnest to test the wm: " Xnest -ac :2 & "

joelsanchez15:06:06

you move windows with shift pressed, that's it

joelsanchez15:06:10

great functionality

john15:06:35

I'll give it a whirl.

moxaj20:06:40

if I have a multmethod foo and a macro bar, what will (methods foo) be during bar's macroexpansion? In clojure, it picks up all my registered methods, in cljs it skips some

joelsanchez20:06:26

Afaik in cljs you need to explicitly require any namespaces that extend a multimethod, as opposed to clj

joelsanchez20:06:32

Not sure if that's your case

moxaj20:06:50

I think you need to do that in clojure as well

moxaj20:06:45

it seems to only pick up method registered before the macro definition

moxaj20:06:08

before = same file or dependencies

joelsanchez20:06:29

In clj the multimethods get extended by namespaces no namespace is :requiring (but the namespace has to be loaded, of course)

joelsanchez20:06:39

In cljs the require is needed (this is my experience)

noisesmith20:06:59

wait how is the ns ever loaded if nobody requires it?

joelsanchez20:06:40

(clojure.tools.namespace.repl/refresh-all)

joelsanchez20:06:21

I think leiningen is able to load all the namespaces of your application on startup as well

joelsanchez20:06:35

Could never do that with cljs

noisesmith20:06:31

I've never had lein load namespaces not in the tree of things required by my init-ns or main

noisesmith20:06:00

and if it did, it would just be disguising errors that would happen when I deploy

joelsanchez20:06:41

Indeed I'm probably mistaken, and refresh-all is the way this gets done

joelsanchez20:06:17

Found the source of my confusion: https://stackoverflow.com/questions/39585510/using-clojure-multimethods-defined-across-multiple-namespaces This answer is incorrect as noted in the comments that I did not read

joelsanchez20:06:31

Solution works only on the repl and with refresh-all

nikki21:06:31

man namespaces r weird

nikki21:06:42

they are all "places"

nikki21:06:08

feel like we could replace namespaces with datomicy thing where you query for all the vars you want and close over them for an ephemeral scope

nikki21:06:33

and just store code and basically everything in that db

nikki21:06:46

backed by in-memory or distributed or server or whatever

john21:06:51

That's the dream

nikki21:06:57

because the serialization or load mechanism for a namespace is a file

nikki21:06:12

where u write the serialization format by hand

nikki21:06:22

welcome to post-1960

john21:06:25

But when the top level isn't mutable, repl driven dev would become weird and unlisply.

nikki21:06:45

nah man, you write ephemeral query and transact back

nikki21:06:52

then if you like what you wrote you save it

nikki21:06:59

thats how you write a function or rule

nikki21:06:24

;O just me saying weird things, i do that

john21:06:40

Immutable namespaces have been discussed repeatedly over the years. Some people have even tried implementing them.

nikki21:06:52

i know we tried to fly many times

nikki21:06:55

eventually someone did

john21:06:13

Indeed. I'm betting you can too!

joelsanchez21:06:25

I think you can't change what something refers to in Haskell

john21:06:29

Bring us home the trophy!

nikki21:06:40

lolol oops feeling da pressure

nikki21:06:56

@joelsanchez yea but that namespace situation is weird

nikki21:06:09

datalog queries with pull over eavt seems v nice to me tbh

nikki21:06:33

it gives you relational plus inheritance (recursive queries) with granular timetravel by its nature and by design

nikki21:06:38

rather than by bolting on

joelsanchez21:06:18

Indeed the pull api is amazing, but i'm having a hard time imagining that as the source of namespaces

nikki21:06:27

i agree tho having to query to get basic things like 'sin' or '+' would get old fast

john21:06:49

I think in some old talk - or email - even RH speculated on the same idea... storing vars in datoms, or something like that.

nikki21:06:13

the way i see it

nikki21:06:55

namespaces are an affordance to bootstrap the next phase of shared data/code which would be something that affords what eavt affords, however implemented

nikki21:06:34

things like versioning and dependencies (some stuff hit at in Spec-ulation RH talk) could be nicer over it

john21:06:34

weening humans off rows and rows of text symbols is apparently non-trivial, though.

nikki21:06:50

thats why u embed it into a cartoon and video game for kids

nikki21:06:00

like meier's code [shifter] narrative

joelsanchez21:06:34

Not long ago someone posted on HN a programming language whose development environment worked by editing the AST visually, no text involved (not really related to the namespace conversation but)

nikki21:06:43

(book actually uses clojure for fictional code lolol)

nikki22:06:02

i think with cljs over react native

nikki22:06:22

you can render asts from pulls automatically as draggable nested blocks on an ipad or whatever

nikki22:06:45

then u r editing the shared world ast for the collective mind

nikki22:06:54

kk this is where i go off the deep end 😅

joelsanchez22:06:58

"The main idea behind the Lamdu project is that the canonical representation of programs should not be text, but rich data structures: Abstract syntax trees."

nikki22:06:26

yeah thats nice @joelsanchez

nikki22:06:56

IMO language is abt empathy and computer languages empower humans by having them empathize with a different kind of processor through their intuitions of scope and naming

john22:06:22

Yeah, I've been arguing for editing the AST directly since the 'tunes' list.

nikki22:06:49

I think one way to think about it is that visual editing for one kind of dsl is ast editing

nikki22:06:18

If an element in it is a color you render a colorpicker, or a vector you render a direction picker or absolute position picker depending on metadata, etc

nikki22:06:38

But ultimately in a simulation

nikki22:06:42

You want to drag and drop objects

nikki22:06:52

You want to paint sprites with an apple pencil or w/e

joelsanchez22:06:03

I think all of this kind of relates to http://witheve.com/

john22:06:31

There's that. But even without inline objects, I think parinfer/paredit/other structural coding tools are just approaching the true "ast editor"

joelsanchez22:06:00

Lisp is pretty close to an ast, so lisp editing tools are a kind of "ast editor", kind of...

joelsanchez22:06:15

Anyway a more visual and interactive way to do it would be nice

nikki22:06:39

eve feels a less general version of query -> transact over eavt but i think that may be too reductionist

nikki22:06:57

I love that this community is willing to engage with such form of discourse lol

nikki22:06:07

Like this is the sort of thing its fun to talk to humans about

nikki22:06:10

I made this a bit ago on C and Lua

nikki22:06:39

made a game in 48 hrs on that for Ludum Dare and it went ok -- cljs gets u 70-80% of the way there out of the box

nikki22:06:07

the c lua engine i had to make the ui and gfx layer from scratch but react native gives you super solid ui really easy

john22:06:13

lol and I don't work in a dev shop, so I almost never meet people IRL that know what anyone here would be talking about.

nikki22:06:39

tbh even in dev shops you have to try consciously if you wanna engage along this dimension

nikki22:06:49

Often ppl r about "current engineering practices" and incremental things

nikki22:06:55

Than about the human problem

nikki22:06:56

@joelsanchez in that last vid u c me editing stuff visually in the game live 😮

joelsanchez22:06:18

I work as a developer, just got a new job as a cljs developer, but I've always been working at PHP shops, no talk about ast editors, lisp, functional programming, or anything there

nikki22:06:21

another space of prior art here is smalltalk / self

joelsanchez22:06:25

Watching the video

joelsanchez22:06:38

How's the game implemented exactly? Where does it run? Browser?

joelsanchez22:06:44

That editor looks lots of fun

joelsanchez22:06:54

How do C, Lua and cljs interact? Or is it only C and Lua?

joelsanchez22:06:04

I'm terribly confused 😛