Fork me on GitHub
#clojure
<
2019-04-13
>
nathantech200501:04:55

I just learned that Clojure and Scala are both using tries for their list data types (persistent/immutable). But Elixir uses linked lists which can be spread all over the RAM (inefficient). Could this contribute to Clojure/Scala being better at data crunching? And Elixir is more for horizontal scaling because it doesn’t share memory.

nathantech200503:04:07

I made a mistake. Actually, Elixir can do vertical and horizontal scaling. It’s just not made for sharing memory (number crunching) like Clojure can do?

aryyya.xyz06:04:29

What is the difference between using require and :require? This code using require returns an error:

(ns hello-world.core
  (require [clojure.set :as set])
  (:gen-class))
The error message is “syntax error macroexpanding clojure.core/ns”. But this code using :require compiles just fine:
(ns hello-world.core
  (:require [clojure.set :as set])
  (:gen-class))

dominicm06:04:15

@aryyya.xyz the first is invalid inside of ns, it used to work by coincidence, now it doesn't.

aryyya.xyz06:04:20

@dominicm And which is conventional to use, :require inside of ns or require outside of it?

dominicm07:04:10

Inside of ns is conventional

yc-chiranjeevi06:04:07

What's the ":-"

yc-chiranjeevi06:04:30

Is it part of spec?

yc-chiranjeevi06:04:01

It seems it's some kind of type hinting?

yc-chiranjeevi06:04:43

E.g. (s/defn make-consumer :- FranzConsumer ...)

dominicm07:04:31

It's a type hint in the library schema

yc-chiranjeevi08:04:15

Thanks Dominicm!

borkdude11:04:07

Is it safe to assume that Clojure aliases dominate over Java class imports?

(ns foo (:import [java.lang Thread]) (:require [clojure.core :as Thread]))
(Thread/+ 1 2 3) ;;=> 6

reborg11:04:11

They seem to integrate “nicely” @borkdude but wouldn’t put that in my code. Do you have an use case in mind?

(ns foo (:require [clojure.core :as Thread]))
(Thread/+ 1 1) ;; 2
(Thread. "Hello") ;; java.lang.Thread 0x49872d67
(BTW No need to import Thread)

borkdude11:04:41

well, it clashes when you call a static method on Thread

borkdude11:04:02

I have no use case, but when analyzing code it’s good to know what to expect

reborg11:04:28

yeah, just tried. So no nice integration.

borkdude11:04:55

I think Clojure requires/aliases are prioritized, so I’ll assume that for now

reborg11:04:11

evidence seems to confirm that

lilactown17:04:33

so I’m thinking of doing a dirty thing and making some breaking changes to a library I maintain

lilactown17:04:54

mainly re-naming some functions. I’m curious if anyone’s ever done work on creating syntax transforms for Clojure that can be run on projects to help with migrations like this.

jaihindhreddy18:04:11

I believe the mainstream opinion is, don't break consumers. Have you considered deprecating instead of breaking?

lilactown18:04:41

I have 🙂 these functions are really a part of a set of idioms and naming conventions that I want to change for users of my library

lilactown18:04:03

I’d prefer to rename them and then give my consumers a utility to convert their code from the old naming contention to the new naming convention

seancorfield19:04:35

I would strongly recommend introducing a new namespace with the new API and announcing to your users that the original API namespace is deprecated and encourage them to switch to the new namespace.

seancorfield19:04:14

But then keep the old API namespace around for a long time (just don't maintain it).

lilactown20:04:55

I think even with deprecation, it would still be cool to have utilities that could help refactor code when API migrations occur. it sounds like this hasn’t been something people have done in Clojure

seancorfield20:04:29

Yeah, a migration utility could well be a good idea, depending on how much code out there depends on your library.

micha18:04:14

you can see it in use on line 357 of that file, for example

lennart.buit21:04:18

does it make sense to use leiningen and tools.deps side-by-side?

lennart.buit21:04:18

does it make sense to use leiningen and tools.deps side-by-side?

lennart.buit21:04:13

like with lein-tool-deps. I am asking because tool.deps has nice git integration

seancorfield21:04:38

Based on my experience writing and using boot-tools-deps -- Boot + deps.edn -- I would say that, ultimately, you'd be better off just switching to clj completely.

seancorfield21:04:21

These integrations tend to have limits. Basic stuff works well. More complex stuff tends to have weird behaviors.

seancorfield21:04:01

Boot and Leiningen might be different enough that the limitations I hit with Boot don't impact you in Leiningen in the same way... If I were you, I'd chat with Rick about any known limitations (when he's around).

lennart.buit21:04:36

right, thanks! I must admit that I spent as little time as possible dealing with configuring tooling, but I start to see that not having Git deps is starting to be a nuisance

seancorfield21:04:37

At work, we started with Leiningen back in 2011, switched to Boot at the end of 2015, and then introduced deps.edn last year, via boot-tools-deps, at first, but then switched completely to clj. We've been very happy with the switch.

lennart.buit21:04:04

yeah at my work all of our projects use lein, but… to be quite honest, I don’t know why. I’ll investigate some more

lennart.buit21:04:02

maybe switching whole makes more sense!

seancorfield21:04:14

Chat to Rich when he's around, and see what limitations he's aware of with the lein integration.

seancorfield21:04:10

As the author of boot-tools-deps, I wouldn't recommend the hybrid approach with Boot, except as a bridge to migrating from Boot to clj. Some of that is to do with how Boot deals with dependencies, the classpath, pods, and so on.

dorab20:04:41

The main issue I ran into when using lein-tools-deps was that the dependency resolution for lein is similar, but not the same as tools.deps. So, even with the same dependencies, the resolutions might be different if you use (for example) lein uberjar you could potentially get different versions of some libraries than if you ran the clojure script. I would second @ in recommending that a hybrid approach only be used during transition.

vemv21:04:11

@lilactown although slightly hacky, I think one also can do that sort of thing with https://github.com/clojure-emacs/refactor-nrepl/#find-symbol. I've used both tools (refactor-nrepl + rewrite-clj) and the latter can be a bit low-level.

hadilsabbagh1823:04:24

Anyone have experience with enums in lacinia?