K7 Tutorial

(shakti.com)

97 points | by chl 61 days ago

12 comments

  • apricot 61 days ago

    Man, I want to like J and K but the constant vibe of "this language is so dense and complex, only a few genius programmers will ever understand it" is getting old.

    • tmcb 61 days ago

      You shouldn't feel intimidated by their density. Both J and K are extremely approachable languages, but you need to try them an open mind and act as if you didn't know a thing about good coding practices. With time you will realize that only a tiny fraction of those apply to the APL language family.

      • Domenic_S 61 days ago

        Maybe that's the marketing ploy -- make anyone who learns it feel like a genius for learning it.

        • rpz 61 days ago

          Have you had a look through the tutorial? Which parts of the tutorial made you feel as if you needed to be a genius to understand it?

          • munificent 61 days ago

            Well, the part where it says:

            > Arthur Whitney's k and its derivatives have served a small number of highly skilled programmers

            Doesn't exactly start off with an inclusive tone.

            • rpz 61 days ago

              As a k programmer myself I'd say to take that statement with a grain of salt and at least give the language a chance if you have some spare time. It's certainly true that the community is small and it's certainly true that there are plenty of really sharp programmers in the community but that doesn't mean that you need to be a genius to write k code.

              • arrayThrowaway 60 days ago

                It answers this question: if the language is so great and has been around for so long, why haven't we heard about it?

          • chrispsn 61 days ago

            As a companion to this tutorial, the community is building out a clickable version of the k7 reference card. It also covers the current state of Python-k integration:

            https://k7contrib.gitlab.io/docs/

            • lolc 61 days ago

              "Customer shall not, directly or indirectly, and shall not authorize any third party to: (i) decompile, disassemble, reverse engineer, or otherwise attempt to derive the source code of, reconstruct, or discover any hidden or underlying elements of the Software"

              Looks like I don't want to spend the effort learning it.

              • avmich 61 days ago

                Just in case you want to look at the sources of something similar, here is a good one: https://github.com/JohnEarnest/ok

                • tluyben2 61 days ago

                  I like oK because it allows nice toying around with graphics in the browser but while k is incredibly fast, oK is really slow. It is nice to play with and learn from but anything beyond, better check out Kona or another APL like like A+ or J.

                  • 4thaccount 61 days ago

                    I'm not aware of too many folks using A+ anymore as it is pretty ancient and hasn't been updated in a very long time.

                    Array languages I would consider for actual work are mostly:

                    Dyalog APL, J, and K if I could afford kdb+.

                    If I wanted to play with implementations I agree that Ok and Klong are pretty cool.

                • arrayThrowaway 60 days ago

                  Perhaps Nial would be of interest: https://github.com/danlm/QNial7

                • justinsaccount 61 days ago

                  This a typo?

                      x: 3 4 5 6 7 8 9 10
                      y: 100 200 300 400
                  
                      ?[x;3;y] / replace what's in position 3 by y
                    3 4 5 100 200 300 400 6 7 8 9 10
                  • tmcb 61 days ago

                    Looks like the comment is zero-indexed as well. I wouldn't consider that a typo.

                • nemo1618 61 days ago

                  "Shakti k also has primitives for blockchain operations."

                  That's... Interesting. I couldn't find any further mentions of "blockchain operations" in the reference. What do they mean, exactly? Since k is traditionally concerned with financial markets, I might guess that they're offering deeply-integrated ways to parse transactions, check the number of confirmations, query the current exchange rate, etc.?

                • manjana 61 days ago

                  What's the benefit using k vs. c, cpp or java for the same? Does it run or compile faster?

                  The article says you can do the same with cpp and some extra libraries, but I wouldn't immediately think cpp or java was easily beatable -- manjana wonders --

                  • avhon1 61 days ago

                    K is interpreted, not compiled. You can run your code the instant it's written.

                    As other's have said, K (the language and the interpreter) is highly optimized for processing tabular data. I've heard of it outperforming C in processing billions of rows of financial data. (Which, by my understanding, is K's primary market.)

                    Lastly, K (like APL, J, A+, Klong, Kona, etc.) is very terse. A phrase I've seen online is "one line of K is roughly equivalent to 100 lines of C". K programs, like APL & co., very often fit entirely into a screenful of text, but require close and complete reading to understand. There are lots of videos on youtube of people writing literate sudoku solvers or conway's game of life in a dozen lines or so, and terse solutions in a dozen or so characters.

                    People who like these programming languages tend to like their terseness -- they can view the entire program all at once (no scrolling or searching), and refactor or rewrite the program in a few seconds of minutes of typing.

                  • 4thaccount 61 days ago

                    If I understand you correctly, why use K over another language like Java? Java is a good enterprise language, but K is a good analysis language. It is very terse and powerful. Look up Kdb+.

                    • ksherlock 61 days ago

                      It depends on what you're doing. If you wanted to analyze some tabular data, k, sql, or even excel are probably more appropriate than c++ or java.

                      • ah- 61 days ago

                        If your problem fits it you can solve it with a fraction of code. It also runs extremely fast and apart from licencing it's trivial to deploy.

                      • jxy 60 days ago

                        Is shakti related to kx? What is going to happen with kdb+?

                        I also have a practical question. Does `brandelf -t Linux bin/k` violate the License agreement?

                        • arrayThrowaway 60 days ago

                          The founders of Kx (Arthur Whitney and Janet Lustgarten) sold their stakes in the company to First Derivatives plc and have now founded Shakti. Kdb+ is still sold by Kx. Shakti seems to be a successor system to kdb+.

                          As for you second question, how would brandelf change the binary (disclaimer: not a BSD user)?

                        • max_ 61 days ago

                          Does anyone understand if this is fully compatible with Kdb+? been learning q & it would be nice to add vanilla K7 to the list

                        • ngcc_hk 61 days ago

                          Whilst One can run j in iOS, j and k are different. May have to try k again.

                          • galaxyLogic 61 days ago

                            I wonder what are its improvements over APL?

                            • 4thaccount 61 days ago

                              K uses traditional ASCII characters and is usually bundled with kdb+ for speedy timeseries analysis.

                              I would use Dyalog APL or J over K in many cases. K is also really expensive (kdb+)...I'm not sure about Shakti (the K inventor formed a new company and left the first one).

                            • dman 61 days ago

                              Can someone compare this to Dyalog APL?

                              • 4thaccount 61 days ago

                                Dyalog uses non ASCII symbols which are really cool to me and make the primitives very easy to learn. Check out tryapl.org to get a feel for it. You can also download a trial version and there is a free book. They have decent library support and full .NET support too as well as easy parsing for CSV, JSON, XML...etc. They have Dyalog APL notebooks, database access, multiplatform support, parallel and tacit features...etc. If it wasn't $1k a year for a license (honestly pretty reasonable) I'd use it pretty often. It just feels like they love their product and support it from the annual coding competitions, monthly webinars...etc.

                                J uses ASCII symbols and has a small community of very intelligent users that are stats smart, software smart, math smart...etc. It has great bindings to Lapack, built in graphs (well Dyalog does too) and tutorials called labs. The community is much smaller though and it doesn't have any parallel primitives. J is free to use, but the Jd columnar database is commercial, but very reasonably priced.

                                Honestly, both are awesome, fun, powerful, and plain cool.

                                • dman 60 days ago

                                  Thanks - my next sabbatical is going to be Rust + APL

                                  • 4thaccount 60 days ago

                                    My usual advice is to also check out Aaron Hsu's talks on YouTube and his posts on HN (user arcfide I think). Really eye opening and alien stuff.

                                    Dyalog also sells a standard keyboard with the APL symbols printed on the keys. You might find that interesting.

                                • avmich 61 days ago

                                  Among other things, Dyalog now employs Roger Hui, one of principal creators of J, so Dyalog APL features are using full knowledge of J. Arthur Whitney's, the author of K, wrote the first implementation of J. So it's a small world...

                                • patrickg_zill 61 days ago

                                  Alternatively, you can look at the completely free www.Aplusdev.org, "A+" language that was also created by Whitney.

                                  There is also GNU APL which I have been playing with and has some good ideas also, including the ability to create scripts.

                                  • tmcb 61 days ago

                                    I would like to recommend Kona[1] as well. It is an open-source K implementation, with some small differences.

                                    [1]https://github.com/kevinlawler/kona

                                    • patrickg_zill 60 days ago

                                      Thanks for the reminder. I had seen it before, but I now see that it is active, with the last commit 8 days ago. I compiled it on my Linux box quickly and will be testing it out...