« first day (1510 days earlier)      last day (1145 days later) » 

12:00 AM
:C
what should I try?
 
ngn
when you press f1, it show in the status line help for the character under cursor, instantly, as you move
 
@ngn Works for me.
 
ngn
@nathanrogers does vim detect the filetype correctly? try :set ft
 
filetype=bqn
 
ngn
@nathanrogers ok. is the mapping there? :map <f1>
 
12:04 AM
no mapping found
is this a recent change?
 
ngn
it should say something like
n  <F1>        *@:cal bqn#t()<CR>
 
No mapping found it says
I can try a pull?
what branch is it in?
 
@nathanrogers Not very recent. Are you sure you copied the ftplugin file? Is searching case insensitive?
If you go to a character and hit %, does it jump to the matching one?
 
@Marshall should they be in .vim or .vim/bundle
 
@nathanrogers I have it in ~/.vim/ftplugin/bqn.vim .
 
12:08 AM
right
but you linked them?
not a direct cp?
 
@nathanrogers Yes, all symlinks.
 
ngn
i have it in :set rtp+=..
 
@Marshall no % doens't work
I rm -rf all the cp'd files I had there, and did a link
so I can just keep them up to date with a pull
I can try just commenting out chunks of my rc file
or just load the bqn stuff last?
I also tried @ngn your rtp version
 
ngn
maybe try inserting an echom 'something' in editors/vim/ftplugin/bqn.vim, to make sure it loads?
 
@nathanrogers It shouldn't have to be explicitly loaded if filetype detection is working.
 
ngn
12:12 AM
messages can be viewed with :mes
 
Just to check, what's $ find .vim -name "bqn*" ?
 
yeah inputs work
@Marshall no results
you got the * in the right place?
but they're links
so its not going to find anything
 
@nathanrogers Yes; for me it returns five results.
@nathanrogers Symlinks are treated as files by most things.
 
but I'm on wsl
i've run into symlink issues before
 
@nathanrogers Maybe vim's having issues picking it up then. Try the debugging thing ngn says I guess, and if that doesn't work see if actually copying them helps.
 
12:15 AM
@ngn do you mean append some nonsense so it crashes?
 
ngn
@nathanrogers it shouldn't do that
ok, here's another way - :scriptnames
 
~/BQN/editors/vim/keymap/bqn.vim
is in there
syntax/bqn.vim
that's all
 
ngn
no ftplugin/bqn.vim? strange
 
@nathanrogers Wait, did you try filetype plugin on in .vimrc?
 
I get an error
invalid argument
is it case sensitive @ngn ?
oh hey
 
ngn
12:20 AM
@nathanrogers filenames are case-sensitive on the filesystems linux usually uses
 
filetype plugin indent on
fixed it
now I get names of glyphs
that's slick
 
ngn
great
 
nice, any hope for a popup keyboard map? :P
 
So just filetype plugin on causes an error? That's really weird.
 
oh I just tried filetype plugin
sorry, I'm in a narrow browser, and the text got overlapped
thanks for the help @ngn @Marshall
 
12:24 AM
@nathanrogers I mean, you can just open editors/bqn in another window so it doesn't seem worth fighting vimscript to make a popup.
If you make one I'd accept a PR, of course.
 
ngn
or type :lm
 
I have like... 4 windows open. I got the tutorial, the window reexecuting the script on save, and the one I'm editing and this chat window :O
 
ngn
and the host operating system :)
 
@ngn ⍥ can that include function names! ⍥
 
ngn
@nathanrogers question for @Marshall
 
12:26 AM
@Marshall can :lm include function names and example ⍥ or is it just the keymapping :C
 
ngn
or @dzaima
 
@nathanrogers I didn't even know it existed...
 
haha
•←2+⁼3 who needs - anyway
 
ngn
@nathanrogers ah, i thought you were asking something about what that symbol does in bqn..
 
2+⁼+⁼˜3

2 "minus" 0
 
12:29 AM
@ngn It gives you an unknown character error. BQN doesn't do spots everywhere.
 
ngn
:lm is "language map". it shows only the key -> char mappings. i'll have a look at vim's :help but i think it can't display comments next to them.
 
