This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-11-03
Channels
- # beginners (50)
- # cider (6)
- # cljdoc (2)
- # cljs-dev (19)
- # clojars (2)
- # clojure (20)
- # clojure-dev (35)
- # clojure-italy (2)
- # clojure-norway (12)
- # clojure-uk (17)
- # clojurescript (7)
- # data-science (3)
- # datomic (10)
- # emacs (2)
- # events (1)
- # figwheel-main (2)
- # fulcro (8)
- # graphql (1)
- # juxt (3)
- # nrepl (4)
- # off-topic (23)
- # parinfer (1)
- # pathom (63)
- # re-frame (7)
- # reagent (1)
- # reitit (5)
- # ring-swagger (1)
- # shadow-cljs (23)
- # tools-deps (16)
@rgb.ide I’d start by asking myself is REST really what I want, and independent of the answer, start looking at the architecture behind https://github.com/capitalone/cqrs-manager-for-distributed-reactive-services/blob/master/doc/architecture.png and the talks @bobbycalderwood has given on the subject. Then I’d think about why GraphQL or its likes are not a better fit than REST.
Not to start a debate but in which context would you say GraphQL is not a better fit than REST?
@slipset nice approach. I have already started building out a "Restful API" without really understanding much about it. I think I may need to take a step back learn a bit more about RESTful API's and other approaches like GraphQL and how well they suite my usecase. Thanks @slipset, @dominicm.
If the purpose of your api is to serve an SPA, I’d say REST is the wrong approach.
Not sure what you mean. Do you mean write it to a file?
In memory, a byte array is in a binary representation, is one way of thinking of it, hence my question back to you.
or maybe you want to print it out for debugging as a sequence of 1s and 0s?
So if you have a way to take a single integer and convert it into a sequence of 0s and 1s, then you can see how to build that up for a byte array, I hope?
And there are many ways to do it, so a question would be: do you need a way that will have the highest performance among all possible ways (or close to it), or you just need some way that is correct? (e.g. maybe performance is a secondary or lower concern because this is for debugging)
For example, here is a way to get a Java/Clojure string of "0" and "1" characters, which could then be converted into a sequence of integers 0 and 1, but that isn't going to be the highest performance way to get a sequence of integer 0s and 1s: (Integer/toBinaryString 148)
returns "10010100"
(Integer/toBinaryString 5)
returns "101"
, so if you want the sequence to always contain 8 integers, you need to pad 0s on the left side for small values.
I was wondering if there was a way to bypass integer representation; still it's not a big problem, the above code is correct
There is also a Java class BitSet that you can call java.util.BitSet/valueOf and pass it a byte array, and it will create an object that you can then get the value of each bit one at a time given its index.
That may be faster than creating an intermediate string, but I haven't measured.
Example: (def b1 (java.util.BitSet/valueOf (byte-array [148])))
Then: (map (fn [idx] (if (. b1 get idx) 1 0)) (range 7 -1 -1))
returns (1 0 0 1 0 1 0 0)