Fork me on GitHub
#clojure-uk
<
2020-12-12
>
jiriknesl20:12:50

Hi guys, for some reason, we are going to do mob programming in Forth next week. Everyone seems excited to do so. Do you have any idea why would Forth be interesting for Clojure dev? I have just tried to hack in it for an hour. It is stateful, nothing is immutable, it seems to be very very low level and the whole concept of reusability is way different from any other functional language. What exactly is that attractive on Forth?

jiriknesl20:12:29

In the past, I have read Color Forth book. Twice. I bought the idea behind until today when I have finally tried to work in Forth. It is exactly the opposite of functional programming. Stack = state is everything. It is even worse than SQL database procedures. They at least have a schema. With Forth, you just have a bunch of data that can be basically anything and you have to somehow believe, you will end up with the right stack in the right time.

jiriknesl20:12:40

And also rearranging of stack seems so hacky to me. For the same reason I don’t like point-free programming in Haskell. Theoretically, you could rearrange anything into a weird mixture of (.) . (.)-ies. The same goes with Forth fith dups, swaps, overs, etc. but without any typing, variable naming, or anything in place.

seancorfield20:12:24

Forth is a fascinating language but it isn't to everyone's taste.

seancorfield20:12:18

If you want a modern take on Forth, look at https://factorcode.org/

👍 1
seancorfield20:12:43

There's an interesting hybrid of Clojure and Forth-like coding in Gershwin https://github.com/gershwin/gershwin (unfortunately its doc site is no longer accessible). It uses an old fork of Clojure and hasn't been maintained for years but back when we were using that old version of Clojure, I actually converted some of our code at work to Gershwin to see how it worked. It's pretty cool.

jiriknesl20:12:42

The thing is - I thought Forth is fascinating. This is why I read Color Forth book twice. It was all until I have tried to work in it.

jiriknesl20:12:11

Now, it doesn’t seem practical to me at all.

seancorfield20:12:15

Learning radically different languages can make you a better programmer (per Pragmatic Programmer advice) but you need to actually build stuff using it, not just read a book.

jiriknesl20:12:45

I know that learning absolutely different paradigm can make me a better programmer. This is why I learn about Forth, Prolog, APL & J, Datomic, lambda calculus, etc. But catching an “idea behind” from the book is different from using the thing. What if your experience from Macromedia with CF was more useful than my experience with Forth even when CF is more mainstream just because Forth is innovative, but also unnecessarily weird?

jiriknesl20:12:18

Before Clojure, I have tried working in Erlang and I have abandoned the language just because of its weirdness.

seancorfield20:12:02

I only meant that you can't really internalize the concepts in a language without building something a bit more than a toy with it. And, yea, APL and Prolog would be other languages I'd recommend (I've built stuff in both).

jiriknesl20:12:16

Maybe it’s just me, but I somehow need to lower the cognitive load of the language. I need true to be true. I need a function to look like a function. So I can absorb new ideas in usable way.

seancorfield20:12:07

Like I said, not to everyone's tastes. I love APL (but dislike J -- using ascii loses the elegance of APL), I love Prolog too -- and I had fun learning Erlang because it reminded me of Prolog so much.

jiriknesl20:12:32

I love APL - in theory. I have never tried to develop anything in it. Even when I have spent a lot of time thinking how to turn all my code into a mixture of comp-s, partial-s and how to treat values the same way as vectors and matrixes. But the thing is - is it really practical once you run into a real world scenario?

jiriknesl20:12:08

And the same goes for Forth. Building bottom up language seems attractive. It is similar promise one gets with Lisp languages. But in fact, I usually end up with 1-2 macros in the whole project.

jiriknesl20:12:36

And in fact, 1-2 macros are just syntactic sugar just because I don’t want to wrap my code in (fn …) for aesthetic reasons and lots of cases for macros are prevented by lazy collections or by reusing existing fns and macros.

seancorfield20:12:49

I learned APL at an insurance company where it was in very heavy usage.

seancorfield20:12:21

I originally learned Prolog at university but later worked at an actuarial company that did a lot of work in Prolog.

seancorfield21:12:19

As for Forth in commercial usage: https://www.forth.com/resources/who-uses-forth/ -- although it's hard to know how many of those companies still use Forth (or even still exist?).

jiriknesl21:12:07

I am sure there are lots of people working in Forth and they would speak happily about it. It is also the reason we do it - one of us was speaking about Forth so much we have decided to do a mob programming coding dojo in it. But as I am preparing for it, it doesn’t seem so good as my expectations.

seancorfield21:12:17

Perhaps I liked it better because I'd used a reverse-polish programmable calculator at school and I used dc on Unix a lot...?

😺 1