@nathanrogers Check this one out. How many semitones would you have to transpose 440Hz to get to the given frequency? Oh, Trans⟜440⁼.
Which reminds me that I need to get that working in the online REPL. It's pretty good about inverses but dzaima is better.
 
I don't know how to link to the section
but the graph showing function composion
how do I read that?
it looks like the functions get bound, then 3 applies to 4?
i don't follow
 
@nathanrogers The result from the middle part gets applied to 3 and 4. It should probably have a dot or arrow or something where the lines cross.
 
I'm still not reading it
I get ×⍨ is square, but not how you would define it inline without composition
I think showing how it would look literally without composition and compose it piece by piece explicitly would be helpful for... people like me
or just me
 
12:40 AM
@nathanrogers that's not the purpose of the graph. It just shows how it's parsed
 
I see now, its the square applied to 3 + 4
 
@nathanrogers yep. is {𝔽 𝕨 𝔾 𝕩} aka {⍺⍺ ⍺ ⍵⍵ ⍵} aka
 
@nathanrogers So it would help to expand it out to ט 3 + 4 and then (3+4) × (3+4)?
 
that makes it look like its doing the computation twice
 
Yeah, I can see how that code block just kind of comes out of nowhere. I get a lot less patient near the end of a tutorial for obvious reasons.
 
12:45 AM
3 ט∘+ 4
ט (3+4)
ט7
7×7
49
 
@nathanrogers So probably ט 3 + 4 to ט 7 to 7 × 7 is better.
 
I think the one I showed is how it makes the most sense to me, or the inverse
there we go, the last edit
•←3 ט∘  + 4
•←  ט 3 + 4
•←  ט     7
•←7 ×      7
•←        49
that's how I worked it out
and I can see its all 49 :P
 
same as 3 ×⍨⍤+ 4 in apl
 
same as •←26+13-⁼˜2√⁼∘+4 in bacon
or •←'1'-@
"forty-nine" who needs numbers anyway
 
Okay, new paragraph should show up here eventually. Hard refresh. Lots of inline code always looks horrible but it's better than no explanation I'm pretty sure.
And section links are fragments with the header changed to all lowercase, spaces changed to dashes, and special characters (not including - and digits) removed. So ...#2-modifiers in this case. Github has a link button you can click on their markdown display but I don't.
 
1:56 AM
@Marshall thanks :)
 
2:12 AM
SyntaxError: ←: cannot assign with different types
•←+´ 5 2 1
 ¯
@Marshall @dzaima what does this mean?
 
@nathanrogers I think that's a wrong error message. The problem is that you're missing between list elements.
 
hah, right
@Marshall NERD!
oh you translate it later :P haha
 
@nathanrogers Well, was it as anticlimactic as you'd hoped?
 
I already knew the answer
I'm a robot after all
I'm fluent in binary and super binary
So yes I guess @Marshall
@Marshall Quick review, since I'm going word for word through the tutorial. When I first encountered array programming languages, it was in discussing "obfuscated c" with a coworker who likened it to the language K, that it was just line noise, and how can anyone read a language like that? Compared K to brainfuq
@Marshall I discovered APL by proxy just learning the narrative around K, and thought it was gorgeous, I was drawn to it. The notation was super tidy, and I had to figure out what it was about.
My first impressions of BQN on the other hand... its been kind of intimidating, like sterile, blocky, rigid, inflexible, gaunt (especially with the fold primitive, and the other modifiers), its hard on the eyes because of all the really tiny notation
I've spent all day trying to get something to display that I can tolerate looking at, not because its array notation, I like that part, but because of the tiny, angled, and aliased itty bitty things that were making my eyes strain to read anything
If I had 1 suggestion to make the website and the tutorial stuff more attractive, and nice to look at, I would switch the code font on your tutorial site and the repl to BQN386 Unicode font
The modifiers in particular are super legible, and I don't have to constantly squint when using it
my eyes are pretty tired after messing with BQN today, but this font is super soft on the eyes
It makes everything all around more soft, and less of that intimidation factor, instead it looks familiar, and not because I know APL already, but it is the same feeling I had the first time I saw APL
just my 2-bits
My preference would me something more like APL2 Unicode or VectorAPL for the ascii set, but they have really bad support for your extended symbols.
 
