4 ms·
APL and Array Programming
- chrisaycock 4y agoFor anyone interested in array programming, the person who made k eventually created a query language called q: https://code.kx.com/q/ref/ https://code.kx.com/q/ref/ Now days we refer to tables-within-a-language as "dataframes". These are widely available in R, pandas, Spark, etc. The q language inspired me to write my own language a few years back that added static typing to dataframes: https://www.empirical-soft.com https://www.empirical-soft.com
- titanomachy 4y agoYour work might predate this, but spark/scala now has good support for typed dataframes (they’re called DataSets).
- chrisaycock 4y agoDoes Spark's Dataset have something like the "inferSchema" option when reading a CSV file? Everything I've read in Spark's documentation makes me think that Datasets require an explicit type provided by the user. Empirical can infer a CSV's schema at compile time. If the file path can be determined at compile time, then the Empirical compiler will sample the CSV file and determine an appropriate type before the user's code is ever run. No need for an explicit type from the user, and yet we still have static typing.
- kthielen 4y agoVery cool, this approach will inevitably catch on, I think. I built a similar typed PL and compiler for Morgan Stanley back in 2013: https://github.com/morganstanley/hobbes https://github.com/morganstanley/hobbes
- chrisaycock 4y agoI read about Hobbes years ago. The embeddability certainly caught my attention. I wrote Empirical specifically for the use case of wanting to read a CSV file while inferring the type at compile time. Basically, a ton of compile-time function evaluation mixed with type providers.
- kthielen 4y agoYeah, I had this type constraint system for doing that kind of thing, so I can load a file at compile time to get the type structure and then compile/evaluate to process data in the file or files. Same thing for network connections between communicating processes (type constraints at compile-time decide a protocol, machine code at run-time assumes that protocol).
- bwanab 4y agoI recently did a project using Dyalog APL. I really wanted to love it. On the pro side, the community was great and I loved the language, but only to a point. There are way too many instances of utter astonishment at behaviors that seemed to be just how the language works. I had a lot of trouble finding good, mature libraries for things I’ve taken for granted in other languages. I’ve found that Julia provides 98% of the Array Programming value in a modern “batteries included” package.
- xelxebar 4y agoThis reminds me of what a BASIC programmer friend of mine said about C when he first tried it. After many (mostly senseless) debates, I eventually convinced him to try C after showing some bodged-together flashy graphics demo. He got me to teach him basic C syntax and then took off on his own, writing a game. After a few weeks of hacking, he presented me with a decent Asteroids clone, "I don't see the point of C." The funny thing is, when I looked at his main.c file, the entire code was written inside the main function, with copious use of gotos. He had essentially tried to speak BASIC using C. APL isn't an Algol-like, and you're probably going to have a bad time writing APL trying to use the cognitive tools and intuitions you have as a programmer of Algol-like or even functional languages. This includes the tendency to reach for libraries, when you can, for example, implement an entire U-Net CNN in 30 lines of APL and be competitive with PyTorch performance. In my (budding) experience, to "get" APL you have to laser-focus on writing beautiful, concise code from the onset. It feels painful as a student to spend weeks writing and re-writing just to produce 2 lines of code, but in the end those 2 lines will be doing the work of 20 lines of Julia, or 200 lines of C, and feel like a pure, direct mathematical expression of the algorithm you intend.
- throwaway17_17 4y agoI think this is the first comment I’ve seen that describes my general approach to learning and designing programming languages. The only other topics such statements are likely to be made are concerning Lisp (and it `mind expanding` properties). I really wish more people would focus on using/making languages that cater to a strict niche but compile to a sensible and readable common root language/IR.
- jph00 4y agoWell this is unexpected - didn't think my little study group would appear on HN! :O Well anyhoo, all are welcome to join; details in the linked thread (including playlist of last week's videos so you can catch up). As it happens, my interview on The Array Cast was just published today: https://www.arraycast.com/episodes/episode31-jeremy-howard https://www.arraycast.com/episodes/episode31-jeremy-howard In it I discuss my thoughts on array programming, including in PyTorch, numpy, Tensorflow, and other libraries and languages. If you haven't seen it before, The Array Cast is a really great podcast including interviews with some of the most interesting folks in the array programming world. My fave episode so far is the one with Aaron Hsu (@arcfide) of co-dfns fame: https://www.arraycast.com/episodes/episode19-aaron-hsu https://www.arraycast.com/episodes/episode19-aaron-hsu My personal interest in APL is for teaching (my daughter and her friend who I tutor really like learning math via APL, and we've successfully covered territory that previously I'd had no luck making progress on using more traditional methods) and for studying notation (which is what APL was originally designed for).
- queuebert 4y agoI also have found that kids pick up APL very easily. Schools are probably missing a huge opportunity not using it to teach math and computer science.
- zelphirkalt 4y agoI also think schools are missing out massively, but not only by not teaching them at every chance, but because they do not combine these things. If I had been taught math and computer programming combined, implementing things one learns, damn, I would have been waaay more interested in math in later school years and that would probably have lead to me being much better at math later on at university too. It just gives you something practical to do and a feeling of success, when you make the computer do it for you, while at the same time you learn about computer programming. I hope some day we see those 2 things married into one superb class at schools.
- z3phyr 4y agoAPL seems like a great language for computer graphics! Has anyone tried their hands at the same?
- memorable 4y agoI don't know if APL supports graphics, but ngn/k, an implementation of K, a language in the APL family, has JS support in its official online playground [0], which can be used for displaying graphics. [0]: https://ngn.codeberg.page/k/# https://ngn.codeberg.page/k/#
- jodrellblank 4y agoSomeone made a 3D boating simulation using Finnish island geodata; called StormWinds and using Dyalog APL connecting to DirectX - https://www.dyalog.com/case-studies/simulation.htm https://www.dyalog.com/case-studies/simulation.htm The author also has this video: https://dyalog.tv/APLSeeds21/?v=iC9floP7POU https://dyalog.tv/APLSeeds21/?v=iC9floP7POU "Tomas takes you through the API of a 3D-engine and shows you how to connect to it from APL, enabling you to create a simple scene with graphics objects moving in real-time. He also explores some of the more advanced rendering techniques." (I haven't watched it)
- queuebert 4y agoThis well-known J dude has done some: https://www.youtube.com/watch?v=CzK2SazvCxM https://www.youtube.com/watch?v=CzK2SazvCxM And J is almost isomorphic to APL.
- razetime 4y agoJ has much easier access to graphics with bindings to a window driver and OpenGL . APL also has support for GUI apps (Windows only) using .NET, but graphics takes some additional effort: https://www.youtube.com/watch?v=iC9floP7POU https://www.youtube.com/watch?v=iC9floP7POU
- RodgerTheGreat 4y agohttps://github.com/JohnEarnest/ok/tree/gh-pages/ike https://github.com/JohnEarnest/ok/tree/gh-pages/ike https://beyondloom.com/tools/specialk.html https://beyondloom.com/tools/specialk.html
- memorable 4y agoThis makes me remember the time when I was still codegolfing in K. It was a breeze from other languages that I have learned and still is.
- rramadass 4y agoLearning Mathematics through J (derivative of APL) : https://code.jsoftware.com/wiki/Books https://code.jsoftware.com/wiki/Books
- mlajtos 4y agoIt is fantastic to see Jeremy from fast.ai tying modern tensor libraries to its origins in APL. If you are interested in this deep interconnection and what future might hold, please check out New Kind of Paper series. [0] [0]: https://mlajtos.mu/posts/new-kind-of-paper https://mlajtos.mu/posts/new-kind-of-paper
- olodus 4y agoI did a bit of the last AoC in BQN. I really liked the language but got stuck a bit when it came to the more tricky loops where you had to do some reassignment if I remember correctly... I should go back and finish the rest of it. Saw there were a few others that had solutions I could take inspiration and learn from.
- raspyberr 4y agoRuss Cox did a bunch of the days of Advent of Code 2021 in Ivy, an APL-like language by Rob Pike. Really interesting stuff. https://piped.kavin.rocks/watch?v=ek1yjc9sSag https://piped.kavin.rocks/watch?v=ek1yjc9sSag