10 ms·
Klong: a Simple Array Language
- yellow_postit 7y agoFound this disclaimer sad and reminiscent of the endless and useless cookie prompts in the EU Note: This text used to be interactive, but is no longer, thanks to the General Data Protection Regulation (GDPR), which makes it virtually impossible for small, non-commercal sites to "process user data" (like your input) without contacting a lawyer first.
- saagarjha 7y agoWhere is this?
- kick 7y agohttps://t3x.org/klong/prime.html https://t3x.org/klong/prime.html For what it's worth, this URL is the first result on search engines.
- saagarjha 7y agoI think the author is overreacting, to be honest. What’s wrong with having client-side interactivity? There’s no possible way that would fall afoul of GDPR.
- pjc50 7y agoFailure of interpretation, really: I can't see how any of that could be considered personal data. Mind you, the attempt to be technology-independent rather than clearly mandate solutions has been a huge problem of the tracking law.
- nils-m-holm 7y ago> Failure of interpretation, really: I can't see how any of that could be considered personal data. Theoretically, you could enter some personal in a free-text field and it would be stored in the log files. I am not saying that people actually would do this, but they could. Now they cannot.
- tluyben2 7y agoThat would not get you into trouble with the gdpr, nor would most common sense things. A bit too paranoid imho.
- rhn_mk1 7y agoCan you back it up? Last time I asked an expert, any kind of personally identifiable data that someone would receive would create a liability.
- tluyben2 7y agoWell, can you? You asked 'an expert'; since the introduction of the gdpr, there was an explosion of 'experts' (even real lawyers) who know absolutely nothing and just read the EU docs line for line to spread FUD (and get clients). And the problem is, that, while the gdpr is EU wide, there are governing bodies per country which all behave different. So your expert in Italy might be completely off the mark about the Netherlands (so, disclaimer, my experts are from the Netherlands and talk about NL). But, in general, if you want to be 100% safe; just have a static site that collects nothing and logs nothing. No need to nag about it; it makes the internet a better place anyway imho. In my experience, if you are not frivolously collecting user data and make sure that the personal data you do collect is something you can explain in the line of your business (even if that data is very secret data, but that usually has extra laws/rules on top). And, finally, that you make sure that data is properly stored (encrypted on properly updated servers), you have no issues. In this case, IF the owner would get an email from the governing body of the country (I think Germany in his case), he would very easily be able to explain the reason for the input and the body can see that he is not asking nor frivolously collecting user identifiable data. If people choose to enter it, for some reason, en masse, in his site, then they would ask him to throw it away when it comes (so in his case, don't log it, but why was it being logged anyway?) in and that's it. No fines, no nothing.
- andykx 7y agoThis is excessively sensitive and represents an opinion-driven interpretation of the law. It seems like a lame attempt to make an "edgy" political statement.
- nils-m-holm 7y agoYour ad hominem aside, it is an attempt to be safe instead of sorry.
- tluyben2 7y agoWell, it is an attack on the gdpr with the huge text on the top (you could just remove that and still be safe instead of sorry?) while your site, in it's previous state, does not need lawyers etc as it doesn't fail the gdpr. Especially as you can simply (if you want to be extra careful) not log IPs or any user input into the logs. Then there is nothing to 'sue' if that would be your worry.
- nils-m-holm 7y agoYes, it is an attack on the GDPR and I consider it to be justified. You do not, and that is also a perfectly valid point of view. What is uncalled for, IMO, is the name calling in the posting further up the thread.
- tluyben2 7y agoName calling is uncalled for, I agree. But you seem to reside in Germany; not sure what you are worried about anyway (you would get (but will never get because your previous site already complied fine, as do most sites that are not personal data farms) multiple warnings and you can simply respond to those as a person (no lawyer needed or warranted), but yes, ofcourse, you are entitled to your opinion. Anyone is as far as i'm concerned.
- nils-m-holm 7y agoIn Germany in particular there exists a nasty habit of sending C&D letters to people for all kinds of minor rule violations. You can either sign these letters and pay an (often substantial) fee or get a lawyer. Or you can try to comply in advance, often to a ridiculous degree, which I do. So I may have such a strong opinion on the GDPR because I live in Germany.
- skrebbel 7y agoYou could make a statement like that about any law. Eg many EU countries also have laws against hate speech, but I saw nobody take down their hobby hacks because of those.
- yorwba 7y agoI guess the difference is that GDPR is new and had a bunch of of reporting about it recently. Few people stop to consult a lawyer before starting a side-project, probably because they wouldn't start a project that would violate any laws they're aware of. Of course there can always be laws you aren't aware of, but those only become scary once you realize you may have violated them.
- nils-m-holm 7y ago> You could make a statement like that about any law. If you can, you should. There are too many totally bogus laws!
- jusssi 7y agoMission accomplished, I say. No reason why this site should collect my personal information and eventually leak it to hackers.
- chvid 7y agoFrom https://t3x.org/klong/prime.html https://t3x.org/klong/prime.html: {&/x!:\2+!_x^1%2} This is function that checks if the value given as first parameter x is a prime by running through the numbers 2 to square root of x and applying the function x modulus y, then it looks at the minimum of the resulting list and see if it is 1 or 0. If it is one then x is a prime. Written in a language with c-style syntax it would be something like: x -> min((2 .. sqrt(x)).map(y -> x % y)) == 1 Why is Klong simple? Is it easier to implement, parse and interpretate? Or is the syntax somehow simpler once you get used to it? The former maybe; but it doesn't seem to be a part of the language's pitch. The latter is surely in the eyes of the beholder. I find it counter-intuitive to have so many single character operators & ! : _ with uncommon meaning and precedence rules.
- yiyus 7y agoThis is actually very standard syntax for array languages. Precedence rules may be uncommon, but extremely simple: right to left, that's all; and finding the meaning of each symbol just requires checking in a table. In your c-style example, you are actually using different precedence for each operation (is it (x -> ...) == 1 or x -> (... == 1)?), you have symbols like the dot which mean different things depending on context, a function of two arguments like % works totally different to another one (map), and so on. The only reason you find the c-style version simpler is because that's what you are used to. But while you have been able to interpret the Klong expression with no experience at all, ask yourself if someone familiar with array languages (and only array languages) would be able to understand the c-style version in a few minutes without having to read an extensive tutorial. I do not agree simplicity is in the eyes of the beholder. If a language can be totally specified by a few paragraphs and a table, it is simpler than a language that needs a long specification. However, this does not mean the simpler language is simpler to use. That, indeed, is a subjective matter.
- e12e 7y ago> The only reason you find the c-style version simpler is because that's what you are used to. Well, yes. But we're taught infix notation early (x+y), and function application quite early too (y=f(x) - and in combiation (also note short-hand eliding multiplication): f(x) = 2x + 1). I still find array languages to be too dense for me - but I do understand that they are simple from a certain point of view.
- tluyben2 7y agoBesides the discussion about the GDPR which is offtopic (and in my opinion it's not handy to be openly political if you want uptake of your product as it's not related to your product but it does taint it (as can be seen here); maybe in the 'about' or 'privacy' it would fit, but that is a matter of opinion), great work on Klong and I'll buy your book to read over xmas. I have been playing (quite a lot; to the extend my wife got me a t-shirt with some k on it for my birthday :) with Shakti(k7) for a few months now and been working through the Dyalog tutorials. Keep up (that part) of the good work! Edit: bought the book and started reading
- nils-m-holm 7y agoThanks! Enjoy the book!
- tluyben2 7y agoCan I mail you feedback if I have any?
- nils-m-holm 7y agoI would appreciate it!
- 127 7y agoAt this point Python/Numpy is really the array processing language I prefer to use. You can even use libraries like Cupy to switch the backend from BLAS/LAPACK to Nvidia CUDA libraries, which makes it lightning fast, often improving performance by 100x. And the requirement for arcane runes in Numpy is much less than APL or J. Also the various libraries and functionalities that plug into Numpy is countless and extremely powerful. There's also https://futhark-lang.org/ https://futhark-lang.org/ which might be an improvement in writing array processing kernels.
- korijn 7y ago> arcane runes What does that mean?
- conover 7y agoAPL (and I assume J) uses a large range of special graphic symbols as part of its syntax, which can be difficult to internalize for folks coming from other languages. It can be easily construed as mysterious or magical lettering (arcane rune). My favorite video to illustrate this is Conway's Game of Life written in APL: https://www.youtube.com/watch?v=a9xAKttWgP4 https://www.youtube.com/watch?v=a9xAKttWgP4
- aratakareigen 7y agoUnlike APL, J has an explicit goal of sticking only to ASCII symbols, but yeah, they're just as intimidating.
- beagle3 7y agoJ and K stick to Ascii (though recent K seems to accept a unicode "sqrt" sign, and "pi" character with the expected meaning). I do find some J choices questionable - e.g. '}' and '{' are used as individual operators, rather than a parenthetical pair - which confuses editors without a special J mode, and humans who switch between languages often - but if you use it enough, it's easy to get used to; Also, K keeps () {} and [] as parenthetical pairs, like they are in C/Java/Python etc
- 7y ago
- smabie 7y agoI’ve been using Q (built on K) for Advent of Code. It’s an amazing language that has made me reconsider what a language and programming should be. I come from a FP background and have always considered abstraction the heart of powerful and expressive programming. In Q, abstraction is wholly unnecessary. Libraries are unnecessary. I can fit the entire language in my head and all code in the language is built out of the fundamental building blocks of it. There’s no layer after layer of abstraction, just a small base of operators and functions. One might be tempted to compare it to other small languages, like Scheme. But for Scheme it’s intended that you build higher and higher levels of abstractions. With Q it’s both small and compact, and one rarely if ever feels the need to actually build a library of utility functions or anything really: it renders unnecessary the false prophet of code reuse. I got interested in Q because some of my friends at other financial institutions were using it for HFT and research on historical tick data. I found it surprising at the time I that their software stacks could be so simple, essentially just a single small executable that entirely fit in the CPU cache that managed both the runtime and their entire database. At the time I thought this was impossible, but now I realize how possible and eminently reasonable this was. Instead of Kafka and Redis and SQL Dbs and Kubernetes and god knows what else, you just have Q. No DevOps bullshit, no containers, no complex shit to manage. In the past 3 weeks I’ve had to rethink my philosophy of what software needs to be and have concluded that most of us are doing things very very wrong: we’ve created this unnecessary world of complexity that is tantamount to masturbation. Now let’s talk about the language itself. It may look complex, but it’s actually quite simple. The only real data types are lists, dictionaries, symbols, and numbers. And surprisingly, that’s enough. When programming in it I have no desire for classes or objects or trees or whatever, in fact, just using lists and dictionaries can usually solve the problem in a better way. Also, while Q is interpreted, it’s so goddamn fast. I’ve done some benchmarks against C and Q is about as fast, sometimes even faster. The optimizations the interpreter does are just insane. Not even joking, a single line of Q can accomplish somewhere between 100 to 1000 lines of what the equivalent C code would look like. Another plus is that editor tooling is unnecessary, I have no need for autocomplete or inline docs because I can literally remember the entire thing. And since Q is so compact, I can view an entire program on a single screen, no scrolling, no jumping between files. I’ve also noticed that I can remember the verbatim definition of my code. I can almost perfectly remember my exact code for each Advent of Code solution. Anyways, good luck on Klong, I’m going to check it out. I don’t like J and wish there was a good open source K/Q like language. I don’t actually like K because the overloads on function arity creates a lot of complexity (Q does away with this), so Klong might be right up my alley! For anyone who hasn’t tried an array based language, I highly recommend it. Q has expanded my mind more than I thought possible at this point in my career. My last really mind expanded experience in programming was when I picked up Scheme and Haskell in high school. And now after using Q, those languages aren’t that great anyways!
- e12e 7y agoIs there something like kdb for klong? How does it preform vis-a-vis the better known array languages?
- kick 7y agoIf you need performance, klong probably isn't for you.
- nprescott 7y agoI read the Klong book [0] and for me it "clicked" in a way that J/K never had. The author did a really nice job paring down the language and cleaning up some of the ambiguities in a way that made it approachable. Also, after reading it I've found APL and J more approachable, which is encouraging. If you'll forgive the style, I took a swing at implementing k-means clustering in Klong a few months ago [1]. While I did find a few slow-downs with a modestly sized data set (Fisher's iris data), I think Klong is built on a Forth-like VM using the core of a scheme implementation (all of which the author wrote!). It wasn't slow enough to really bother me, as I was more interested in learning about array languages and algorithms. I'm a fan of Klong -- it's just fun. [0]: http://www.t3x.org/klong/book.html http://www.t3x.org/klong/book.html [1]: https://idle.nprescott.com/2019/k-means-clustering-in-klong.html https://idle.nprescott.com/2019/k-means-clustering-in-klong....
- renox 7y agoIs the right to left order common to all array language? It sure doesn't help onboarding..
- beagle3 7y agoIt is for APL and derived languages (APL, J, K, A, A+, Klong) And .. well, if you want C or Java, use C or Java. Quickly, which is higher precedence, "&" or ">" ? You may have memorized them, but many people get it wrong often enough. APL has a very simple and consistent rule: There is no precedence in an expression except paranthese, and you go right to left. And it may seem to not help with onboarding if you skim, but if you take the time it clicks quickly for most people, especially if you consider that "right to left" is actually "left of right", e.g. (note, a|b is the maximum of a and b, not the bitwise or) 1 + 2 * 3 + 4 | 5 is read and understood as: (1 + ...) applied to ((2 * ...) applied to ((3 + ...) applied to (4 | 5))) read another way (note: using python syntax) def f(x): return 1+x def g(x): return 2*x def h(x): return 3+x It is equivalent to f(g(h(max(4,5))) But one argument K/APL functions need no parentheses, so you would have written it f g h 4|5 But with "f", "g" and "h" inlined you get the original expression back. It is different - but it is simple and consistent without any arbitrary precedence and associativity rules. Also, it's not a new idea; APL predates every other programming language still in use except, perhaps, Fortran, Lisp and COBOL -- of which only Fortran uses operator precedence and associativity in the modern C/Algol sense. Lisp is also consistent (though with a different route than APL took). And I'm afraid to describe COBOL in fear that cthulu will rise.