Fork me on GitHub
#clojurescript
<
2015-11-28
>
cjmurphy02:11:58

@clojuregeek - to keep taking data (plural) out I think go-loop instead of go, so:

cjmurphy02:11:59

(go-loop [] (log (<! receiving-chan)) (recur))

tyler03:11:18

Released a template for building nw (formerly node webkit) applications. Generates all the boilerplate needed to get a cider repl running and its deployed to clojars so you can use it with lein new! https://github.com/tvanhens/nw-template

borkdude12:11:23

this looks great, but probably not easy to use with Reagent, since it implements its own atoms? https://www.niwi.nz/2015/11/26/introduction-to-lenses-and-how-to-use-them-instead-of-cursors/

jaen12:11:46

Yeah, I imagine one would have to re-implement that for reagent, since it requires more than watchers IIRC.

borkdude12:11:14

here they talk about Rum, it's more flexible

borkdude12:11:46

so much new things to look at: Om.next, this stuff... simple_smile

jaen12:11:14

Yeah, I imagine with Rum's mixins it's easier to use any atom flavour you want

jaen12:11:10

Not sure what are performance implications, I imagine reagent might use custom atoms for performance optimisations or something.

borkdude12:11:24

@jaen: not sure about that. I think Reagent is just one practical idea that applies in many situations, but it's more complected than Rum.

borkdude12:11:41

(yay, I used the word complected)

jaen12:11:08

I would agree, Rum is certainly simpler and more flexible from what I've seen.

jaen12:11:20

Exposing the mixins mechanism feels quite powerful

mccraigmccraig13:11:30

@borkdude from a quick look you could roll your own reagent-alike from rum & cats-lenses

thedavidmeister13:11:16

can anyone help me with a protocols/namespacing problem?

thedavidmeister13:11:30

i did this in one namespace

thedavidmeister13:11:36

(ns app.vectors)

(defprotocol IEnsureValue
  "Protocol for data types that can have a value ensured at a position"
  (ensure-last [this v] "Ensure the last item of this is v"))

(extend-type PersistentVector
  IEnsureValue
  (ensure-last [this v] …))

thedavidmeister13:11:58

now i’m struggling to get ensure-last in another namespace

thedavidmeister13:11:11

i tried :require [app.vectors :as v] but both (ensure-last v l) and (v/ensure-last v l) fail

dreic13:11:08

@tyler: why not electron?

dreic14:11:04

learning clojurescript I'm wondering if i should go with om or om.next.

jaen14:11:14

Of those two I'd choose Om.next. Om is just not as nice as reagent, but Om.next gets you future superpowers.

val_waeselynck14:11:51

@thedavidmeister: when you create your protocol, a function app.vectors/ensure-last is created, so v/ensurelast is the way to go indeed. What's the error ?

thedavidmeister14:11:36

WARNING: Use of undeclared Var app.vectors/ensure-last

val_waeselynck14:11:12

If that happens at the REPL, you should make sure everything gets loaded in the right namespace, it gets me all the time simple_smile

thedavidmeister14:11:27

happens when i run tests

thedavidmeister14:11:38

it didn’t happen when the function wasn’t part of the protocol

mike14:11:00

@jaen I didn't find om next as simple as reagent.

thedavidmeister14:11:53

ok, just noticed some weird stuff going on in my file system

thedavidmeister14:11:12

i think i’m modifying the wrong file

thedavidmeister14:11:21

@val_waeselynck: thanks for helping anyway

jaen14:11:49

@mike: I'm not saying Om.next is as simple as reagent. It certainly is more complex, but it also gets you aforementioned superpowers. On the other hand Om.prev is more complex than reagent, but you don't really have any benefits from it.

jaen14:11:31

Reagent is probably the best way to start, that's for sure, I just replied how those two compare IMO.

mike14:11:38

it all feels like Angular 1 and Angular 2.

jaen14:11:00

Om -> Om.next?

jaen14:11:45

I dunno, does Angular 2 has Relay-like querying and synchronisation?

mike14:11:50

is front end development really getting this complicated, or, are we making it as complicated?

mike14:11:04

om next tries to solve the problem facebook and netflix face.

mike14:11:12

but how many developers are as big as them?

jaen14:11:25

On the backend? Not that much.

mike14:11:25

we just have simpler problems.

jaen14:11:35

On the frontend? I'd argue it's getting commonplace.

jaen14:11:43

People want more desktop-like applications

jaen14:11:48

And that's what it tries to answer to

dnolen14:11:57