2:55 AM
@nathanrogers Thanks for writing this up. I can sort of see what you mean comparing the two fonts but I never would have thought of that as an issue on my own. It would help to have some other people here comment: obviously I've chosen the font I prefer but the website is mainly not for me.
One smaller thing I could do is just make the modifiers larger in the DejaVu mod. They're not combining characters so it shouldn't cause any issues in text, but I do have to make sure they're not referenced by other characters in the font file.
 
I think I prefer slightly larger modifiers too, at a small font size they are basically indistinguishable in DejaVu
 
Personally I think the minimalism and hard edges of BQN glyphs look cool but of course that's just a matter of taste.
I'll be back to take a look at this tomorrow!
 
in general I like the rest, I particularly like the circle thing you've got going on, that's pretty cool and nice that you can instantly tell what 'type' of symbol something is in general
 
@Marshall I think it looks cool in a "cold, logical alien race" sort of way, but even as someone who appreciates the notion of notation, it was a bit austere for me
But whatever font, yes larger modifiers please
especially constant. That is super hard to distinguish on the site
 
3:34 AM
Now, the puns @Marshall... Those are good
more of those
 
3:50 AM
    Base2
+⟜(2⊸×)´∘⌽

    base2 ↩ 16   # Change it to a number
@Marshall am I to understand by this example that Base2 and base2 are the same variable but different forms? and not 2 distinct names?
 
4:01 AM
@Marshall how does under know what areas of the array are... evaluated?
like in the example you showed ⌽⌾(4⊸↑)↕10 how does it know, since you're just taking 4, that 6 remain? Is there an implicit catenate happening here?
Also this example is a bit misleading to people just learning trains
('A'-'a')⊸+ ⌾ (2 ↑ 4⊸↓) "abcdefgh"
the 2↑4∘↓ looks like an atop, but really you're apply ⍵ to the constant function {2}, and passing the value to ↑. I don't think a novice is going to understand that and will likely only be confused later when other trains don't work due to this false intution
 
@nathanrogers I don't see much of a problem. As long as the user knows that a train works by recursively grouping 3 things from the right, the two interpretations {2}↑4∘↓ and (2∘↑)⍤(4∘↓) are identical.
It is indeed a useful way to read an Agh-fork (or should it be aGH-fork for BQN?)
 
4:24 AM
@Bubbler So I guess you're expecting all users of BQN to experienced APL and J users
Managing expectations then?
@Marshall this looks like a niladic function based on the example. It looks to an APLer like you're defining a function, and then invoking it and getting a printed response.

To make it more clear, You could simply remove the assignment altogether:
 
4:43 AM
@Marshall sorry, this is what I was referring to, the Headerless blocks example, idk what happened to the link
 
4:53 AM
@nathanrogers Where did you find the example? Can you share a link to the page?
 
mlochbaum.github.io/BQN/doc/block.html I keep linking it, sorry, I linked it both times, I'm not sure why it didn't stick
The headerless function section
 
I think that's pretty clear, 'An immediate block is only ever evaluated once' etc
 
I think the code can be made explicit by showing that it returns something. it looks here as if its being invoked as in a niladic function
 
(although this makes me wonder, if you have an impure function, say {⎕} in APL, how does that translate to bqn? do you need to still have a dummy argument?)
@nathanrogers the only reason anyone would know what a 'niladic function' even was was if they came from an APL background
 
right, and it this whole section makes a lot of inferences about background, by comparing BQN features to J or APL features
so there's a lot of expectation that the reader is coming from another implementation
 
4:58 AM
also, functions are uppercase in bqn anyway, so the fact it's lowercase shows it's a value
 
which has its benefits and drawbacks
no new array language user is going to be able to parse most of this documentation
 
Was the page changed in the middle of discussing it?
 
So much of it expects prior knowledge
 
I don't see any code that looks like ('A'-'a')⊸+ ⌾ (2 ↑ 4⊸↓) "abcdefgh" or uses Under or a train
 
that was for a different thing
 
5:00 AM
oh, sorry, 2 conversations overlapped
second
bout 3/4 way down the page
 
