Fork me on GitHub
#off-topic
<
2018-03-31
>
qqq01:03:26

Why is 'callback hell' considered to be so bad? "Reagent + functiknal reactive programming + js callback hell", in my experience, is easier to debug than core.async.

sundarj10:04:38

a bit late on this, but you can see Rich explaining it here: https://www.infoq.com/presentations/core-async-clojure

fellshard02:03:56

It usually leads to reverse composition, basically; a difficult-to-read and verbose flow. Nothing inherently wrong, but when you combine it with Javascript and typical JS devs, you get... call(1, 2, 3, function(a, b) { c = a + b; call2(4, 5, 6, function(d, e) { ...

fellshard02:03:10

In-line ad hoc nesting

fellshard02:03:32

ad infinitum because all they want is procedural code

justinlee02:03:37

@qqq i’m starting to wonder the same thing myself. core.async is particularly hard to debug on cljs since it shears off your stack trace. i’ve been meaning to play around to see if clojurescript is inherently flexible enough to do what i need (which isn’t much) without having the indentation hell

qqq02:03:49

@fellshard: maybe my cljs code isn't complicated enough, but it rately gets that level. most of the time it goes:

register_js_handler() {
  stuff that modifies an atom;
}
then, that atom is reactive, so changing that atom triggers re-reners via reagent/react

fellshard02:03:58

I'm speaking mostly of why callback hell gets a bad rap; doesn't mean it must be bad, and in languages designed for it, it works perfectly well. It's a combination of Javascript itself having horrid lambda syntax and the immaturity of many JS devs that gives it that bad rap.

justinlee02:03:33

for me, i often have 3 or 4 async things in a row. if you use call backs, the indentation gets pushed right, or you write a bunch of functions with strained names and they have to be written backwards in time. I feel like there must be some sort of threading macro like magic that will fix this for me, but it might not really be possible without better language support

☝️ 4
fellshard02:03:57

Hence why it requires languages designed for it. Works extremely well with currying or pipelines.

qqq07:03:52

Anyone know why CounterClockwise (Eclipse) or EnClojure (Netbeans) never took off?

mpenet07:03:10

ccw was quite popular back in the days. I guess cursive just ate its marketshare over time.

sveri08:03:37

I would assume as much as there are people that dislike the JVM because its "clunky" they even dislike eclipse more, because its "bloated and slow".

qqq08:03:02

@sveri: Interesting, I didn't realize there was a significant portion of Java users that hate Eclipse.

sveri08:03:49

@qqq while there surely are java users that hate eclipse I was talking more of users of different programming languages that come to clojure.

cfleming09:03:07

@gklijs I have a DelayedFn I use:

public class DelayedFn implements IFn {

  private final String namespace;
  private final String name;
  private volatile IFn delegate = null;

  public DelayedFn(String namespace, String name) {
    this.namespace = namespace;
    this.name = name;
  }

  @Override
  public Object invoke() {
    return getDelegate().invoke();
  }

  @Override
  public Object invoke(Object o) {
    return getDelegate().invoke(o);
  }

  ... etc etc ...

  @Override
  public Object applyTo(ISeq iSeq) {
    return getDelegate().applyTo(iSeq);
  }

  @Override
  public Object call() throws Exception {
    return getDelegate().call();
  }

  @Override
  public void run() {
    getDelegate().run();
  }

  private IFn getDelegate() {
    // See 
    IFn result = delegate;
    if (result == null) {
      synchronized (this) {
        result = delegate;
        if (result == null) {
          if (!"clojure.core".equals(namespace)) {
            REQUIRE.invoke(asSym(namespace));
          }

          delegate = var(namespace, name);
          result = delegate;
        }
      }
    }
    return result;
  }
}

cfleming09:03:14

Then I have a static function which constructs them, so I use:

val callClojure = delay("my.namespace", "some-var")

...

val result = callClojure.invoke(a, b, c) as Something

gklijs10:03:28

@cfleming thanks I just have one namespace, and a couple of functions, but when I start using more, DelayedFn is nice.

qqq11:03:03

new is reserved by clojure for java interop; is there a three letter word meaning something similar ?`

dominicm22:03:28

sow is my favourite.

qqq15:03:30

What is the obsession of Eclipse, Netbeans, JetBrains with XMLconfig files? It seems like I can not build a plugin in any of them without lots of xml files and lots of Java wrappers.

tbaldridge15:03:14

same in Clojure, it's just that XML is a bit more verbose

qqq16:03:41

anyone here use Kotlin? bsides the lack of s-expr syntax, the language looks really nice

ajs18:03:59

Kotlin is very similar to Swift, almost identical in many respects.

ajs18:03:16

Much of the syntax is indistinguishable

gklijs18:03:18

I'm trying to put something together using spring, to compare to clojure.

sveri20:03:09

Kotlin is a nice language, succinct and expressive. But, as a lot of other languages, it lacks a good REPL. Or any REPL. Some complain about the REPL startup time, but miss that most web frameworks on the JVM have a longer deploy time for every change than the startup time of the REPL.

sveri20:03:31

For me this is the killer and the main reason I stick with clojure for my private stuff vs. kotlin.

fellshard21:03:44

It's pretty solid; I think it's got a feature bloat issue, perhaps, but it does a pretty good job at tackling a lot of very long-standing irritations with writing regular Java. I personally treat it kinda like Java++.