Clojure control flow. There's a lot of options!


#1

I’m new to Clojure. There’s a lot of interesting Clojure control flow structures that are not built-in to other languages. You might think of pattern matching and dispatch as a form of control flow, too. Also, this might be a good way to introduce the idea of Clojure as a functional imperative language vs Haskell which is functional declarative.

But I’m a noob. What do you think?

Please vote. Comments are encouraged!

  • :thumbsup: Yes, please teach this!
  • :thumbsdown: No, I’m not interested.

0 voters


#2

Hey Jeff,

Thanks for the cool topic. Are you into the theoretical side of languages?

Eric


#3

I am, although I’m not very conversant with the topic.

I’m a topologist by training, but you can’t feed a family on topology!

I guess my interests are mainly along the lines of this: we are stumbling our way to something big about a theory of how to do things. The ancient Egyptian really thought geometry was about measuring land. A few hundred years later, and people realized that it was really about the things that are true when the identity relation is “has similar shape”. Topology is about the identity relation “can be stretched into the same shape”., things that stay the same under conditions of infinite stretchiness.

What’s computer science? To me, it’s as much about computers as astronomy is about telescopes. Not much. Seems like we are grasping at a way to theorize with the identity relation “does the same thing”.

I dunno. May seem like abstruse bullshite, but that’s my interest anyway. Not the kind of thing you can feed a family on, but one might do something really cool.


#4

Hi @Jeff,

That’s awesome. I don’t think it’s bullshite. I think it’s one of the hidden lessons of Computer Science. We should be thinking more along these lines in general.

I wrote something about this recently: https://purelyfunctional.tv/issues/clojure-gazette-180-how-do-you-structure-your-apps/

One day recently in the shower, I realized the answer. And it’s so simple. How do you structure a functional program? With the same structure as the problem. This principle applies to any paradigm, but it’s obscured by OO languages.

The idea of a structure to our problems that could be isomorphic to the structure of our programs is directly related to topology. But the more I talk to Clojure programmers about this, the more I get the feeling that I must have learned this somewhere else. My work in Haskell, perhapse?

The universal process for structuring software to solve a problem: first, understand the problem to some degree, which includes concepts and their relationships. Second, map those concepts and relationships to constructs in the language. Third, write a solution using those constructs, which will deepen your understanding. Then repeat all the steps as many times as needed.

The key is the mapping to constructs with similar structure. Thanks for the discussion :slight_smile:

Rock on!
Eric


#5

I always thought being a topologist would give a family more options for eating? Since a coffee cup and a donut are topologically equivalent and whatnot…