@nathanrogers it looks pretty accessible to me providing you know what like, 2-modifiers are for example, but that's covered earlier in the docs
I think the only reason anyone would think {something} could be a niladic function is if they knew about niladic functions and about dfns from APL. If they were truly learning {whatever} was a 'block' not a dfn, there would be no issue
 
@rak1507 "providing you know..." It is covered earlier, but to a new user, I'm telling you because this is an assumption I made early on that proved to make things confusing, that this is going to confuse a non-array programmer
its not confusing to you because you write trains all day
 
@nathanrogers Thanks, found it
 
@nathanrogers what was the assumption, that {thing} will be a niladic function?
 
@rak1507 The difference is the train example is in the "TUTORIAL" which new people are going to gravitate to, and the other section EXPLICITLY REFERS to contextual knowledge
 
5:04 AM
oh you're talking about the train thing now again
 
context is important. NEW USERS are going to jump to a conclusion. OLD USERS are going to jump to a conclusion
@rak1507 now I'm talking about both
 
alright
 
the train 2↑4∘↓ looks like 2↑4↓x, but it isn't, its ({2}x) ↑ (4↓x)
 
which is the same thing
 
and
f←{...}
f
   < result>
 
5:06 AM
oh right no I see what you mean
 
looks like a function call to APLers in a section where he speaks to APL and J knowledge
I'm saying for the first example
Make it explicit that this is happening rather than "leaving it up to the reader". I think that's a great learning point for new users and a short circuit for some easily confusing "false intuition"
And the same thing for the other section which speaks to domain knowledge, if I'm coming from APL that looks like a niladic function call, in a section where he speaks about BQN in comparison to APL
 
mlochbaum.github.io/BQN/tutorial/combinator.html could probably include a simple (f g h i j) function train then to make it clear that's how they worked
 
@rak1507 I don't think they need more complex examples, I think a literal translation like what I said a moment ago is the right answer, explicitly show the applicaiton
@nathanrogers this took forever for me to grok
 
I agree that the train being (suddenly) introduced in the fourth tutorial is weird.
It could be better to have a dedicated section about trains before that
Maybe the third tutorial, where it claims to cover the topic "tacit programming"
 
It does
 
5:10 AM
and something that makes it explicit the difference between
2↑4↓x
and the train
(2 ↑ 4∘↓)
({2}x) ↑ (4↓x)
 
{2}x is 2 though so I don't really understand your point
 
because look at the train
a new user, AKA ME for like 2 years, thought that it was an atop
but it straight isn't
and gave me false intuition about constants in trains
and how trains evaluate in general
 
The third tutorial includes the word "train" but it doesn't really explain it:
 
an (A f g) example is probably required then
 
> This is called a "train" and we should probably leave it for another tutorial before going too far off the rails.
 
5:11 AM
fair enough
(btw, this is why I always use ⊢/⊣ over ∘ in trains)
(2↑4↓⊢) is much more obvious imo
 
@rak1507 @Bubbler my whole point is that he "leaves (this specific example) it up to the reader to figure out", but I don't think he should if he's targeting new array language users... because this is a potential pit of confusion
 
@rak1507 what
 
I'm not sure who he's targeting but I don't think at this point in time he's targeting new language users
 
@nathanrogers And I'm agreeing with that
 
I could be wrong but if he is targeting new language users he's not doing a brilliant job
 
5:13 AM
👍
@rak1507 that's why I'm leaving this sort of feedback
 
yeah
I think your feedback is definitely really useful and I tend to agree with most of it
 
the docs talk to APL users, and people with some experience. The tutorial really needs to get people from square 1 to trains, or at least square 1 to reading the docs
 
at the very least, the combinators page should link to that tutorial
 
I just went through the whole tutorial line for line, and its a great intro for sure. Its funny and has some fun examples that I enjoyed
 
5:15 AM
But I was asking myself what I would have thought reading it if this was my first array language. There's a lot of assumptions of knowledge, which is understandable, we all use array languages so we forgot what we didn't know
 
asking a few friends to make sense of it might help
 
I love the light heartedness, but for the tutorials, taking a bit more time with a few
"If you've used APL you can skip to [link]." To not bore the array language users would really help the novice users, and probably appeal to a wider new user base
 