@mike: if you don’t have these problems don’t use Om Next simple_smile

dnolen14:11:08

but it solves problems at every JS job I had for the last 10 years

jaen14:11:46

You can't really make a complex desktop-like client-side application without encountering problems Relay/Falcor/Om.next try to solve.

mike14:11:16

@dnolen: I'm sure you had good intentions with om next. but it just does not feel like a smooth path to start with.

dnolen14:11:37

@mike fortunately nobody is telling you to start with it simple_smile

mike14:11:44

not trying to troll here, just an honest feedback.

jaen14:11:23

It's probably not explicitly meant to be the first introduction into SPAs in Clojurescript anyway.

jaen14:11:32

But I think it's something you'd appreciate when you go

marvotron14:11:44

on a slightly related note are there any recommendations for which library or features to use for the remote communications part? sending and receiving json mainly. seems there's quite a selection of libraries..

jaen14:11:52

I wish I had client-side database like datascript in my app with seamless synchronisation with the backend.

jaen14:11:03

At least that's what I feel are the use cases it's more geared towards.

mike14:11:19

@jaen that is just the very same pattern with Angular 1, and now Angular 2.. everyone says,.. yeah it's hard at the beginning, but once you learn it...

dnolen14:11:36

@marvotron: fwiw, I never use the 3rd party things. Closure is quite capable

marvotron14:11:40

one you learn it you end up throwing most of it away 😛

marvotron14:11:53

ok, so jsonp stuff in goog lib

jaen14:11:09

I dunno, I never could learn Angular. Had no problems with reagent, exactly because it's not as prescriptive.

jaen14:11:40

But I can appreaciate what Om.next is trying to solve having tried to do exactly that once (granted, that was my own overengineering probably, but still).

jaen14:11:03

@marvotron: depends on what you want to achieve. I tend to use cljs-ajax it's pretty nice to start with.

dnolen14:11:08

@mike the problem with Angular or any MVC has nothing to with being easy or hard to learn

marvotron14:11:56

short term goal, send json to elastic endpoint, get json back and update state atom (whatever thats based on, om / reagent)

jaen14:11:05

But it is hard to learn. It bring swathes of new concepts for no appreciable gain. At least that's how I felt when I tried to approach it.

dnolen14:11:13

the only interesting metric IMO is does MVC X decrease overall complexity of the system down the road, is it easy to swap out decisions later, is it easy to optimize?

marvotron14:11:24

so i'll go goog closure thing first and add abstractions if i need to simple_smile

twillis14:11:56

@mike: If I may provide another anecdote. My day job is spent building a SPA in ember/ruby back-end for managing patient care(very complex) and things like 2 way bindings/ember-data/json-api are proving to be too simplistic for our needs. So i'm very interested in the ideas things like om.next is exploring. But it is probably overkill for your basic CRUD apps, unfortunately apps worth doing are not your basic CRUD apps IMO

jaen14:11:19

@marvotron: if you are comfortable with closure then sure. I probably couldn't even use it if I tried. Also, if you're using JSON then take a look at prismatic's schemas for coercions. It really makes it more bearable to interact with JSON APIs

dnolen14:11:41

@marvotron: this isn’t guidance against any of the things that are out there, a lot of people like the various libs, I just find Closure acceptable

dnolen14:11:07

@twillis: agreed if you’re really doing basic CRUD why bother with all the front end stuff

jaen14:11:32

I find closure kinda inscrutable. But I'm pretty sure it is top notch if google is using it for so long.

mike14:11:41

@dnolen do you see om next to be in use in 3 years?

twillis14:11:12

considering the half life of any js framework is 90 days at best. simple_smile

dnolen14:11:24

@mike Om Now is approaching 2 years with plenty of users and I intend to maintain both things … so sure!

mike14:11:01

based on other libraries/frameworks, all due respect, I doubt that.

mike14:11:10

feels like we have lost our way.

mike14:11:21

everyone is just pushing the borders.

mike14:11:41

years ago, you just had to know c, maybe MFC on windows,.. and you could build apps.

mike14:11:00

now, anything you learn on the front end side gets decayed really fast.

mike14:11:11

I personally am tired of this.

mike14:11:29

I do not want to keep learning new language/architecture.

mike14:11:07

sometimes it is nice to gain experience and keep using it like a craftsman and his 50 year old tool.

mfikes14:11:33

Hmm. Lisp is getting there simple_smile

val_waeselynck14:11:34

@mike what I like about ClojureScript is that it's the closest thing to an accomplished and mature solution I have found in the frontend world.

