« first day (1408 days earlier)      last day (1236 days later) » 

5:55 AM
:( the more and more I use TryAPL the more and more I dislike it. I just accidentally hit Ctrl+R and instead of `+R (for Rho) and lost a 45 minute session
because the new TryApl doesn't cache your most recent session
 
6:12 AM
@code_report In the FILE tab, there's an option called "Save workspace using local storage". I think enabling it will prevent data loss (at least it seems to work for me)
 
6:25 AM
@Bubbler TY!
that should probably be on by default
 
6:43 AM
@code_report That would be illegal due to recent law changes.
 
ngn
6:56 AM
@code_report to be fair, it's TryAPL.org, not DoALotOfImportantWorkWithAPL.org :)
 
yesterday, by code_report
@RikedyP Alt + up / down works :) thanks for adding that. I have Dyalog 17 on 18 on my Windows laptop, but when I tried downloading Dyalog for linux my keyboard setting broke for half a day so I uninstalled it. I personally think Dyalog should be heavily investing in tryapl.org. In C++ land, https://www.godbolt.org/ has become the primary place I write C++ code examples and prototype. Software development (and everything) is headed to the browser/cloud, not to desktops.
 
 
2 hours later…
8:45 AM
I now wait for @ngn to cut that in half or find the non-∇ version I couldn't :)
 
ngn
@xpqz today i'm prepared with a solution of my own :)
⎕io←0⋄a←'#'=↑⊃⎕nget'3'1
f←{+/a[↓⍉↑(⍴a)|⍵×⊂⍳⌈(≢a)÷⊃⍵]}
(f 1 3)(×/f¨(1 1)(1 3)(1 5)(1 7)(2 1))
but i'll study yours too
 
ngn
9:09 AM
@xpqz i think apl badly needs a ⍣ that preserves intermediate results
if it had such an operator, you wouldn't have to use accumulating recursion, and i think it's a common enough pattern
 
@ngn With a known range, ⍣(⍳n) would work.
@xpqz What does your assert look like?
 
ngn
@xpqz 0⊃⍴d ←→ ≢d (when d isn't scalar)
 
@ngn Wait, are we golfing? I can certainly shorten yours.
 
ngn
@Adám not really golfing, but we could do that if you want :)
 
9:24 AM
@ngn (1 1)(1 3)(1 5)(1 7)(2 1)2 1,∘⊂⍨1,¨1+2×⍳4
@ngn (≢a)÷⊃⍵⊃⍵÷⍨≢a
@ngn (f 1 3)(×/f¨(1 1)(1 3)(1 5)(1 7)(2 1))×/⍤f¨1 1⊂2 1,∘⊂⍨1,¨3,1+2×⍳4 (I think.)
(Did I mention that I dislike parens?)
 
ngn
@Adám 1+1 2∘ר5⍴⍳4 4
1+2×@1¨5⍴⍳4 4
@Adám f can be inlined
64 bytes so far: (1∘⊃,×/){+/a[↓⍉↑(⍴a)|⍵×⊂⍳⌈⊃⍵÷⍨≢a←'#'=↑⊃⎕nget'3'1]}¨1+2×@1¨5⍴⍳4 4
to be continued after lunch..
 
9:48 AM
@Adám assert←{⍺←'assertion failure' ⋄ 0∊⍵:⍺ ⎕signal 8 ⋄ shy←0}
Stolen from someone here, as I recall.
 
Ah, that's Roger's def. We're considering adding that as ⎕ASSERT.
 
10:08 AM
That would be nice to have. Or as part of the as yet hypothetical standard library.
Maybe the APL heroes of yore didn't need an assert, as they always got things right the first time?
 
10:27 AM
ngn's is so short wow
 
11:04 AM
What's better, ⊃⌽⍴⍵ or ≢⍉⍵
 
They are not exactly the same.
 
For situations where they are exactly the same, what's preferred
 
@rak1507 golfing? ≢⍉⍵. performance? ⊃⌽⍴⍵
 
@ngn I took your approach and tried it in Python, too: gist.github.com/xpqz/2a4ecacbd3801ec02f35a59d6454ed06
 
list(map(lambda v: makes me cry
 
11:19 AM
You know the rules. No loops :)
 
use a list comprehension
 
Where's the fun in that?
 
It's more pythonic
 
@rak1507 Sure. And actually shorter, too.
 
ngn
@rak1507 nice. looks more arrayful than mine - 2xN matrix instead of pair of vectors. i think you don't need the ⊢ after ×⍤0 1
 
11:23 AM
Maybe
 
ngn
@xpqz in python you can use bools as ints: sum(int(d[y][x] == '#') .. ) <-> sum(d[y][x] == '#' ..)
@rak1507 in trav you could have used data directly, without passing it as ⍵. were you deliberately trying to avoid using closures, e.g. for some philosophical or aesthetic reason?
 
I was using the function with different right arguments for debugging
And also, I like things being not hardcoded in general
 
ngn
11:40 AM
i was asking because k forces you to program like that - there's no support for closures (you can use only locals&globals), but i don't enjoy this style very much and i'm trying to better understand the pros and cons
 
Oh right, I guess for me most of the time I'm using some data in a function I would want it to be an argument rather than something hard coded
In other languages I tend to overuse default values
 
ngn
@ngn 62 bytes: (1∘⊃,×/){+/a[(⊂⍴a)|⍵∘ר⍳⌈⊃⍵÷⍨⍴a←'#'=↑⊃⎕nget'3'1]}¨0 8∘⊤¨9+2×⍳5
 
11:57 AM
Why use tradfns not dfns?
 
no good reason really
 
 
2 hours later…
2:01 PM
I spotted this trick from Jay Foad for yesterday:
b t l s←↓⍉⎕CSV('\W+'⎕R','⊃⎕NGET'data/2020/day02.txt' 1)''4
Smart if the input contains numbers and strings.
 
 
1 hour later…
3:27 PM
Damn, my reshaping idea doesn't quite work :(
 
ngn
4:11 PM
@ngn 59 bytes: (1∘⊃,×/){{×≢⍵:⊃⍵+∇x⌽y↓⍵⋄0}'#'=↑⊃⎕nget'3'1⊣y x←0 8⊤9+2×⍵}¨⍳5 loosely based on @xpqz's recursive approach
 
4:27 PM
@ngn That's about 4 bits per hour…
 
ngn
@Adám sounds like one of those corporate productivity metrics :)
 
@ngn (1∘⊃,×/){×≢w←'#'=↑⊃⎕nget'3'1⊣y x←0 8⊤9+2×⍵:⊃w+∇w⌽y↓w⋄0}¨⍳5 I think.
 
ngn
@Adám i'm getting a rank error at ⌽
 
@ngn Oh, there's . Never mind.
(I'm not actually running anything, just reasoning…)
 
5:21 PM
How do you respond to people saying APL is unreadable, considering the fact that even if you don't know a mainstream programming language, if you know anything similar it is probably readable, whereas APL isn't?
 
@rak1507 TMN
 
people know that though
 
@rak1507 Yeah JS & C# are inter-intelligable in some sense like Danish and Swedish to a small extent
 
I'd say most mainstream languages are
 
@rak1507 There's no getting around having to learn to read it. Unfortunately many people seem to value being able to guess a few of the most basic primitives over the ability to be more expressive later on
 
5:24 PM
@rak1507 because they learned it just as they learned English needed for mainsteam langs. Nothing's stopping one learning APL the same way, and APL has the advantage that some effort was put in place to make it sensible
 
Right makes sense thank you both
 
@rak1507 It might be as simple as the inertia - they've already put the effort in once to learn the traditional-language thing
@dzaima And maybe they don't take seriously even the idea that having an executable mathematical notation is worthwhile - however there are many senses in which programming languages are more like natural languages than they are like mathematics
 
ngn
@rak1507 i usually respond by asking "is chinese readable?" (unless they are actually chinese)
 
'programming languages are more like natural languages than they are like mathematics' insert SICP quote here
 
@ngn a response I'd expect is "does that imply that chinese is better than english?"
 
5:27 PM
@rak1507 In my view, the intial recoil at APL is quite low on the reasons people don't adopt - I think it's more like the inability to do anything exciting without effort at first (unlike, for example, in python where you can recognise digits using a neural net in an hour long tutorial - although you'll just be mindlessly copying and pasting API calls)
@dzaima They can fit more information in a tweet than we can
 
@dzaima doesn't imply that english is better than chinese either, trying is the only way to know
 
Yeah I think so, often when I've mentioned APL people have said something along the lines of 'that's cool but it is totally useless to me', which is fair enough
 
@rak1507 In mainstream languages that use English words, there is, to the uninitiated (and even to the programmer), no visual difference between built-in names and programmer-defined names. If someone doesn't understand any of the APL symbols, they'll only be able to read the programmer's identifiers, and therefore stand a much better chance at gathering what the program is about.
 
@dzaima I also find (even though I'm not very good or fluent) parsing kanji gives me the "what is this thing" in my brain a lot quicker than parsing words
 
@Razetime there is an infinite number of things that could possibly be better than other things you use, so that doesn't help APLs case particularly
 
5:30 PM
@RikedyP Uh, now you can do the same in APL, but after that hour, you'll actually understand what you did!
 
@Adám +←1
 
I think going through RGS' tutorial from scratch would take more than an hour
 
@dzaima we are talking about APL vs a standard language here, however, so there is a finite number of things
 
ngn
@dzaima the "chinese" question usually gets the point across: their complaint is about familiarity, not readability. there's no implication of one language being "better" than the other.
 
@rak1507 I was gonna say this
 
5:31 PM
If anything it's more extreme, it probably takes about 20 minutes for someone to do it in python, the longest part is probably pip installing all the dependencies.
 
@rak1507 APL Wiki.
 
@ngn I mean, yeah, it refutes the point that it being unreadable is necessarily bad, but not much more. There's still a clear preference one would make between needing to learn a bunch of funny squiggles vs not needing to
 
ngn
@Adám where did you get that definition of "semantic densitiy" from? looks wrong
for me "semantic density" is the amount of meaning packed per character
 
@ngn Stephen Taylor had this article on the old aplwiki old.aplwiki.com/SemanticDensity
@ngn I think you can extrapolate that to "per phrase" as well - since sometimes the way characters combine will help or hinder that
@ngn I think I agree with you, doesn't go with a "density"
 
ngn
@RikedyP yes
@ngn at least, i think aaron hsu, who was trying to popularize the concept, was using it in this (or similar) sense
 
5:40 PM
I guess readability is subjective, I certainly can't understand any of Arthur Whitney's code
 
ngn
@rak1507 you can if you try
 
Let me rephrase that, I understand the code a lot less than I would have if he used a few more characters per variable name
 
ngn
i remember a conversation with aaron which was exactly about this - the optimal length of identifiers
 
I feel the same way about co-dfns
I was watching one of his talks the other day and he was comparing the length of a description of some APL with the actual APL, and although I get the point he was making, at least I understand what the description means...
 
@ngn everyone can understand pretty much any code if given enough time. Readability is more like the amount of code (or maybe amount of stuff done by the code) you can understand per time unit
 
5:45 PM
^
 
ngn
@ngn he was arguing that it should match the semantic density of the language (long names in java, short names in apl, really short names in macro-heavy arthurese c). i was arguing that shorter is always better, even if the language is forcing verbose syntax on you. somebody else was arguing that longer is always better..
@dzaima that is subjective. it depends on the prior experience of the person reading the code.
 
@dzaima that also has some variations - certain coding styles would give a higher such readability score for understanding a single function, while sacrificing the score for understanding the entire codebase (and others vice versa)
@ngn I mean, of course it does. I'm not saying readability isn't subjective
@ngn and that also raises another readability factor score - how suited it is for someone with no prior experience. Might matter in some cases, might not in others
 
6:03 PM
@rak1507 More or less what Richard said but there's often no need to respond. I someone just dismisses APL with "that's unreadable", they're likely trying to protect themselves from feeling like not knowing it makes them a bad programmer or FOMO. Frustrating that it comes out looking like an attack but that's a reasonable thing to do, and there's no point in arguing the point: they don't want to debate.
 
Right makes sense, I guess from my point of view it seems like a shame APL is initially so inaccessible to people as I think learning APL has made me a better programmer in other languages, and I think that can apply to others as well
 
If someone says they want to learn APL but are worried about the glyphs, you might point out that there aren't very many of them and most are suggestive of their functionality in some way. Or ask for more clarification to see if they have other misconceptions about APL.
@rak1507 A lot of the problem—which was worse historically but is still bad now—is that it's confusing and difficult to find the resources. You need at minimum the ability to execute APL and a decent introductory text and each of these are hard to find. I think the main effect of APL being weird is that people have less patience in initial steps. If they were making obvious progress from the start then it wouldn't matter.
 
Yeah I agree, and one benefit APL has is that it isn't as confusing in places as other languages, but if you're trying to show that to people who already have overcome those problems, it's not such a benefit
 
ngn
6:21 PM
i think the lack of a decent libre impl is a much more serious obstacle for adoption than the initial perception of being unreadable, confusing, etc
 
I would agree if it wasn't so straightforward to download an unlicensed copy of dyalog
 
(as of ~1.5 years ago)
 
ngn
@rak1507 you can download it but you can't use it (legally) for anything you like. commercial use is explicitly forbidden.
 
if people were trying to learn a language to make money, they wouldn't be learning APL anyway
 
ngn
true
 
6:28 PM
@ngn I think there are cultural and business concerns which probably have more influence - one is if your team of APLers is smaller for the same project, the loss of 1 member is higher percentage loss of (maybe perceived) productivity - another is that since it doesn't look like the other langs you know you have to train people (and not just grab fresh graduates for cheap who've already learned the mainstream langs)
 
ngn
@RikedyP yeah, a bit like chicken&egg
no programmers => no jobs because there's no-one to hire => no programmers because they don't wanna learn it because no jobs
 
When I came to APL, what attracted me was the fact that the first time I saw it, I really could not relate it to anything else I knew. A mouthwatering challenge. I never saw that as a problem with APL, only my lack of knowledge.
 
I wish everyone was like that
 
I think many have gotten used to that if they know one c-like language, they can easily pick up -- or at least passably read -- another without much of an effort. So when someone says "APL isn't readable" I hear "APL looks nothing like javascript/go/python".
And next time a recruiter suggests I use whatever language I like for the interview test, I'm 100% submitting golfed-to-death APL :)
 
6:46 PM
Haha, talking of using obscure things for interviews, you might enjoy this aphyr.com/posts/342-typing-the-technical-interview
 
Yes, a classic!
 
ngn
7:00 PM
 
I was prepared for it to be about 20 characters, but it is commented and readable
 
ngn
@rak1507 contributed by jay foad
 
Oh haha, that makes sense
 
ngn
if it was me.. you know - one line, no comments :D
 
Yeah, I was thinking something along those lines
 
7:52 PM
Pretty amazed at how quickly the Day 1 AoC solutions run in APL vs Raku. Part 1 is fine in Raku but for Part 2 it takes 30 seconds for Raku to assemble the three-wise cross of the input and then find the triple that sums to 2020 :O
APL returns the answer instantaneously
 
Is the time complexity the same?
 
8:04 PM
Seeing a lot more APL/J solutions in the Advent of Code solution threads this year, seems the word is getting out :)
 
@rak1507 Good question :) ... Looking at just the algorithms, they might be more or less equivalent but I have to admit to not having a great grasp of time complexity in APL. The largest chunk (by far) of the Raku time is spent in constructing the array of triples.
 
@voidhawk neat
@ab5tract yeah I would guess that makes sense, does your APL solution use two outer products then?
 
@rak1507 Indeed it does. Stunningly beautiful.
 
I prefer only using one
 
@rak1507 I'm sure you've shared it before but would you mind reposting a link to your solution?
 
8:09 PM
(×/⊢∩⍥,2020-∘.+⍨)
 
@rak1507 Thanks! I'm going to have to spend a bit of time to fully understand this approach. But I'm also very thankful to find that @data.combinations($times) is much (15x) faster than using [X] @data xx $times in Raku :)
 
I know 0 raku so I wouldn't know!
 
@rak1507 Never too late to start ;)
 
Might give it a go at some point, from small snippets I've seen it looks very powerful
 
I hadn't bothered timing the day 1 solution, but I get 8 microseconds (?!) from the naive O(n^3) solution p←⍎¨⊃⎕nget'in\1.txt'1 ⋄ f←{×/p[⊃⍸2020=p∘.+⍣⍵⊢p]} ⋄ cmpx 'f¨⍳2' which is pretty crazy
I guess vectorized math is fast, who knew?
 
8:22 PM
damn
8 microseconds?! that's insane
what do you get for my solution?
 
@rak1507 You know how to easily time APL?
 
@rak1507 I have been following it since the original RFC process back in 2000 but only really started learning/using it when I was conducting interviews at $work and started converting answers. It didn't take long for me to get hooked on the expressivity!
 
@voidhawk the input is 200 items long, and 200*3 is only 8000000
 
@rak1507 Uhhh... 270us?
 
@voidhawk i get 3ms for that
 
8:28 PM
Hrmmm...
```
p←⍎¨⊃⎕nget'in\1.txt'1
⍴p
200
f←{×/p[⊃⍸2020=p∘.+⍣⍵⊢p]}
cmpx 'f¨⍳2'
6.7E¯6
```
Ah, formatting. Anyway, am I doing the measurement wrong somehow?
 
@voidhawk no, you're doing the same thing i did. But I got 3.3E¯3 ¯\_(ツ)_/¯
 
ngn
@voidhawk what's your ⎕io?
 
ah yep ^
 
@ngn ....right
Okay, 2.4ms. All's right with the world
 
@voidhawk Ctrl+k instead of ```
 
8:52 PM
@Adám yes, I was just wondering what they got on the same hardware
 

« first day (1408 days earlier)      last day (1236 days later) »