This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2015-11-26
Channels
- # admin-announcements (70)
- # aws (1)
- # beginners (17)
- # boot (37)
- # business (1)
- # cider (2)
- # cljs-dev (56)
- # cljsrn (6)
- # clojure (151)
- # clojure-germany (1)
- # clojure-nl (5)
- # clojure-poland (5)
- # clojure-russia (34)
- # clojure-taiwan (1)
- # clojurescript (289)
- # clojurex (2)
- # cursive (16)
- # datavis (3)
- # datomic (12)
- # editors (10)
- # emacs (3)
- # hoplon (17)
- # ldnclj (5)
- # lein-figwheel (12)
- # leiningen (1)
- # liberator (1)
- # off-topic (23)
- # om (116)
- # onyx (39)
- # parinfer (44)
- # portland-or (1)
- # reagent (34)
- # yada (6)
No, it isn't. But if you would add your support by requesting the admins install an Slack <-> IRC bridge, it could easily be the case.
I'm evaluating clojurescript for a new project. A Ruby Sinatra app has to be converted into a Windows-compatible app - I'm thinking about E lectron. I think most of the problems can be solved this way, for the app it doesn't matter whether it's server or client based. I checked out clojurescript because it offers some nice advantages over js. However, what am I going to do with the required mysql connecti vity? It's an app that basically outputs data from a huge DB. I didn't see any mysql specific libraries. Are plain clojure libraries also working? Am I going to use JS libraries?
Yea, I think there's not a ton of people connecting to old-world databases from ClojureScript.
There's some good info on interop here: http://cljs.info/cheatsheet/ and here: http://www.spacjer.com/blog/2014/09/12/clojurescript-javascript-interop/
Actually I don't really worry about the DB connection. I'm usually pulling everything and then walk through the data as necessary. Probably some JSON chunks would do.
I am currently working on a little editor and want to give users the chance to edit a simple config file in their home dir.
Currently I have it in EDN and just use cljs.reader/read-string
to parse that back into cljs.
Now I would really like to give the user the possibility to define a custom function and link it to a keybinding. Like cmd+x
executes function #(println "foobar")
. Maybe on execution pass some environment stuff into that function to make it even more powerful
Is it possible to do something like this? Can I let the user define a normal cljs file and evaluate that on the spot?
can someone tell me or point me to an article that describes why should the big atom be a good idea?
@dvcrn: if you want on-demand compilation you either need a jvm or the self-host stuff. but it is going to be really hard to do partial compilation (only the files from the user) since the cljs compiler relies on analysis information pretty heavily. so you'd need the source of everything that is possible referred to by the user code
@thheller: I guess there is no way to serialise a function into a EDN-ish version and load it back into cljs?
maybe I'll drop EDN and go with a pure javascript object + js functions instead. I could probably load that back and eval it
@xifi the most obvious answer: all your state is one place. @app-state
and see what the app state is at any time.
no need to look at place-a
, place-b
, place-c
, wherever
to get a picture of what is going on
@thheller: if you were to write a different piece of software, would you crunch all your data into one big atom?
OK, let's say I get that. What is the reason to copy this idea into web apps instead of doing it the old fashioned way?
you generally only have one database with many tables, not a database per table if you think SQL
in your analogy wouldn't the namespace be the database and the variables the tables?
that would be global state, there are plenty of good examples why global state is bad
but something just isn't just data (eg. websockets connections) not quite sure where to put those
and i apologise in advance if im being generic or just wrong, im new to the clojure(script) game
so that groups together the various ways of accessing other data. waves hands over there
@xifi: one nice feature of the big atom
is that you can schema-check the big-atom
and be assured that your app never evolves into an inconsistent state, and that you get an error when your buggy code attempts to create an inconsistent state
(and re-frame
s handler middleware makes schema-checking like this particularly easy to do)
is it possible to send in a global variable into the js environment from cljsbuild that is available as the script starts? thinking dev-mode? variable kind of thing
https://github.com/clojure/clojurescript/wiki/Compiler-Options#closure-defines looks to be the thing
I’m in a need of injecting compile-time configuration into my cljs project (some clojure code which runs before all my macro code) I’m using leiningen which has :injections config option, but that didn’t work for me (it works only when executing test profile, not when doing cljs-build compilation tasks). I ended up creating config.clj[1] which gets on class path only in release mode and I try to include it as early as possible from my entry-point namespace file [2] [1] https://github.com/binaryage/chromex-sample/blob/master/src/release/chromex_sample/config.clj [2] https://github.com/binaryage/chromex-sample/blob/master/src/popup/chromex_sample/popup.cljs#L2 It works for now, but it is inherently fragile I guess. I depend on order of requires to be config-first, core-second. Which does not have to be always guaranteed I believe. Any ideas how to solve this properly? Thanks.
This release config is included only in release builds, like this: https://github.com/binaryage/chromex-sample/blob/master/project.clj#L85
In the library project I have used :injections successfully: https://github.com/binaryage/chromex/blob/master/project.clj#L40, but that really works only when executing “lein test”, unfortunately due to some magic handling test task differently
Chatted with a friend yesterday who’s working on some React app. Hot Reloading, webpack, etc. Startup time for development: 1minute. Babel and friends make JS come close to CLJS startup speed.
@marvotron: the issue is at the root of your application, who knows how you want to set it up? Om Next just doesn’t care. You may have multiple reconcilers, you may want to use something Stuart Sierra component-like to establish starting and stopping your system, etc. The point is not to get involved and not get in the way.
for that specific remote example, there’s actually no reason for those things to be top level, but it’s kind of besides the point for that tutorial
@dnolen : i see, thanks. I started to get that impression as I read more, the idea of pushing that stuff 'to the edge'.
@xifi: “we don’t do this anywhere else”, this isn’t true. The big atom idea is not really a new thing - a pretty old idea in the functional world, of course databases, and weirder languages like Prolog.
fixed my config problem above using environ library (and lein-environ plugin): https://github.com/binaryage/chromex/commit/174f401b1a668e09c3760f7c8b22729d2a2546dc https://github.com/binaryage/chromex-sample/commit/68a3e89224c9968fc9559fbfd671aaa7ae0f320a
the advantage is simply not having to spend as much time trying to figure out who changed what - narrowing the scope of consideration has huge implications for our ability to reason about the behavior of a given program.
so to take one of my current cases for our js based SPA, when the app loads we need to do a series of remote requests to different endpoints each requires data from the previous endpoint AND some of that data is exposed in the UI
because this would be the main technical selling point for our team, at the moment its a complicated chain of rx and promises
@marvotron: so you won't be able to get rid of that if the network part looks that way
Om Next doesn’t require any fancy backend thing at all, if you want to overlay a sensible way to query multiple REST endpoints you can do that
ok, i think at this point i need to start building and trying stuff. thanks for the answers, much appreciated
@dnolen: databases - ok that's fair. Functional world - what would be an example? But this is still missing the point for me, i.e. the answer isn't deep enough. E.g. if you want to replicate what databases do - why? What was the initial problem that led you to use this technique
it's exactly the reason you use a database instead of writing to random locations on disk
@dnolen: ah, I missed that post! And do you find that true for huge applications as well?
I work on a pretty significant highly concurrent immutable database at Cognitect - Datomic
well it's not that I don't believe that, I just thought if the use-case or logic behind is the same, that's how it would be advertised. I never heard anyone say It's like a client-side database. I do believe you though, you're the coder, I'm just another noone
@xifi no I’m just pointing you believe something, but you haven’t explained to me why you think they should be different things
@xifi this is all to say I can’t prove that it's any better or the “right” way Just that it seemed sensible to try a good engineering practice from elsewhere, and it seems to me to lead to better systems. This is all anecdotal! But it seems to be growing in terms of other people verifying these personal conclusions (thus the number of Clojure(Script) users coming from elsewhere)
@dnolen: I can't prove anything as I don't have experience. I'm asking around in multiple places/frameworks/languages and trying to make sense of it all
we have some large SPAs in JS (angular based) and they reached the point where trying to mentally reason about the app state and how it changes was practically impossible
@xifi sure but sometimes someone says it’s a good idea and you try it. Not everything can be resolved to logic. That’s definitely the case with software or we’d still be writing Assembly.
so we're on an involved process of scooping out all the state and putting it into a baobab based system, BUT on a longer term we want a solution thats built this way from the ground up
I like to recount when I discovered Clojure didn’t have mutable locals and almost passed it over
@xifi I really did think Clojure was the worst language I’d ever seen there for a second
@xifi also a lot of these conclusions about client side development didn’t happen overnight - rather a long winded series of experiments
@xifi for what it’s worth some JS people have picked up on the single atom idea - Redux & Relay so it’s worth looking at what they say for an alternative take on the rationale
@dnolen: well yes I can imagine. That's why I value your opinion. I don't have much experience in this topic so I like to collect information before jumping into something. You always learn stuff when you do stuff but if one can save some time by making some smart decisions early on it's always a win
I’ve been thinking about it a lot lately. How exactly is it different from, for example, re-frame and Om
one thing is that in cycle, views, models and intents never have side effects, only return values. This is not true with re-frame
Sometimes it’s difficult to really understand what the differences are, and how they affect you
it’s more like a JS MVC framework in that it is a complete solution - modeling, remoting are all part of the design
@jaredly: core.typed does not work with ClojureScript, support was more or less dropped more than a year ago
ok. I've really come to value having flow
in js-land. do you know how much work would be involved in reviving cljs support?
@jaredly: no idea talk to Ambrose, you have mailing lists and IRC channels for core.typed
I've had a couple of requests to create a library from a project of mine. Does cljs library deployment differ from clj library deployment as described at https://github.com/clojars/clojars-web/wiki/tutorial ? If so, can anyone point me to current documentation on cljs library deployment? I've been doing some googling but haven't come up with anything that seemed definitive. Thanks!
OK, cool. And I bundle libs in one of the ways described at https://github.com/clojure/clojurescript/wiki/Dependencies ?
Or I'm guessing the most useful thing all around would be to package the JS lib itself into a CLJSJS package (as per https://github.com/cljsjs/packages/wiki/Creating-Packages ) and then just include it in my cljs lib. But I'm new to all of this (packaging for cljsjs, deploying a clj/s lib, etc) so I'm just feeling it all out still.
just curious: how much work would it be to enable cljs to compile macros? if it's a lot, what are the major obstacles?
@settinghead: Bootstrapped / self-hosted ClojureScript does support compiling macros.
@mfikes: i don't seem to get it to work correctly. for example, if i were to eval this code:
(defmacro unless [pred a b]
`(if (not ~pred) ~a ~b))
(unless true (js/alert "falsy") (js/alert "actually true"))
i get both conditions to run and end up having 2 alart boxesClojureScript macros must be defined in a separate namespace from the one they are called in and referred via the normal :require-macros
mechanism.
ah i see. i'll look into it. thanks
@settinghead: If you are curious, you can muck about in the deep end, messing with unsupported stuff (this aids a bit in understanding the machinery): http://blog.fikesfarm.com/posts/2015-09-07-messing-with-macros-at-the-repl.html
@settinghead: But, to do things the way they were meant to be done, just put them in their own ns. A small example is in this post: http://blog.fikesfarm.com/posts/2015-06-19-portable-macro-musing.html
@mfikes: awesome!
i'll take a look at the articles
@eggsyntax: interestingly the wiki does not discuss deps.js
@mfikes: which wiki do you mean (I linked to three)? I see the cljs one at least mentions deps.js
in passing...
It's mentioned briefly, in the CLJSJS section. But more info probably wouldn't hurt...or maybe a direct link to https://github.com/cljsjs/packages/wiki/Creating-Packages ?
My only guess is that lein
generates it for you. Otherwise the ClojureScript Wiki may need more elaboration. If you figure it out, I'd update it.
I've manually put together a deps.js
simply to specify externs (Goby calling into Objective C), but I don't have experience producing a lib that includes JS
@eggsyntax: What are you trying to package? Cljs lib or JS lib?
CLJSJS wiki mentitions deps.cljs being generated by Boot task
Yeah, there is a ClojureScript wiki that describes how to make a lib that bundles JS but it lacks deps.js
description.
@juhoteperi: ultimately I'm trying to package a cljs wrapper that I wrote for the MathBox JS lib. But I'm guessing that I could increase the overall value of it by first packaging the JS lib directly & sticking it on CLJSJS, and then referencing that in the lib containing my wrapper. Does that sound sensible?
I second using cljsjs
is awesome 😄
@eggsyntax: Sounds good. Though it's also possible to package the JS lib separately and deploy it to Clojars yourself, users don't see a difference.
But hopefully Cljsjs helps with packaging.
There is nothing special about Cljsjs packages, they are just normal Jars in Clojars.
is there a lein plugin to deploy to (s)ftp? I am lazy 😄
@richiardiandrea: why you use ftp?
I am open to new suggestions 😄
but we are deploying a website in the 90s 😄
@richiardiandrea: s3 + cloudfront rules
@richiardiandrea: I guess that site needs to run some of your deployed files though?
well it is generated with lein cljsbuild
then I was trying to find a lazy way to deploy ...s3 looks like a good options, there is a plugin I see
never configured cloudfront...but I guess I can find plenty of tutorials
for now I was thinking of a simple -> https://codeship.com/documentation/continuous-deployment/deployment-with-ftp-sftp-scp/#authenticating-via-ssh-public-keys
just for fun 😄
@richiardiandrea: I’m working on a little thing to make s3/cloudfront setup as easy as possible. ping me if you want to give it a spin
hi @martinklepsch, the ruby guy here.
is core.typed well supported in cljs? is there a quickstart for how to use it in a cljs project?
@pshk4r: if you first compile the modules away with webpack or something like that, then sure.
@jaen: it is already compiled to one js file. I included it, and used reagent/adapt-react-class
with that library's single component name, but it fails on finding window.React
. I've just realized it's probably because of javascript require order, must check it now
@richiardiandrea: you can use lein-shell
to run arbitrary shell commands to deploy to S3 or SFTP
thanks @danielcompton, you can even launch a .sh
I saw. I will do that initially
Well, it's not exactly wrong if it works, but yeah. That's where most support goes. If you decide to go into React then enfocus' author has a similar enlive-like library that works with React, kioo (though it's sometimes a bit verbose if you need to have a stateful component or something).
No problem. I've started out with kioo (even fixed a couple of bugs) because I had a separate team of designers I had to integrate with, and that where something like enlive shines
But like I said it is a bit on the verbose side compared to if you use the hiccup-like sablono, especially when the component needs internal state or something like that.
You have to wrap the kioo template in another function (or you could probably figure out a way to use kioo internals to avoid that, but I didn't have time to check it)
So I would probably use kioo only if I had to integrate with designers that don't know nothing about code or templates. Otherwise I'd probably go with sablono.
I assume you could start with sablano and then break into kioo when you have a template to add
From the React wrappers reagent is probably nicest to start with, has also nice flux-ish library in re-frame. There's even a non-trivial sample application using both - https://github.com/madvas/fractalify/
Does anybody know the React Native or Om way to restore UI controls' values (e.g., textinput text) upon changing back to a previous screen? I tried setting 'value' but then the cursor gets moved to before the beginning of the text after each character the user actually enters in the box [as there's no way to determine if the current render cycle is due to a) changing back to the screen from another 'modal'/popup if you will or b) the user actually entering text]). I tried a workaround where I kept some side state in another atom (that isn't being observed by Om Next) to store whether a screen change was occurring or not and that worked but only for the first render cycle-- if the user did something else on the page after changing back to the screen (like say checking a checkbox), then the side state had been cleared and my logic didn't set the 'value' of the textinput to that stored in app-state. I'm now considering an alternative workaround that should work (i.e., setting the 'value' of the textinput to the text stored in my big atom on every render except those triggered by an onChange event in the actual textbox in question); however, the idea of having 'side-state' in a 'side-atom' seems to go against the Om way.
@mudphone: for sure, I thought since you seem to have some experience in Clojurescript already, then having a reference application might be useful when learning how to use React.
Also, re-frame has nice wiki pages regarding how reagent works that might come in handy if you decide to learn React with reagent - https://github.com/Day8/re-frame/wiki#reagent-tutorials
I’ve only done some basic Reagent tutorials so far, but have done some minor stuff with Om (not Next)
This is really helpful. I’m going to see if I can get my local Clojure group folks to do a group session on this.
Yeah, they guy who wrote re-frame has some quite nice insight into reagent. At the very least Creating Reagent Components
is a must-read, explains differences between how you can define components in regent really well (you define components slightly differently depending on whether they are stateless, stateful or have to react to React's lifecycle events).
Update: my second workaround didn't work-- funky behavior on hitting backspace in the control: txt disappears completely although my code isn't touching 'value' on keypresses.
That's still better than zero I have in radius of hundreds of kilometers, therefore I'm kinda envious ; d
Well, if professors at my university don't even know what functional programming is, what are the chances of having a group for a relatively new FP programming language around P ;
So it's quite awesome you have your local group you can learn more about reagent or something with.
I did have a discussion with the head of our local CS department, who told me he couldn’t help me find speakers for talks on Category Theory because the subject was too “esoteric."
Oh, and the head of a different local CS department had never heard of Clojure… sigh...
I like to troll my professors with fringe languages. I once made a report for algorithms in Haskell. The professors, when I asked him later if there were any interesting languages among the papers was all like "well, there was Python" : |
Yeah, when you're a university/student you get a lot of free stuff from them. But it's one big walled garden. Hopefully that changes with .NET going open source.
I'm kinda sad to see MIT's CS 6.001 go from Scheme to Python, it's like the ideal language for intro to algorithms (like C is great for intro to hardware). I'm quite interested in what Elena Machkasova is doing with making Clojure more education friendly, like Racket. Clojure errors are one of the paint points for that.