val_waeselynck14:11:07

Because the decisions it makes are long-term, and because it strives to tackle all the deep problems

val_waeselynck14:11:32

The use of the Closure compiler with Dead Code Elimination is an example

mike14:11:35

@val_waeselynck: at language level, I agree with you. but at library level, how is it different to js?

val_waeselynck14:11:56

Precisely, DCE is key to a solid, durable library ecosystem simple_smile

dnolen14:11:19

@mike since you’re not me I’m not sure what there is to doubt about delivering a well maintained ClojureScript lib simple_smile But OK

dnolen14:11:33

as far as 50 year old tools, all the ideas in Om Next are so boring

dnolen14:11:47

Lisp, Graphs, databases, etc.

mike14:11:17

@dnolen: I can answer that. both om and reagent are based on react idea. maybe in 3 years react feels like backbone. where would that put om next and reagent on the map?

val_waeselynck14:11:39

@mike the fact of the matter is that no one is satisfied with old JS libraries, because the browsers and application requirements have been evolving a lot.

dnolen14:11:01

@mike React is just a view layer

val_waeselynck14:11:15

That's why betting on a tool that evolves very fast and makes flexible choices is interesting currently

dnolen14:11:20

it lets you render on many targets

mike15:11:09

I'm talking about the general concept here. a new shiny thing will replace falcor and relay in 3 years.

dnolen15:11:11

Backbone is not just a view layer and it does nothing for you with respect to rendering on many targets

dnolen15:11:19

nor does Angular, or Ember

mike15:11:59

apart from google cloure library, please name another front end library/framework which has not been aged since 2006.

dnolen15:11:27

last big JS survey I saw 90% of JS devs still use jQuery

dnolen15:11:56

in fact the state of the art of mainstream JS development has not changed in 10 years

mfikes15:11:58

I, for one, am ecstatic that we luckily have things like React Native and ClojureScript, and I’m glad Om Next is pushing forward on solving real problems. I know all of this is new, but I suspect we’ll be using an evolved version of all of it a few years from now.

val_waeselynck15:11:52

@mike: the key to avoid library deprecation is to compose small, special-purpose libraries with separate concerns, instead of having one big package that tries to get everything right. ClojureScript delivers that, much better than e.g AngularJS.

dnolen15:11:03

OK not 90%, but 56% but more than all the other MVCs combined except Angular

dnolen15:11:20

53% don’t use module bundling

dnolen15:11:30

60% don’t test

dnolen15:11:33

sounds like 2005 to me

mike15:11:39

not the whole web is SPA.

dnolen15:11:12

sure but I’ve seen a fair amount of jQuery based SPAs

mike15:11:21

here is one.

mike15:11:24

this very app.

dnolen15:11:36

well there you go!

mike15:11:42

sometimes when I type in slack it freezes.

mfikes15:11:20

Even the CEO of Slack says it is crap

mike15:11:38

does it matter, as long as they have the users?

trancehime15:11:21

jQuery based SPA? Isn't that a headache?

mike15:11:43

I don't know, is it?

mike15:11:50

isn't learning Angular 2 a headache?

val_waeselynck15:11:03

@mike well, do productivity and flexibility not matter ?

mike15:11:08

we're in a room of 3.6k front end developers, and the room was created by an inferior technology.

mike15:11:27

sometimes when I get tired of learning fancy stuff, I tell myself, maybe I should just go with jquery?

mike15:11:37

I mean, it worked for slack.

twillis15:11:52

or just give up front-end development

mike15:11:17

what I'm trying to say is, I'm not sure if front end technology is moving forward.

mike15:11:39

just because time passes and library versions go higher, it does not mean we're moving forward.

val_waeselynck15:11:00

@mike the 'it worked for' argument is usually moot. Project management is about risks, and when it comes to risk, you're interesting in the probablity of being successful knowing that you use <this technology>, not the probablity of using <this technology> knowing that you're successful.

twillis15:11:00

i think it's probably more like 3 steps forward, 2 steps back

trancehime15:11:23

Angular for me isn't really a headache. Actually I should go check the major changes in 2, but after I finish this CLJ+CLJS thing

mfikes15:11:28

@mike Previously, I had to write iOS apps in an imperative style. Now I can employ FP. That’s forward, for me.

val_waeselynck15:11:51

It doesn't matter that 10x more successful project use jQuery than ClojureScript, if 100x more failed project use jQuery too

dnolen15:11:43

right so I don’t believe in stuff like this. the truth is that people are quite effective with “less capable” tools

