Live data from Hacker News

Loopless Programming

code.jsoftware.com

71–80 of 129 posts

Re: Loopless Programming

#71
post #70

Earlier quoted context omitted.

In that case, maybe you might like to make an attempt at addressing his points.

There's no point in trying to explain things to someone who's aggressively defending their ignorance. (I have lots of experience being the aggressively ignorant guy.) Step one is realizing other people might know something you don't. After that it becomes useful to talk to you. Someone who's determined to dismiss what they're hearing can always find an excuse—especially in programming, where everything is Turing-comp…

I realize you might know something I don't, I promise!

Would you like to say any of those things? So far you've only given instructions that would take many hours to follow, not imparted knowledge or given a good description of why those instructions are worth the effort. You've given no hint of why the OP would be wrong, you've only been dismissive.

Re: Loopless Programming

#72
post #70

Earlier quoted context omitted.

There's no point in trying to explain things to someone who's aggressively defending their ignorance. (I have lots of experience being the aggressively ignorant guy.) Step one is realizing other people might know something you don't. After that it becomes useful to talk to you. Someone who's determined to dismiss what they're hearing can always find an excuse—especially in programming, where everything is Turing-comp…

I realize you might know something I don't, I promise! Would you like to say any of those things? So far you've only given instructions that would take many hours to follow, not imparted knowledge or given a good description of why those instructions are worth the effort. You've given no hint of why the OP would be wrong, you've only been dismissive.

Try watching this video; it will only take you 8 minutes, but within 3 minutes you should have an idea of why array languages are different from having an ndarray library available in Rust or having typeclasses in Haskell: https://www.youtube.com/watch?v=a9xAKttWgP4

After you watch that you will of course suspect that APL and other array languages like J are a sort of DSL for things like numerical linear algebra, which is of course what Numpy and Octave are. (Even though the Game of Life isn't linear algebra, it's very clearly matrix-based, so it doesn't seem that far off.) Dyalog has posted some other videos demonstrating the use of their proprietary APL for different things, but I think a more interesting one is https://www.youtube.com/watch?v=e0rywC7-i0U, by J inventor Roger Hui. This is an hour and a half, but it demonstrates some approaches to reducing different problems to multidimensional arrays, of pointers ("boxes") in some cases.

This ought to be enough to convince you that there's an alien kind of thinking here, quite different from the Haskell and Rust approaches, that can be applied to a wide variety of problems.

Now, I'm not Stevan Apter, so I'm not going to try to convince you that this alien kind of thinking is better. But it's clearly different, and different ways of thinking work best in different situations.

Re: Loopless Programming

#73
post #54
post #41

Earlier quoted context omitted.

You seem to have missed the point of the original remark that (x + y) is a statement, and you're missing the point of my clarification. > "(x + y) is an expression rather than a statement". The point isn't that (x + y) wouldn't be a statement in other languages, rather than point is that in languages the reader of the article is most likely to be familiar with, you would use a for loop to solve the problem, and obvio…

> The point isn't that (x + y) wouldn't be a statement in other languages, rather than point is that in languages the reader of the article is most likely to be familiar with, you would use a for loop to solve the problem, and obviously a for loop is a statement, not an expression. No, in other languages you would write one function that specifies how to perform an operation per type, then reuse that, and most linear…

> This seems like a pretty low-effort write-up.

You're not the audience for the article and that's what this entire thread shows. You missed the fact that you were not the audience, and that makes this a low-effort dismissal. Rather than trying to get the point of the article, you're picking on minutiae and trying to pick it apart. This is why we can't have nice discussions about programming languages.

The audience for the article is: people using, learning, or interested in J, who want to know how to think about loops in a "loopless" way, which the language encourages. The fact that you're talking about linear algebra libraries shows that you're not the audience the article is written for.

None of your points are wrong, in some cases you are literally restating my points, but you're not getting the emphasis. Rather than try to prove the article wrong, why not try to see it for what it is, and who it is aimed for, and leave it at that?

Re: Loopless Programming

#75
post #72

Earlier quoted context omitted.

I realize you might know something I don't, I promise! Would you like to say any of those things? So far you've only given instructions that would take many hours to follow, not imparted knowledge or given a good description of why those instructions are worth the effort. You've given no hint of why the OP would be wrong, you've only been dismissive.

Try watching this video; it will only take you 8 minutes, but within 3 minutes you should have an idea of why array languages are different from having an ndarray library available in Rust or having typeclasses in Haskell: https://www.youtube.com/watch?v=a9xAKttWgP4 After you watch that you will of course suspect that APL and other array languages like J are a sort of DSL for things like numerical linear algebra, whi…

Pretty mind-blowing. Any Haskell experts want to attempt a point-free version of the function that calculates the next generation for an arbitrary matrix in Conway’s Game of Life?

Re: Loopless Programming

#76

Earlier quoted context omitted.

And instead you use...?

Yeah I'd like to know also. Loops are a foundational operation. Instead of a loop you could use a function/operator overload, which would just call another function which contains the loop. But that isn't doing away with loops, it is just encapsulating them inside a function and calling them in order to avoid polluting up the higher level code context with loop code, and makes that upper context easier to read.

> Loops are a foundational operation. Instead of a loop you could use a function/operator overload, which would just call another function which contains the loop

That's incorrect, you can always replace a loop with a recursive function (e.g. as you do in Erlang where there aren't explicit loops)

Re: Loopless Programming

#77
post #75
post #72

Earlier quoted context omitted.

Try watching this video; it will only take you 8 minutes, but within 3 minutes you should have an idea of why array languages are different from having an ndarray library available in Rust or having typeclasses in Haskell: https://www.youtube.com/watch?v=a9xAKttWgP4 After you watch that you will of course suspect that APL and other array languages like J are a sort of DSL for things like numerical linear algebra, whi…

Pretty mind-blowing. Any Haskell experts want to attempt a point-free version of the function that calculates the next generation for an arbitrary matrix in Conway’s Game of Life?

That's a little unfair—the APL version in that video isn't point-free.

Re: Loopless Programming

#78
This article doesn't actually list any self-claimed "fundamental deficiencies". There's a reason that C (any many other languages) have been using pre and post conditional loops for over fifty years - because it's what the machine actually does, and they are straight forward to follow.

The article mentions "A C programmer would write", and then shows two nested for loops. This is almost correct, but I think any good C programmer would write this once as a method or a macro, and then calling it is as simple x + y, without the snake-oil.

In either case, both are going to execute something like

.loop CMP r0, r1 JNZ .end_of_loop ADD r2, r1 ; move some memory around JMP .loop .end_of_loop ;

And what does that look like... oh wow it's a loop.

The J language was written in 1990. It's now 2019. The language is just wrong.

Re: Loopless Programming

#79
post #51

Earlier quoted context omitted.

Is there a difference between loopless and " largely loopless". https://docs.oracle.com/cd/B28359_01/appdev.111/b28370/loop_... The wiki author, who also wrote J for C Programmers, never uses the word "unusual". He uses the words "different" and "better". Is it only the parent comment that invokes the word "unusual". The comment also implies J is not a "modern language", whatever that means..

PL/SQL is not SQL.

Do recursive CTEs count as SQL, then? Despite the name, they are practically loops.

Re: Loopless Programming

#80
2 questions:

- Doesn't "loopless" actually mean "implicit looping"? (unless you assume infinite parallelization)

- How do you debug a chain of "loopless" functions when some corner case invalidates your assumptions?

Post reply on HN