if you've used apl you can basically jump in at the deep end and not read (m)any docs at all (imo)
 
especially with code_report on youtube getting comments like "WE'RE HUNGRY FOR APL"/"MORE APL PLEASE!!!" people want this stuff, so making it some what amenable to that audience would help its adoption
@rak1507 Right, I think the tutorials are a great read through, gets you up to speed pretty quickly
and its much easier to make sense of the docs after
Does anyone know if there's a way to link with a text name in SE Chat? Like replace the text of the link with some other text?
 
test (oops)
 
5:19 AM
haah
 
yay, (name)[link] works
 
Isn't it the other way around?
[name](link)
 
yes, it is, my bad
 
@Marshall Based Array Theory is Based
 
5:23 AM
@ngn k
 
@Bubbler how
 
[name](link "tooltip")
though it isn't mobile friendly
 
Mobile user can't hover @Bubbler
also, nsfw language warning after 15 seconds or so
 
ngn
@nathanrogers e
 
@Marshall what is the difference between 'abcde' and "abcde"?
@Marshall for reference under "Verses nested array theory": mlochbaum.github.io/BQN/doc/based.html
using 'abcde' seems to make bacon explode
 
5:35 AM
@nathanrogers I think the single-quote strings in that section are APL code, not BQN one
 
@Bubbler oh you're probably right
right because it has [2] which bacon doesn't have
 
not convinced by this whole based array thing
 
You need to take the red pill and you too can become Based @rak1507
 