dnolen15:11:13

in fact, the mark of a software great team is discipline given less capable tools

mike15:11:31

good point, now, what are we trying to optimize here?

trancehime15:11:37

Right, but that shouldn't be an excuse I don't think

mike15:11:40

effectiveness, or nice tools?

dnolen15:11:13

none of the above

marvotron15:11:08

maintenance simple_smile

dnolen15:11:21

software developers can identify sources of incidental complexity in their software

dnolen15:11:59

and pushing forward by reifying discipline into some abstraction

dnolen15:11:48

there are tradeoffs everywhere off course.

dnolen15:11:04

but you can use anecdotal evidence from people who buy into your worldview

dnolen15:11:22

how much code to deliver X (where X was delivered before with something else)

borkdude15:11:34

@dnolen: I have yet to read your om.next tutorials, which I have planned for Xmas, but is there also something on GraphQL/Falcor server implementation in Clojure that co-exists?

dnolen15:11:35

how easy to test X, how easy extend X, etc.

dnolen15:11:28

plenty of people try ClojureScript, Reagent, Om Next and say it’s not worth it

dnolen15:11:44

but plenty of people ship with it and come here and talk about their experience

dnolen15:11:56

this means something is working

dnolen15:11:15

whether you care or not is your own decision

trancehime15:11:56

speaking as a clojure newbie, I am amazed at how much i got done with it in a couple weeks

dnolen15:11:14

@borkdude: there’s an #C06DT2YSY channel, bunch of stuff cropping up from users

mfikes15:11:22

Perhaps what is really changing is not the shiny tools we use, but we as developers are growing as a group

dnolen15:11:34

eventually I’ll write up something but it may be the community stuff ends up more comprehensive

trancehime15:11:25

I will say this community has been quitr helpful to noob like myself, it's great.

borkdude15:11:04

I played around with Scala/Play stuff lately, and I'm impressed how good their 'getting started' documentation is. Doesn't Clojure need something like that for newcomers, a web development stack supported by a company + good docs?

borkdude15:11:21

I had the feeling Pedestal App + Server were to become this, but maybe progression stopped when app was abandoned?

dnolen15:11:38

@borkdude: Pedestal was supposed to be that thing - it still could be but there’s no urgency anymore

dnolen15:11:34

the problem with App is that nobody predicted React would happen

borkdude15:11:35

@dnolen: maybe in the future: om.next + graphql/falcor pedestal-ish service

borkdude15:11:07

@dnolen: is om.next supported/backed by Cognitect, or entirely your personal project?

dnolen15:11:23

personal project

mfikes15:11:01

(Interestingly, Om Next seems to have pushed me over the tipping point for wanting Datomic.)

trancehime15:11:41

I should study datomic in more depth. preferablu when im currently not typing in bed

dnolen15:11:48

@borkdude: I think too early to say - there’s a lot of non-obvious ideas in Om Next that people are sorting through

dnolen15:11:59

I’ll be just as happy if people copy them over into their own systems / projects

mfikes15:11:27

From an outsider’s perspective, Cognitect seems to focus its strength on the server-side technologies, which is a great base of strength. The UI stuff is swirling around outside of it. But, then again Transit pushes in that direction.

mfikes15:11:05

Sometimes you have to pick something and focus on it.

borkdude15:11:19

For mass adoption it would be good to have some kind of 'framework' that everyone knows and writes things around, like say Ruby on Rails. I hope someday that will happen

val_waeselynck15:11:03

@borkdude: well, Luminus is an effort towards this

borkdude15:11:11

maybe now it's too early, things are still in flux, exciting times

val_waeselynck15:11:11

@borkdude: but I'm still not sure it's possible to have both the simplicity and the 'out-of-the-box' things at the same time, they seem opposite

dnolen15:11:15

@borkdude: right, something like RoR would do a lot for increasing adoption rates

mfikes15:11:45

How about Om Next on React (web, Native, etc.) simple_smile

mfikes15:11:21

(As an aside, I don’t like the subtitle for ClojureScript Up &amp; Running 2ed.)

mfikes15:11:46

Functional Programming for the Web

mfikes15:11:23

