Live data from Hacker News

Stages of denial in encountering K

nsl.com

201–210 of 432 posts

Re: Stages of denial in encountering K

#201

Look, I don't hate K. It's probably a pretty good language for the task it seems to have been designed for, which appears to be numerical computing. Being able to fit an entire code on a screen is an interesting concept; while I'm not completely convinced it should be a goal in and of itself it's certainly something I can't rule out as a possible productivity booster. However, I still find it problematic, and it's no…

> the claims it's perfectly readable, and anyone who says anything otherwise is either stupid, lying, or too poor to understand it are not useful.

Yes: It is perfectly readable once you know how, and anyone who says anything otherwise is just plain wrong. Including you 58 days ago.

I don't know if you are wrong because you are lying, or you believe this because you are stupid. I wrote off at the time that it was well-meaning ignorance, but it doesn't really matter: The key thing, that is, the thing holding you back from reading it, is you.

I believe you can learn to read it and read it as well as me as quickly as with a few months of study. If you think anyone else is telling you otherwise, ignore them.

I don't believe you need to not be "poor" to do it - everything you need is available to you.

It's all about whether you want to do this or not.

> Every "inspired" languages hits these issues, depending on how "strange" it is: Objective-C is ugly, Lisp is alien, and on the far end APL derivatives are simply labelled as unreadable. That doesn't mean they're bad languages, but to those promoting it: drop the attitude, and understand why we have reservations.

We understand because we were once you: Every X-evangelist you're talking to (where X is Lisp, or Objective-C, or in this case K) was once like you in at least the way of not knowing X, so we know you are wrong in a way (as we now know X) that you simply cannot comprehend yet. Think about that. Maybe re-read Paul Graham's blub article and appreciate really what it means to be the blub programmer.