I quite like 3≡⊂3 :(
 
I don't have a strong preference for anything. I just get used to things by using it
 
5:43 AM
fair enough
 
tru. Reading these functional conditionals is really clever after getting through the gist of bacon with the tutorials
Its scary how general this notation actually is
 
But it is annoying to remember the interpreter quirks in golfing languages not documented anywhere, so I stopped using them. I just use Python/JS/Haskell/APL/J/Factor/Rust/whatever I feel like it
 
I don't like golflangs anyway, got a lot more enjoyment from learning some factor than learning jelly
 
I'm more of an idealist than a golfer. There must be some kind of underlying elegance to the thing
 
By going through lots of different practical languages, I learned that, for every programming paradigm, there is some whole class of code that cannot be expressed well within that paradigm
So I stopped being an idealist.
 
5:53 AM
@Bubbler I don't see lisp on your list
@Bubbler This is why I think rather than a paradigm a notation is required. A paradigm that allows you succinctly and with precision express transformations on data, eliminating the need for paradigms and abstraction
 
Okay, except lisp.
 
@Bubbler you need to learn you a lisp. its the only language I know of that has a literal notation for program constructing programs. programs that write the program you would have written, and its all at runtime
code_report goes through chapter by chapter of SICP which at the end implements a scheme interpreter in scheme. its a worthy read, and a worthy watch
After learning lisp, I can't help but be an idealist. The only thing is that computers have a much harder time with notation, and the programming community at large is against the very notion of notation, considers it unreadable, fooey to that
@Bubbler that series by code_report is cool becaues he points out how many times Lisp and Scheme legends credit APL with their ideas
Really reveals how much APL was dominant in the programming space in the early days
 
@nathanrogers Thanks, I'll try it out when I get some spare time
 
worth reading the book and doing the exercises. really pushes your algorithmic brain
 
ngn
@nathanrogers afaicr apl was mentioned once in the lectures (abelson&sussman's, not whatever "code report" is) and it was in a negative light
 
6:03 AM
@Bubbler I've just sent a PR for dyalog-apl-gitpod - I updated the version-numbers. WIBNI it could automagically link to the latest releases w/o having to code specific version numbers?
 
@ngn oh no, you need to watch code_report then, he accredits reduce to APL, and there's a lot of credit given to iverson throughout the lectures of both MIT and the Burkley lectures which he collects in his SICP overview series
@Marshall right, so I am looking at the primitives graphs, and I for the life of me can NOT understand how under works. I get what it does, but now how it works. For example
{𝔾⁼∘𝔽○𝔾} You say that you "undo" G, but actually, if I take the example of under from the tutorial
•←{(2⊸↑4⊸↑)⁼∘('A'-'a')⊸+○(2⊸↑4⊸↑)𝕩 }"abcdef"
and try to spell it explicitly, undo doesn't work
my bacon explodes with all sorts of errors
@Marshall but in the second encoding, I have no idea where W is coming from
{(𝔾𝕩)↩𝕨𝔽○𝔾𝕩⋄𝕩}
 
@MBaas Thanks, I'll merge it. Yeah, latest-release links would be great (you mean there are no such links yet, right?)
 
under only works like that conceptually, if you actually try and take the inverse of that it won't work
 
I'm assuming this is the binary case? But this doesn't halp me to understand the unary case
 
@Bubbler Not that I'm aware of - but I'll take it up with the IT guys and see if they can be convinced (or have other ideas)
 
6:14 AM
@rak1507 right, so how does it actually work then? does it do an index match of the range? or are there meta properties of these functions in the interpreter, or what what what? because I don't know @+¨119‿116‿102‿98‿98‿113
 
no idea, ask marshall/look in the source
 
@rak1507 I did @+¨109‿97‿114‿115‿104‿97‿108‿108
I'm gonna have to go through blocks again because it made sense when I was reading it, and now I don't. Its what I get for reading it at midnight on daylight savings day.
GN
 
6:34 AM
@nathanrogers Under is a new big monster that very few people fully understand what it formally does (or at least you can safely assume so). In many cases it is sufficient to think of it in plain English analogy.
(Maybe it's worth having a dedicated article for how it works with all sorts of primitives and their compositions)
 
7:07 AM
@Bubbler agree
 
 
5 hours later…
11:51 AM
@nathanrogers I too kind of don't like APL385's a-zA-Z for long-form text, but the look of glyphs is well worth it for me. (and my BQN386 modifiers went through quite a few refactorings, keeping them the same style in the same bounding box, while keeping them somewhat legible)
@nathanrogers F⌾G x first calls F G x, and then does Magic™ to call some form of G⁼, which includes giving it knowledge of the original x so it could make decisions. If you were G in G←4⊸↑, and from ⌽⌾G↕10 were given 3‿2‿1‿0≡F G x and (↕10)≡x, you have everything you need to create 3‿2‿1‿0‿4‿5‿6‿7‿8‿9
and the Magic™ part isn't very complicated either - in dzaima/BQN, calling a function and its inverse are equally "valid" ways to use a function. Calling a functions inverse with the knowledge of the original value is another equally-as-valid way to invoke a function
 
@RGS @dzaima thanks for the +1s. I've added some tests (there weren't really much in terms of APL) to the pygments PR, so let's see what they think.
 
12:07 PM
@nathanrogers The thing here is 2⊸↑∘(4⊸↑) looks horrible enough to make someone just quit. I think it's better to show a nice and intuitive version, and point out that an explanation is still coming up.
@nathanrogers I guess I'm just going to brute force this by stating that an immediate block isn't a niladic function. It's moderately important to show it has a subject role, which is why the assignment's there.
 
RGS
@xpqz Yup, I got an email about that. Hopefully it is fine now.
 
@dzaima (fwiw I still have a custom userstyle for mlochbaum.github.io, which includes usage of BQN386 among other changes to style and brightening things up)
 
12:23 PM
@nathanrogers yeah, that's what's meant by variable names being case-insensitive. The case only, and only, matters for the syntactic role. (and underscores too, base2←16 ⋄ ba__SE_2 is 16 too)
 
@nathanrogers A function with 𝕨 doesn't require a left argument. If there isn't one, then 𝕨 is set to ·, called Nothing, so that it basically disappears from expressions. 𝕨𝔽○𝔾𝕩 would be 𝔽○𝔾𝕩 for example. It's covered after the first code block here.
 
why not throw an error?
 
@rak1507 I don't want it to be an error, I want it to be 𝔽○𝔾𝕩.
 
how come
 
@rak1507 it allows for very fancy ambivalent function creation
 
12:31 PM
sounds slightly pointless to me
 
@rak1507 I mean almost all of the modifier definitions here use it.
 
fair enough
 
It also lets you use a default left argument easily with 𝕨⊣default.
@nathanrogers There are (at least) two ways to implement structural Under. One is to store recovery information in each primitive as it's defined, and use that to undo them one at a time. The other is to evaluate 𝔾 on an array of indices, possibly expanding them to arrays of sub-indices if needed. dzaima/BQN uses the first and self-hosted BQN uses the second.
The specification contains a complicated proof that structural Under is well-defined, so any method of computing it will get the same result assuming it can find it.
This is better than the Undo-based scenario, which isn't always well-defined. Undo has to be specified in common cases, like requiring that ט⁼be so it doesn't give a negative answer.
And yes I still need to write a documentation page on Under.
@rak1507 Also still working on the tacit programming documentation page.
 
12:59 PM
@Adám I tried myself at Roger's problem once again, and i'm a bit disappointed. Now i understood the hint and used it to implement this program:
#define T1(x)for(i=0;i<x;++i)
typedef unsigned long long L;
typedef unsigned int U;
typedef int I;
typedef char C;

C f1(C*x,L n){
    U i;C b[256]={0},*c,m;T1(n)b[*x++]=1;c=b+256;
    T1(256)if(*--c){m=c-b;break;}return m;}
C f2(C*x,L n){U i;C m=*x++;T1(n){if(*x>m)m=*x;x++;}return m;}
I also wrote some driver code for benchmarking it:
I main() {
    const U mx=1<<12;U i;C c[mx];T1(mx)c[i]=rand();
    L s1=__rdtsc(),e1,e2;C m1=f1(c,mx);e1=__rdtsc();
    C m2=f2(c,mx);e2=__rdtsc();printf("%llu, %llu\n",
    e1-s1,e2-e1);return m1-m2;}
(x86 only)
I tried: benchmarking it as 32-bit code, benchmarking it with my march=native on i5 7400, benchmarking it with old architectures, benchmarking it with -O1, -O2, -O3, -Ofast, -Os, i benchmarked it on an ARM machine (sm8150)
and Roger's version is faster only for an old architecture and -O1, for any other combination it's much, much slower
and it's nowhere near being as fast as Roger advertised it to be; as it's around 1,05-1,1 times faster, not 1,5 times faster
 
@KamilaSzewczyk Can you remind me what this is about?
 
I also read Roger's paper on that, and he must have been aware of modern instruction sets which i disabled, for some reason.
@Adám the fastest way of finding maximum of a uint8_t vector
Roger's version is also slower on -O0, which unrolls no loops, and vectorizes nothing.
 
@KamilaSzewczyk The simple code beats it because of autovectorization. But on a 64-bit machine you can also do faster by adding eight bytes at a time with SWAR.
 
@Marshall Roger explicitly mentioned that it's disallowed
yes, I know that it'd be faster, in fact, this was my go-to solution before i found out that it's banned :)
 
@KamilaSzewczyk As in, you're not allowed to do ordinary arithmetic on 64-bit values?
 
1:07 PM
no, because it counts as unrolling.
at least that was the consensus we got
 
Well this has become a rather good example of Carbon Copy, of Myself testing.
 
1:21 PM
tl;dr please :P
 
1:47 PM
@KamilaSzewczyk I was just referencing the phrase "Carbon Copy, of Myself". Someone's only going to get the question right if they think just like Roger. Loop unrolling is a dirty trick but allocating 256 bytes and adding a bunch of constant overhead is just fine.
 
@Marshall i know what Roger meant
because of the hint
it used the key operator which means that roger wanted me to pick distinct items from the vector, and only then find the largest of them
because this means that the loop which executes N times doesn't have a conditional, only memory write to toggle 1 at the index the current value is at
and then a 256-iteration loop rewinds from the back and picks the index of first 1
intuitively, this might be simpler and faster, but not really
it's slower on larger workloads - 1<<16 random numbers, also slower on smaller workloads - 1<<7 random numbers
for 1<<20 I get 3 291 596 vs 375 644 which is much, much, much slower.
 
@Marshall interesting article
 
btw, the speed increase is observable only with clang, only for x86, only with -O1, to be more clear.
 

« first day (1510 days earlier)      last day (1145 days later) »