Fork me on GitHub
#beginners
<
2022-01-04
>
zeitstein09:01:59

I'm seeing Datascript's performance degrade by a factor of about 3-4 going from JVM to CLJS. I'm wondering whether running a local JVM server would be worth it performance-wise, considering the necessary overheads of doing so (e.g. transit). Any thoughts?

practicalli-john10:01:06

It doesnt matter if the CLJS version is not as performant as CLJ, if the CLJS version perfromant enough within the overall system (no need to optomise unless its really needed). If there is a performance issue that is effecting the system and its users, then its probably worth using the JVM (especially if the performance is likely to grow as an issue)

zeitstein10:01:00

All good points, thanks. I'm designing the system, so I'm thinking through the possibilities.

practicalli-john11:01:25

Definately worth a spike to compare the relative performances if there is time. I often implement two or more approaches for more important design decisions.

gratitude 1
raspasov10:01:03

Yeah, it's a known issue. Are you using DataScript in the browser? Or this is for a server-side CLJS/JS setup?

raspasov10:01:02

That being said, DataScript apparently has gotten decent perf. improvements recently and anecdotally things do feel faster but I have no exact numbers, take it with a grain of salt (I am using DataScript in a React Native project, mainly iOS) https://github.com/tonsky/datascript/releases/tag/1.3.0

zeitstein23:01:32

Pull is drastically faster, I've measured 🙂 I might have overestimated the degradation factor, it seems to me more about 2-3. I don't think its DataScript specific? JVM vs. browser.

👌 1
Romit Gandhi13:01:34

Hello, I'm new to Clojure. I wanted to know what is the best folder structure for clojure and clojure-script (re-frame) ?

athomasoriginal16:01:25

For clojure, I would steer you to https://github.com/seancorfield/next-jdbc/tree/develop/src/next to see how it’s structured. Yes, this is a library, but there isn’t much difference. So:

org-name.app-name/
   src/
     app_name/ ;; "implementation" details
     app_name.clj
From my experience, the best results come from: • A simple structure • Give each namespace a meaningful name and have it serve a purpose. e.g. don’t use names like core or index . They don’t tell us anything about the namespace. • Don’t worry about files getting “too big” — infact, load them up at first unless you have a very clear picture of what it’s supposed to be. • Your structure may evolve over time, this is fine. For reframe, they actually have an approach which they provide: https://github.com/day8/re-frame/blob/master/docs/App-Structure.md

mal16:01:33

If you use a template for a certain type of project a lot of times it lays the ground work… e.g.

$ lein new re-frame your-app-name
https://github.com/day8/re-frame-template

Romit Gandhi17:01:16

Thank you @UH1MELU4U for sharing this, Actually I didn't like to put events and subs in single file. Do you make folders for events and subs and import all that files in the core.cljs ?

Romit Gandhi17:01:36

Thank you @U6GNVEWQG, do you have anything specific structure of proper web development project that will help me very much.

athomasoriginal17:01:38

I don’t have one up right now for front to back. My front end projects look like this: https://github.com/athomasoriginal/create-reagent-app

👍 1
Muhammad Hamza Chippa20:01:56

{"user_account" [{"user_account_id" 1, "user_type" 0}]} I have this type of data in the clojurescript file, I wanted to convert string into keyword how can I do that clojure.data.json is not working in the clojurescript file ?

pavlosmelissinos20:01:43

> clojure.data.json is not working in the clojurescript file > Yes it's not supported but the data is not json anyway (edited misleading statement to avoid confusion) I assume it's a clojure map. Try https://clojuredocs.org/clojure.walk/keywordize-keys. As well as https://github.com/clj-commons/camel-snake-kebab if you want more complex conversions

seancorfield20:01:37

@UEQPKG7HQ Also, clojure.data.json is Clojure-only -- you cannot use it in ClojureScript.

👍 1
pavlosmelissinos21:01:36

Oh right, didn't think of that, thanks. In any case, both keywordize-keys and camel-case-kebab work in cljs!

1
seancorfield20:01:05

(! 714)-> clj -Sdeps '{:deps {org.clojure/clojurescript {:mvn/version "RELEASE"}}}' -M -m cljs.main -r
ClojureScript 1.11.4
cljs.user=> (require '[clojure.walk :as walk])
nil
cljs.user=> (def data {"user_account" [{"user_account_id" 1, "user_type" 0}]})
#'cljs.user/data
cljs.user=> (walk/keywordize-keys data)
{:user_account [{:user_account_id 1, :user_type 0}]}
cljs.user=> 

seancorfield20:01:52

And it works the same in Clojure in this case:

(! 715)-> clj
Clojure 1.10.3
user=> (require '[clojure.walk :as walk])
nil
user=> (def data {"user_account" [{"user_account_id" 1, "user_type" 0}]})
#'user/data
user=> (walk/keywordize-keys data)
{:user_account [{:user_account_id 1, :user_type 0}]}
user=> 

🙌 1