Many K programmers have some familiarity with APL. Some (like myself) have used Objective-C and Common Lisp (I've got over a decade of professional history in CL), and loads of other languages. Until you learn K, all you have is our testimony; our gospel that this is worth learning. You can literally do anything in blub, being able to do it easier is the point.

Re: Stages of denial in encountering K

#202
I love the brevity of regular expressions and use them on a daily basis. It is the same argument that keeps me returning to K: the syntax is terse and compact, the semantics are simple and composable, and your eyes get used to it.

Beyond a point however, I cannot read my own regex's after a month's absence. Which is why I use perl's /x modifier extensively to split up regex components onto multiple lines and to document them thoroughly, even if they are for throwaway scripts, because I don't always throw them away!.

For example:

    $_ =~ m/^                         # anchor at beginning of line
            The\ quick\ (\w+)\ fox    # fox adjective
            \ (\w+)\ over             # fox action verb
            \ the\ (\w+) dog          # dog adjective
            (?:                       # whitespace-trimmed  comment:
              \s* \# \s*              #   whitespace and comment token
              (.*?)                   #   captured comment text; non-greedy!
              \s*                     #   any trailing whitespace
            )?                        # this is all optional
            $                         # end of line anchor
           /x;                        # allow whitespace
(source: https://www.perl.com/pub/2004/01/16/regexps.html/)

This is where K fails me. It may not be a fault of the language, but everyone in the community has bought into this strange idiomatic style. I can't imagine debugging it, or checking it for correctness, or foisting it on a less experienced developer. Here's a canonical example an xml parser, on their website.

https://a.kx.com/a/k/examples/xml.k

Where's the pedagogy? Where are the comments? Why is this line noise considered acceptable?

Re: Stages of denial in encountering K

#203
post #107

A million-line program isn't readable by anybody, no matter how readable the language is. If the equivalent program can be written in, say, a thousand lines in some more concise language, that's more than worth the learning curve, even if the language is strange and off-putting.

I find that in these discussions people think that complexity can be escaped. A program cannot be less complex than the problem it solves. Of course you can add even more complexity if the programmers are not good, but that lower bound cannot be surpassed.

In your example, assuming that a million-line program is well done in its language, you'd have exactly the same complexity but now in a thousand lines, meaning that now each line does more, is more complex and changing it/understanding it is more difficult and prone to errors. It would be equally (if not more) impossible to understand.

If it were me, I'd choose the million-line program and keep the ability to understand parts of it and performing maintenance with just the program reference by my side, not the language reference too.

Re: Stages of denial in encountering K

#204

Earlier quoted context omitted.

https://en.wikipedia.org/wiki/Write-only_language >Languages that are often derided as write-only include APL, Dynamic debugging technique (DDT), Perl,[2] Forth, Text Editor and Corrector (TECO),[3] Mathematica, IGOR Pro and regular expression syntax used in various languages.

You've got me wondering about the utility of a genuinely write-only language. As a thought experiment, would there be benefit to letting functions only be written once? No-one could come along and break code by changing a function. If you wanted to fix a bug in a function you would have to write a new copy and explicitly update callers to use the new version. A lot of maintenance overhead? Possibly, but tooling would…

What an absolutely fascinating idea! As the field of software engineering matures, how million line repos get maintained is going to become a subject of academic study.

> If you wanted to fix a bug in a function you would have to write a new copy and explicitly update callers to use the new version.

Finding all callers is the hard part though! And in modern languages, that need to be addressed both at compile (or "compile") and run time.

Assuming you've got all the call sites with what constraints you were given and have imposed, the second part, where you call a specific version of a function, is where it gets tricky.

Is the bug in the calling code or the called code? because huge software maintenance is obtuse. The original programmers have all long since left, so what we're left with is a smattering of random specific version calls, with only the tiniest of tidbits of history, locked away in someone's email, and saved in the previous ticketing system.

So it sounds interesting, but I worry (though I worry about a great many things), that the programmer three years later, ends up coming across calls to three different versions of some code, with no guidance on which ones can be upgraded, should be upgraded, and must not be upgraded. I can't say which one would involve digging up more ancient history though.

Re: Stages of denial in encountering K

#205
post #132

Earlier quoted context omitted.

This one comment managed to insult both K and Perl coders...

I don't think Perl coders need any help with that.

For non-perl guys: It is a cryptic example, because it uses ‘system’ variables in a non-obvious way, not because of syntax. I can read it syntactically just fine, but have to look up for names to understand what it does. A fully uncodegolfed variant would require the same effort here.

Re: Stages of denial in encountering K

#206
post #97

Earlier quoted context omitted.

k costs $20,000 per-core (less accurate now than it used to be but I'm pretty sure it's still true for commercial uses). It has a billion-dollar company based entirely around it (Kx/FD) and a smaller multimillion one, so it worked out well, I guess. J is free, but J has never had an advertising budget, and was only freed recently. APL's current leading implementation is really bad in comparison to how nice the langua…

A language doesn't cost... the environment might. Why did nobody pick up on the ideas? C# is not inspired by K, Go is not, Swift is not, Rust is not, Clojure is not... I mean, take any big or small company that decided "we need a new programming language" - I'm not aware of many taking inspiration from K. I get it, there are people who love K, and are productive in it. And I'm not even claiming the ideas of K are inh…

> But you know, when the rest of the world "doesn't get it", _maybe_ the reason is not that the rest of the world is dumb?

Look at the kind of replies you get on every hn thread on APL/J/K - the majority of the negative comments around readability are emotional/gut level responses.

People aren’t trying to understand K examples for a couple of hours and failing... they are making snap judgements based on their experiences in other languages.

That is hard to overcome.

Re: Stages of denial in encountering K

#207

I went through a similar transformation when I finally understood LiSP. I knew Python and had programmed in it for several years but it was breaking into Scheme that changed my approach. I wonder if learning new paradigms always changes how you use other languages.

According to Peter Norvig, you were half-way to Lisp using Python:

https://norvig.com/python-lisp.html

Re: Stages of denial in encountering K

#208
post #125
post #107

A million-line program isn't readable by anybody, no matter how readable the language is. If the equivalent program can be written in, say, a thousand lines in some more concise language, that's more than worth the learning curve, even if the language is strange and off-putting.

Only if it's written in a style which affords reading. K programmers seem to want to write their code in a mathematical style, but without the natural language prose which makes mathematical papers readable. In a paper by a mature mathematician, the equations only perform some of the work in expressing the idea. The rest of the work is done by prose written with an intent to be lucidly expository, to allow the notati…

> but without the natural language prose which makes mathematical papers readable

A mathematical paper introducing some meaningful worker function uses English because mathematical notation is insufficient for describing computation. That's one of the important goals of Iverson's notation.

> We have this style in the programming world. It's called Literate Programming. How many K programmers write in that style?

Quite a few! I would actually suggest there are more literate K programmers than there are literate C programmers! Every 4-5 lines of code probably has 2-3 lines of prose in a large application that I work on, but in another language that might be something like 500 lines of code for 2-3 lines of prose which puts the prose offscreen for most of the code it's describing.

Some C programs will try to keep the prose-to-code density higher than that, but even amongst Knuth's code that's rare.

Re: Stages of denial in encountering K

#209
post #201

Look, I don't hate K. It's probably a pretty good language for the task it seems to have been designed for, which appears to be numerical computing. Being able to fit an entire code on a screen is an interesting concept; while I'm not completely convinced it should be a goal in and of itself it's certainly something I can't rule out as a possible productivity booster. However, I still find it problematic, and it's no…

> the claims it's perfectly readable, and anyone who says anything otherwise is either stupid, lying, or too poor to understand it are not useful. Yes: It is perfectly readable once you know how , and anyone who says anything otherwise is just plain wrong. Including you 58 days ago. I don't know if you are wrong because you are lying, or you believe this because you are stupid. I wrote off at the time that it was wel…

> I believe you can learn to read it and read it as well as me as quickly as with a few months of study.

Then it's not perfectly readable. That, or your definition of readable is useless because then any programming language is readable given enough study time.

> being able to do it easier is the point.

I still haven't seen any example where it is actually easier. Shorter? Yes. Easier? Very debatable.

Re: Stages of denial in encountering K

#210
post #201

Look, I don't hate K. It's probably a pretty good language for the task it seems to have been designed for, which appears to be numerical computing. Being able to fit an entire code on a screen is an interesting concept; while I'm not completely convinced it should be a goal in and of itself it's certainly something I can't rule out as a possible productivity booster. However, I still find it problematic, and it's no…

> the claims it's perfectly readable, and anyone who says anything otherwise is either stupid, lying, or too poor to understand it are not useful. Yes: It is perfectly readable once you know how , and anyone who says anything otherwise is just plain wrong. Including you 58 days ago. I don't know if you are wrong because you are lying, or you believe this because you are stupid. I wrote off at the time that it was wel…

Take a break from K (or any other shorthand language of your choosing) for a year or five, then come back and try to figure out what the code you wrote when you were using it frequently is actually doing.

Now do the same with well-written, verbose C-style or Python code (no shorthand/abbreviations, no lambdas, no ternary notation, etc.).

Shorthand code in any language is bad in the long run because it's unmaintainable except by people who work with it on a regular basis. You are making the same arguments as Perl fanatics who used every possible abbreviation in their language 25 years ago. How much of that is even comprehensible now without a major reverse-engineering effort?

Post reply on HN