11 ms·
A nice demonstration of how the K REPL can be used as a calculator and exploratory tool. The concise syntax particularly shines in interactive cases.
by RodgerTheGreat 7y ago
A nice demonstration of how the K REPL can be used as a calculator and exploratory tool. The concise syntax particularly shines in interactive cases.
- DaiPlusPlus 7y ago> The concise syntax particularly shines in interactive cases If you can tolerate the learning-curve though. For comparison, I do appreciate that many (most?) Linux shell utilities and command-line programs in general have adopted standard conventions for arguments (-f for short, --full for verbose) which make it easier for people new to a program to take a cryptic command-line and look-up the full-versions of the abbreviated commands to see what's going on - PowerShell does the same thing with its strict aliasing of cmdlets. Unfortunately I can't see that K (or many other programming languages really) do the same thing, where a a short, cryptic program can be syntactically expanded to one using verbose syntax with no changes in program semantics (unless you count VB.NET vs C# equivalence, heh). Is there any automated explainer tools for the K language for beginners?
- smabie 7y ago> Is there any automated explainer tools for the K language for beginners? I think q is a better starting out point than k. Most functions in q have readable names (each in q vs ' in k, for example). Also it comes with a richer library of functions.
- nprescott 7y agoNot long ago there was a post about using English language instead of the J symbology[0] but the end result isn't meaningfully easier to understand because of all the prerequisite knowledge of how evaluation works etc., once you've worked that out most of the "line noise" has already sunk in. I think that's a big sticking point against creating a second "inflatable" notation - though there is always Nial[1] Not entirely an answer to your question, but J provides introspection/help in a pretty direct way via two distinct means, the first is ;: ("words") which will show you the parse of a J phrase (here, a pretty direct translation of the algorithm in the article): ;:'+/s>(s,#v)$/:\:,/v&%"0 (0.5+i.s)' ┌─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬──┬──┬─┬─┬─┬─┬─┬─┬─┬─┬───┬─┬──┬─┬─┐ │+│/│s│>│(│s│,│#│v│)│$│/:│\:│,│/│v│&│%│"│0│(│0.5│+│i.│s│)│ └─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴──┴──┴─┴─┴─┴─┴─┴─┴─┴─┴───┴─┴──┴─┴─┘ Which shows the tokens of the phrase, which can be helpful if you are unsure of where a symbol or diacritic is being used. Inside the J IDE you can get context sensitive help by pressing Ctrl-F1 on a symbol, if you were interested in /: for example, you are directly linked here[2]. I am unaware of a similar tool in K, which should not be taken to mean it doesn't or can't exist. One of the reasons I'm interested in J has been the tooling and documentation available. [0]: https://wjmn.github.io/posts/j-can-look-like-apl/ https://wjmn.github.io/posts/j-can-look-like-apl/ [1]: https://tangentstorm.github.io/nial/intro.ndf.html https://tangentstorm.github.io/nial/intro.ndf.html [2]: https://code.jsoftware.com/wiki/Vocabulary/slashco https://code.jsoftware.com/wiki/Vocabulary/slashco
- rgoulter 7y ago> The concise syntax particularly shines in interactive cases. I think this is a good point. In an interactive environment: you can iteratively build the expression up, and you have the right chunks of context in working memory as you do it. You'd still need to learn what the different functions/operations are; but in a one-line REPL the use of symbols would allow you to fit more on a line than using more traditional identifiers. That avoids many of the things I'd be concerned about for writing code like this if I had to come back and read or modify it months later.