(specifically I don’t like the Web “constraint")

borkdude15:11:26

@val_waeselynck: how big a deal is the 'single thread' issue in Ring-based apps? Play supports the async model like Pedestal does

val_waeselynck15:11:30

@borkdude: well it depends on your performance requirements. I think the majority of apps can be completely fine with the 'one thread per request' constraint.

val_waeselynck15:11:09

But it's definitely an issue, since basically all the existing Ring middleware becomes unusable as soon as you want to go async

val_waeselynck15:11:34

I hope the Ring spec/ecosystem will evolve to decomplect the middleware from the execution model

val_waeselynck15:11:25

I think there is not a lot of pressure to go towards the async model, because a lot of database drivers are still blocking

val_waeselynck15:11:38

Look how many people are successful even with synchronous, single-threaded servers like Django or Rails

borkdude15:11:00

@val_waeselynck: true, but look how many people are also stepping away from it when they want to scale up

val_waeselynck15:11:18

@borkdude: I think the solution then may be to use something like Sente

val_waeselynck15:11:24

well Websockets

mfikes15:11:27

The bulk of AOL’s backend is built with single-threaded C-based servers. No context switching. simple_smile

val_waeselynck15:11:18

@borkdude: but I totally agree that pushing towards support for asynchrony is beneficial, be it only for decomplecting

borkdude15:11:48

@val_waeselynck: maybe I should go learn Pedestal 😄

mfikes15:11:45

@val_waeselynck: I built my server that way (http-kit, core.async)

mfikes15:11:07

The only blocking bit is the database layer, but I put that in a thread pool with a queue

val_waeselynck15:11:12

And the thing is, now I'm backed by Datomic, which currently has a synchronous model backed by lazy IO, so not very compatible with async

val_waeselynck15:11:03

@mfikes: Im curious, why go async then ? Do not most of your requests talk to your database ?

val_waeselynck15:11:33

(maybe we should move this to another channel simple_smile )

mfikes15:11:12

@val_waeselynck: I’m lucky in that most of my app is heavy read-based, and I can afford to slurp the main bit into a gigantic Clojure map, and I hit that most of the time. simple_smile Yes… this is no longer about ClojureScript simple_smile

borkdude15:11:42

ah yes, we've moved off topic

mfikes15:11:53

It happens simple_smile

mfikes15:11:08

Especially when your language covers the full stack. simple_smile

mfikes15:11:47

@val_waeselynck: The async approach really shines for me when my server has to talk to yet another server in order to satisfy a request. A thread is a terrible thing to waste.

dreic15:11:51

so om(.next) is difficult and reagent is simple? I think I need to pick one now and go with it. I'm learning ClojureScript with my project.

mfikes15:11:14

Om Next is an investment, IMHO.

val_waeselynck15:11:28

@dreic: difficult is not the opposite of simple simple_smile

mfikes15:11:47

It is not trying to be simple for newcomers, but be capable of solving real problems.

dreic15:11:52

@val_waeselynck: I don't want to get lost while learning

juhoteperi15:11:11

@dreic: Difficult is not perhaps the correct word. More complex perhaps, but that's because it tries to solve problems that Reagent doesn't tackle.

dreic15:11:17

I can't tell whether my "Problem" is real or just imaginary.

val_waeselynck15:11:40

@dreic: it's a matter of taste. Reagent is more 'magical', and concise, at the expense maybe of being less transparent / customizable IMO

dreic15:11:04

magical is fine with me.

borkdude15:11:26

@dreic: you don't have much to learn with Reagent

borkdude15:11:39

@dreic: if you already know how an atom works and hiccup syntax, you're almost there

dreic15:11:40

borkdude: 😄

val_waeselynck15:11:11

@dreic: yeah if you're learning ClojureScript too it's a good call to go with easy minimalistic stuff like Reagent

borkdude15:11:13

@dreic: you can always move to om.next as a next library and extend what you've learned by building with reagent

dreic15:11:17

I'm coming from ruby.

val_waeselynck15:11:13

@dreic: having said that, you doneed to be knowledgeable about React at some point, even in Reagent

dreic15:11:19

In my editor I'm confronted with an extension that doesn't let me remove parens. That's what's irritating me. Otherwise I'm eager to see what's up.

val_waeselynck15:11:22

@dreic: this should help you v

dreic15:11:38

val_waeselynck: I read through the react docs and created a small editor. Not being a JS user I'm fine with the concepts.

dreic15:11:48

That looks like a useful overview. Will watch it! Thank you.

juhoteperi15:11:40

"Magical Elegance" description Luke gives in the presentation for Reagent is okay, but I would argue that Reagent is not Magical as in "hard to understand understand how it works"

dreic16:11:33

oreilly books are 50% off. Is the up and running book useful?

val_waeselynck16:11:05

@dreic: will age quickly imho

juhoteperi16:11:37

I'm thinking Reagent might be less confusing it Ratoms were named differently

juhoteperi16:11:27

E.g. hoplon/javelin uses names cell and formula cell for things which are identical to Reagent atom and reaction

val_waeselynck16:11:38

@juhoteperi: there is value in the fact that Ratoms have the same interface as atoms

juhoteperi16:11:15

@val_waeselynck: Javelin cells also implement IReset, ISwap and such

val_waeselynck16:11:58

@juhoteperi: yes what i meant was that they probably chose that name to emphasize this particular aspect

juhoteperi16:11:23

Yeah, but the name doesn't really describe why ratoms do exist

juhoteperi16:11:51

It's not because performance but because they need to track when they are dereffenced by components or reactions

val_waeselynck16:11:32

@juhoteperi they were spending a lot of time on the cache invalidation problem, so they didn't spend as much time on the naming problem simple_smile

dnolen16:11:25

@dreic: it’s hard to recommend Up & Running 1st ed now

borkdude16:11:26

@dreic: didn't read it myself, but came across this free clojurescript book yesterday: http://catcode.com/etudes-for-clojurescript/toc.html

mfikes16:11:10

Hah nice. I’m now wondering if go / CSP language support directly in Java will become the next “waiting for lambdas” issue a few years from now. So glad we have macros.

borkdude16:11:03

You can use these actors from Pulsar in Java already and they can be distributed/monitored unlike go processes I guess?

val_waeselynck16:11:10

@borkdude: the thing is, as long as the DB drivers are blocking, asynchrony cannot help much...

mfikes16:11:02

Yeah, the DB issue is the nut to crack.

val_waeselynck16:11:30

There's exciting stuff happening in the Node.js world with generators: http://koajs.com/

andrewboltachev17:11:32

Hi. What's the best way to turn snippet of CLJS into equivalent snippet of JS? I want to have piece of CLJS code to do a job for me inside LibreOffice extension. When I compile on some online tool (or Chrome extension), it emits code which relies on cljs library. What's left is to add the library and apply Google Closure to it. What's the best way to do two last points?

martinklepsch17:11:40

@andrewboltachev: you got to compile with google closure

jaen17:11:57

It's probably better to just use a build tool and use the resulting file. Here's a minimal sample on how to set up such a project - https://github.com/adzerk-oss/boot-cljs-example. You'd probably have to modify :compiler-options in the src/main.cljs.edn file to use optimizations like whitespace or advanced.

martinklepsch17:11:33

@andrewboltachev: if you want to use :advanced make sure you mark the functions you want to call from libreoffice with ^:export metadata

andrewboltachev17:11:17

@jaen: sure, boot is cool, but would it make single file for me?

jaen17:11:37

Yes it will if you select appropriate optimizations

martinklepsch17:11:43

@andrewboltachev: all modes except :none create single file artifacts

andrewboltachev17:11:46

@martinklepsch: thanks, that export thing is a good point

jaen17:11:15

Yep, what Martin said.

andrewboltachev17:11:33

thx guys, let me test it out

jaen17:11:28

Actually, let me back up a bit, you don't have to modify the cljs.edn file in the sample

martinklepsch17:11:58

lein new tenzing will give you a very minimal boot/cljs setup that should be good for your purposes

andrewboltachev17:11:12

btw, assumign that code that I would be generating is "clear logic" like adding two numbers/manipulating data structures, should I specify any "target platfrom" anyway?

andrewboltachev17:11:10

e.g. I might imagine assigning global vars to window instead of just "var"

mike17:11:26

@jaen any real world apps other than https://github.com/madvas/fractalify/ using re-frame?

jaen17:11:58

Not that I know of, you could try asking on #C073DKH9P, maybe they have more.

andrewboltachev17:11:41

So, is it true that CLJS compiler supports two exact targets — Browser and Node.js, and won't support very "custom" code snippets?

andrewboltachev17:11:27

like e.g. compiling for LibreOffice extension?

dnolen18:11:32

@andrewboltachev: ClojureScript just generates JavaScript the target stuff is really only Node.js specific sugar-y bits

dnolen18:11:38

and hardly anything at that

dnolen18:11:20

the main issue with random JS environments is lack of standard I/O

dnolen18:11:33

so you can’t use the Closure stuff for loading code at runtime, you need the compiler to generate a single file

dnolen18:11:41

if the LibreOffice JS stuff supports I/O then you can sort these issues out yourself

dnolen18:11:58

this is how Ambly iOS REPL works, Node REPL, Nashorn REPL, etc. etc.

andrewboltachev18:11:53

@dnolen: Thanks. Wish I see (1) Even more optimzing Closure compiler, which produces not ~250 lines for "Hello world" but only a few (though it's real complexity and hardware restrictions are the issues there). (2) Ability to compile flexibly that code which isn't using I/O (just to offload my complex logic there). In the future simple_smile

dnolen18:11:06

@andrewboltachev: “Hello world” is a useless metric when assessing ClojureScript

dnolen18:11:28

that only works so CLJS don’t get trolled about trivial stuff that doesn’t matter

martinklepsch18:11:33

@shaunlebron: just saw these API docs and wished there would be something as awesome (as typedoc) for clj/s libs: http://plottablejs.org/docs/modules/plottable.html Then I thought of your http://cljs.info work and that the analysis you're doing could maybe be used to gather this kind of information. Have you considered this kind of use case at all?

dnolen18:11:50

@andrewboltachev: what JS runtime does LibreOffice use?

martinklepsch18:11:19

Also out of curiosity - would it be possible to point your analyzer at clojure as well?

dnolen18:11:08

@andrewboltachev: for scripting purposes bootstrapped may be simpler for you, people have already embedded in Excel for example with that

dnolen18:11:34

if all you want to write is one-off scripting that may be simpler for you, esp. since in LibreOffice who cares how big the JS is

martinklepsch18:11:39

Envisioning a tool that generates an edn description of a given source tree, ideally with similar change log like information as you have in http://cljs.info

andrewboltachev18:11:20

@dnolen: @martinklepsch About the runtime — I only know that JS is and option among Python, Basic and yes, if I understand well Java is supported too ('cause it's what it's written in) but I'm not sure.

andrewboltachev18:11:27

@dnolen: but what do you mean "bootstrapped" here?

jaen18:11:06

Clojurescript compiler can now run in Clojurescript, that's what "bootstrapped" here means.

jaen18:11:17

(apart from things like integration with Google Closure)

jaen18:11:33

So you can now compile Clojurescript from Clojurescript.

martinklepsch19:11:41

http://stackoverflow.com/questions/33967344/simpler-arithmetic — was thinking there must be something in closurelib for this but didn’t find anything...

mike19:11:41

a bit (+ surprised disappointed) that clojuretv has almost nothing on reagent + re-frame.

grav19:11:03

I’m playing with ‘temporal recursion’. I can define foo as (defn foo [v] (prn v) (js/setTimeout #(foo (inc v)) 1000)) and then call (foo 42).

grav19:11:51

But I cannot define foo as (defn foo [v] (prn v) (js/setTimeout #(#'foo (inc v)) 1000))?

grav19:11:08

It gives me java.lang.AssertionError: Assert failed: (ana/ast? sym)

jaen19:11:49

I don't think Clojurescript has vars and thus var quote?

grav19:11:39

@jaen: I see. Is there any other way of being able to redefine foo and make the next js/setTimeout invocation call the new definition of foo?

grav19:11:41

Would it make sense to put the function in an atom and then deref’ing? I guess it’s just some kind of indirection that I am after.

jaen19:11:48

That's a normal javascript variable, you can maybe try set!ing it?

grav19:11:03

Ah, ok. That makes sense

jaen19:11:23

That said, I'm not 100% sure on what I said. I think at some point Clojurescript got some form of vars, but they are different from Clojure ones and they don't exist at runtime. Someone more knowledgeable would have to chime in.

dreic20:11:04

would slim.clj work in clojurescript?

dreic20:11:16

in a frontend

grav20:11:06

@jaen: cool, well set! works, but I have to use set! consistently, ie first using defn and then set! won’t work

grav20:11:07

Ie

(set! foo (fn [v] (prn  v) (js/setTimeout #(foo (inc v)) 1000)))
(foo 42)
yields 42 43 43 etc in the console. (set! foo (fn [v] (prn “hello” v) (js/setTimeout #(foo (inc v)) 1000))) changes this to hello 44 hello 45 etc

grav20:11:53

But if I start out by defn’ing foo before invoking it, I cannot change the definition dynamically

grav20:11:35

Puzzling

dnolen20:11:38

because there are no vars

dnolen20:11:00

you wrote a function with a static reference to itself

dnolen20:11:14

we could probably change emission to handle this differently, but would need a lot of testing to see if it doesn’t break expectations

dnolen20:11:28

so probably not really worth it since there are other ways to accomplish the same thing

mfikes21:11:46

@grav: Interestingly, you can workaround your issue if you namespace-qualify your var: (defn foo [v] (prn v) (js/setTimeout #(#'cljs.user/foo (inc v)) 1000))

mfikes21:11:12

Then (foo 42) starts it counting up, and (defn foo [v] (prn v) (js/setTimeout #(#'cljs.user/foo (dec v)) 1000)) cause the running counter to go down, if that’s what it supposed to do.

mfikes22:11:56

Another ns-independent workaround is to employ let to capture the var outside of the fn form: (def foo (let [var-foo #'foo] (fn ([v] (prn v) (js/setTimeout #(var-foo (inc v)) 1000)))))

mfikes22:11:56

So, the compiler bug appears to be summarized by these simple variants

(def f (fn [] #'f)) ;; fails
(def f (let [vf #'f] (fn [] vf))) ;; works
(def f (fn [] #'cljs.user/f)) ;; works

mfikes22:11:56

You can also work around this way:

(declare f)
(let [x (fn [] #'f)] (def f x))
So whatever it is, it is constrained to that one failing form.

eyelidlessness22:11:36

What about a named fn?

(def f (fn foo [v] (prn v) (js/setTimeout #(foo (inc v)) 1000)))

mfikes22:11:37

I added http://dev.clojure.org/jira/browse/CLJS-1495 If David or others conclude that a fix is dangerous, at least we have it captured and can close it as won’t fix.

Tim22:11:48

could you use macros to get core.async?

Tim22:11:03

what is stopping you from implementing csp without macros?

jaen22:11:09

Nothing, but who would want to write onself a callback hell? It's a convenience really, the macro transforms sequential code into asynchronous one. You could write it all without a macro, but it would be a chore.

Tim22:11:20

is core.async implemented with threads, I guess?

jaredly22:11:43

@tmtwd: not in cjls -- there are no threads. but on the jvm, yes

Tim22:11:00

oh, can you have buffered chans in cljs?

jaredly22:11:25

I believe so

Tim22:11:31

oh , interesting

jaredly22:11:31

Does anyone have suggestions of smallish (maybe <1000 loc) projects in cljs that I could read through to familiarize myself w/ the language? games, libs, cli tools, etc

mfikes23:11:38

@jaredly: Do you know Clojure itself? (Are you learning the language proper?)

jaredly23:11:46

somebody mentioned https://github.com/madvas/fractalify/ and that looks cool

jaredly23:11:11

I haven't done anything serious in either, but I've tried to get into both multiple times. I've made a few toy things

jaredly23:11:23

but my main interest is cljs, not clojure(jvm)

eggsyntax23:11:34

I'll second @mfikes; the parts of Clojure written in Clojure are just incredibly lucid & a pleasure to read (with the single caveat that the docstrings tend to be more a terse reference than a beginners' explanation -- but you can turn elsewhere for that).

jaredly23:11:36

also looking for something bite-size and applied though

eggsyntax23:11:55

Re: cljs specifically, re-frame is a pleasure to read, and only a few hundred lines of code. If you're not familiar, it's a framework for Reagent (& hence React). https://github.com/Day8/re-frame

eggsyntax23:11:19

The clj code is actually fine for reading in bite-sized pieces; a lot of it is extremely self-contained.

mfikes23:11:21

@jaredly: your question is a good one. I learned the language by doing the 4clojure problems and comparing my solutions to others. But, the most code I've read is the compiler. Perhaps cljs.core is a good read, if not dry :)

eggsyntax23:11:23

I'd probably start with the 2nd half of https://github.com/clojure/clojure/blob/master/src/clj/clojure/core.clj and then work your way backward to the foundations (given the style you're requesting).

mfikes23:11:55

4clojure is nice in that it is bite sized and applied

jaredly23:11:01

wwwow that's a long file

jaredly23:11:19

Yeah I remember going through a bunch of the 4clojure stuff a year ago or so

mfikes23:11:22

But you have to solve the problems instead of just read.

mfikes23:11:08

Maybe fire up Bruce's Flappy Bird Figwheel thing and read its code

mfikes23:11:29

Flappy bird is nice in that you can muck with it in real time

mfikes23:11:34

ClojureScript One might be a more "business applicable" codebase. (I'm guessing; haven't read it.) But it was designed with pedagogy in mind.

eggsyntax23:11:16

Does ClojureScript One still exist? It looks like their website ( http://clojurescriptone.com/ ) just bounces you to the main cljs github.

mfikes23:11:45

@eggsyntax: Hmm. Right you are simple_smile

dnolen23:11:35

@eggsyntax: does not exist anymore