Live data from Hacker News

Stages of Denial

beyondloom.com

111–119 of 119 posts

Re: Stages of Denial

#111

Earlier quoted context omitted.

I'm not going to deny that learning any array language requires thinking slightly differently (as does any new paradigm), but really this example doesn't use anything particularly strange. {x#x{x,+/-2#x}/0 1} x x is the argument of an anonymous function {} , concat +/ plus reduce (sum) -2#x last two elements of x x f /0 1 applied x times to 0 1 x# take first x elements

It does have some strange things: - What's the scope of x? it appears to be the argument of two different anonymous functions. - Is / both apply and reduce? - So 'x f list' applies f to list x times. What if I use ',' instead of f? That is, what does 'x,/list-of-lists' do? does it flatten the list of lists and then concatenates x or does it flatten the list of lists x times? It seems confusing to have symbols that ac…

An anonymous function is defined (can't find a better word) between braces like {x+1}, in python (lambda x: x+1). There is an inner one, {x,+/-2#x}, and the outer one (the entire thing).

/ (like a lot of k symbols) does a few different things depending on context. In this case, if you do n f/x, where f takes a single argument (is a unary/monadic function), it applies f to x n times.

-2#x: yeah, it seems reasonable that it might negate the first two elements, APL uses ¯2 instead of -2 for this reason. In k however -2 is parsed as one number, as - then 2#...

Sure, there may be some complexities or questions, but there are in all languages, and in this case they were fairly simple things anyway to me.

Re: Stages of Denial

#113

Earlier quoted context omitted.

It does have some strange things: - What's the scope of x? it appears to be the argument of two different anonymous functions. - Is / both apply and reduce? - So 'x f list' applies f to list x times. What if I use ',' instead of f? That is, what does 'x,/list-of-lists' do? does it flatten the list of lists and then concatenates x or does it flatten the list of lists x times? It seems confusing to have symbols that ac…

An anonymous function is defined (can't find a better word) between braces like {x+1}, in python (lambda x: x+1). There is an inner one, {x,+/-2#x}, and the outer one (the entire thing). / (like a lot of k symbols) does a few different things depending on context. In this case, if you do n f/x, where f takes a single argument (is a unary/monadic function), it applies f to x n times. -2#x: yeah, it seems reasonable th…

> here is an inner one, {x,+/-2#x}, and the outer one (the entire thing

So in the inner one, x is the argument of the inner function or the argument of the outer one? Is x always an argument to anonymous functions?

> / (like a lot of k symbols) does a few different things depending on context

That's a recipe for confusion.

> Sure, there may be some complexities or questions, but there are in all languages

I can go back to the initial example: just browse other implementations of Fibonacci in different languages. For most of them you can actually understand a bit what's happening, even if it's a different paradigm (e.g, I can understand the Haskell or Clojure implementations without too many issues, and in fact I can learn things about the language from that). But operators that do different things depending on context, insistence on non-standard symbols, weird scope issues... That's not "complexities or questions that are in all languages", that's a recipe for confusion and extra complexity that you need to have in mind on top of the complexity of whatever you are coding.

Re: Stages of Denial

#114
post #54

I recently started using rust-analyzer with vscode. One common sight is this: thing .stuff() .other() .whatevs() Each of the calls returns a different type. Rust-analyzer displays the return type of each call to the right of it. I imagine something similar could reconcile the benefits of terseness with readability and discoverabilty. The blog post already has the prototype: + / ! 100 plus reduce range 100 Imagine the…

> Imagine the second line being added in by your ide in a light gray. So what would be the benefit compared to just writing `plus reduce range 100`?

I'm not sure, but imagine once you learned it you parse the sentence like a word. Like some of the Asian alphabets?

Re: Stages of Denial

#115
post #54

I recently started using rust-analyzer with vscode. One common sight is this: thing .stuff() .other() .whatevs() Each of the calls returns a different type. Rust-analyzer displays the return type of each call to the right of it. I imagine something similar could reconcile the benefits of terseness with readability and discoverabilty. The blog post already has the prototype: + / ! 100 plus reduce range 100 Imagine the…

> Imagine the second line being added in by your ide in a light gray. So what would be the benefit compared to just writing `plus reduce range 100`?

The benefit would be it being optional. You only need it while learning the language, whereas once you're familiar with the notation the terseness becomes a feature.

Of course once you've come up with clear names for each symbol you could do the opposite, let the IDE turn `plus reduce range 100` into `+/!100`. But as long as IDEs are still glorified text editors and devs care about the representation that gets stored on disk I would argue making the terse notation the default is the right choice.

Re: Stages of Denial

#116
post #103

Earlier quoted context omitted.

You certainly can do points-free programming in Haskell. It's the first place I ever heard of it. Ironically, points-free programming in Haskell has a lot of '.' in it.

Haha, I never understood why the point-free (aka "pointless") form in Haskell actually is the form that requires lots of "."!

"Points" means something like "elements". When you write

    \x -> f (g x)
you are defining a function that explicitly specifies how each "point" `x` is to be mapped. When you write

    f . g
you don't mention any point. You are abstracting away from the notion of point. That's why it's "point free".

Re: Stages of Denial

#117
Maybe the issue is that the symbols we readily accept are the ones we grew up with when learning Mathematics, + - * / ^ % = ..

If 'reduce' and 'map' had widely used symbols, which were taught in school / university as part of the standard curriculum, how different would coding look today?

Re: Stages of Denial

#118
post #73
post #52

So it is a language with single-character symbols for the most common array operations like map, filter etc. I think the article tries to make it sound more mysterious and groundbreaking than it really is.

the symbols compose in both directions and are aware of tacit parameters, so I don't really think your summary is even remotely correct

By "compose in both directions" you mean like arithmetic operators like + and * ? No doubt it is useful to have built-in operators for array operations if you have to do a lot of array operations.

Re: Stages of Denial

#119

Earlier quoted context omitted.

An anonymous function is defined (can't find a better word) between braces like {x+1}, in python (lambda x: x+1). There is an inner one, {x,+/-2#x}, and the outer one (the entire thing). / (like a lot of k symbols) does a few different things depending on context. In this case, if you do n f/x, where f takes a single argument (is a unary/monadic function), it applies f to x n times. -2#x: yeah, it seems reasonable th…

> here is an inner one, {x,+/-2#x}, and the outer one (the entire thing So in the inner one, x is the argument of the inner function or the argument of the outer one? Is x always an argument to anonymous functions? > / (like a lot of k symbols) does a few different things depending on context That's a recipe for confusion. > Sure, there may be some complexities or questions, but there are in all languages I can go ba…

Default arguments to anonymous functions are x, y, and z. You can also name arguments like this. {[foo; bar] foo+bar} is the same as {x+y}

I'm not denying it is probably more possible to gain a superficial understanding of what code written in other languages does than code written in k to someone who's never seen k before. This just doesn't seem like that important of a language feature. The 'confusion and extra complexity' you mention wouldn't really confuse anyone who'd tried k for more than a couple of hours (at most).

Post reply on HN