Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
Internet Janitor
May 17, 2008

"That isn't the appropriate trash receptacle."

Cybernetic Vermin posted:

on another subject matter entirely: since you bothered to implement it at one point, do you know a reasonably idiomatic use of the odometer operator (in k and presumably others)?

there are simple ways to implement odometer, but you want your dialect's equivalent of base-decode: {+x\'!*/x} (k5) or {x _vs!*/x} (k2/k3)

if you just form a cartesian product, you have to make a bunch of nested lists and then flatten them back out to get the same effect; it's less direct, and it gets messier for higher dimensions:
code:
  !2 3
(0 0 0 1 1 1
 0 1 2 0 1 2)
  (!2),/:\:!3
((0 0
  0 1
  0 2)
 (1 0
  1 1
  1 2))
  ,/(!2),/:\:!3
(0 0
 0 1
 0 2
 1 0
 1 1
 1 2)
  +,/(!2),/:\:!3
(0 0 0 1 1 1
 0 1 2 0 1 2)
odometer is useful for expressing many combinatorial search problems in a single pass, rather than multiple nested iterations.

as another concrete example, here's a cute way of generating power sets from a list:
code:
  {x@&:'+!(#x)#2}`a`b`c
(()
 ,`c
 ,`b
 `b`c
 ,`a
 `a`c
 `a`b
 `a`b`c)
I don't think arthur considers odometer essential, just a convenience- it's often implemented in k rather than c. he has also been known at times to add features in his languages which make various benchmark-puzzles more elegant to express.

Adbot
ADBOT LOVES YOU

Nomnom Cookie
Aug 30, 2009



Subjunctive posted:

I’m suspicious

that’s reasonable. I was also excited for arc

animist
Aug 28, 2018

Plorkyeran posted:

racket's trying to become a real language rather than a dumb toy for annoying lispers. naturally the annoying lispers are unhappy about this.

i've always wanted to learn Racket

is it possible to compile it? also, do people actually used the typed subsets of the language?

Plorkyeran
Mar 22, 2007

To Escape The Shackles Of The Old Forums, We Must Reject The Tribal Negativity He Endorsed
yes, it can compile to a standalone binary.

the only time i ever used typed racket was when i was still in school and could go bother tobias personally if we had issues. it seemed good but unfinished then, but that was 10 years ago so i would hope it's better now. racket doesn't have a lot of industry production use to begin with, so obviously typed racket is going to have even less.

redleader
Aug 18, 2005

Engage according to operational parameters

Internet Janitor posted:

code:
  {x@&:'+!(#x)#2}`a`b`c

jesus loving christ, a language that makes mumps look both beautiful and comprehensible

Internet Janitor
May 17, 2008

"That isn't the appropriate trash receptacle."
code:
/ a vector of symbols- interned, atomic strings. good for dictionary keys
`a`b`c

/ curly braces enclose lambdas. x is implicitly the first argument to a lambda
  {x}`a`b`c
`a`b`c

/ unary # is count of x
  {#x}`a`b`c
3

/ binary # is take- make copies or resize a list
/ evaluation is strictly right to left unless there are parentheses
  {(#x)#2}`a`b`c
2 2 2

/ unary ! of a list is odometer- see above
  {!(#x)#2}`a`b`c
(0 0 0 0 1 1 1 1
 0 0 1 1 0 0 1 1
 0 1 0 1 0 1 0 1)

/ unary + is transpose- flip the axes of a matrix
  {+!(#x)#2}`a`b`c
(0 0 0
 0 0 1
 0 1 0
 0 1 1
 1 0 0
 1 0 1
 1 1 0
 1 1 1)

/ unary & is where- collect the nonzero indices
  &0 0 1 0 1 1
2 4 5

/ the symbol ' is each- map the operation on the left over the list on the right
  {&:'+!(#x)#2}`a`b`c
(()
 ,2
 ,1
 1 2
 ,0
 0 2
 0 1
 0 1 2)

/ binary @ is index- note that this indexes with the entire structure on the right
  {x@&:'+!(#x)#2}`a`b`c
(()
 ,`c
 ,`b
 `b`c
 ,`a
 `a`c
 `a`b
 `a`b`c)
you'd read x@&:'+!(#x)#2 aloud as "x indexed by where each of the transpose of the count of x take 2"

you have to learn K's operators before you can read it, and once you do it's very clear and comprehensible

our summer interns pick this stuff up in a few days

Soricidus
Oct 21, 2010
freedom-hating statist shill

Internet Janitor posted:

code:
/ a vector of symbols- interned, atomic strings. good for dictionary keys
`a`b`c

/ curly braces enclose lambdas. x is implicitly the first argument to a lambda
  {x}`a`b`c
`a`b`c

/ unary # is count of x
  {#x}`a`b`c
3

/ binary # is take- make copies or resize a list
/ evaluation is strictly right to left unless there are parentheses
  {(#x)#2}`a`b`c
2 2 2

/ unary ! of a list is odometer- see above
  {!(#x)#2}`a`b`c
(0 0 0 0 1 1 1 1
 0 0 1 1 0 0 1 1
 0 1 0 1 0 1 0 1)

/ unary + is transpose- flip the axes of a matrix
  {+!(#x)#2}`a`b`c
(0 0 0
 0 0 1
 0 1 0
 0 1 1
 1 0 0
 1 0 1
 1 1 0
 1 1 1)

/ unary & is where- collect the nonzero indices
  &0 0 1 0 1 1
2 4 5

/ the symbol ' is each- map the operation on the left over the list on the right
  {&:'+!(#x)#2}`a`b`c
(()
 ,2
 ,1
 1 2
 ,0
 0 2
 0 1
 0 1 2)

/ binary @ is index- note that this indexes with the entire structure on the right
  {x@&:'+!(#x)#2}`a`b`c
(()
 ,`c
 ,`b
 `b`c
 ,`a
 `a`c
 `a`b
 `a`b`c)
you'd read x@&:'+!(#x)#2 aloud as "x indexed by where each of the transpose of the count of x take 2"

you have to learn K's operators before you can read it, and once you do it's very clear and comprehensible

our summer interns pick this stuff up in a few days

no

eschaton
Mar 7, 2007

Don't you just hate when you wind up in a store with people who are in a socioeconomic class that is pretty obviously about two levels lower than your own?

eschaton
Mar 7, 2007

Don't you just hate when you wind up in a store with people who are in a socioeconomic class that is pretty obviously about two levels lower than your own?
so long as APL and its derivatives exist, nobody is allowed to complain about Lisp syntax

distortion park
Apr 25, 2011


apl/k/q are all great should be supported as a dsl within other languages, like regex

Zlodo
Nov 25, 2006

eschaton posted:

so long as APL and its derivatives exist, nobody is allowed to complain about Lisp syntax

this is like saying that as long as php exists no one is allowed to complain about javascript

eschaton
Mar 7, 2007

Don't you just hate when you wind up in a store with people who are in a socioeconomic class that is pretty obviously about two levels lower than your own?
like I’m a Lisp proponent and still understand why some people initially dislike it, you do have to learn to read “through” the parentheses (same as people new to Objective-C have to learn to read “through” the square brackets)

but APL and its derivatives make intentionally-obfuscated Perl and MUMPS both look like goddamn COBOL, the only thing comparable to them in sheer opacity is loving Urbit and it was designed by a crazy bigot to be intentionally opaque and establish a priesthood

Zlodo
Nov 25, 2006
brb writing some apl code

*wipes rear end with keyboard*

mystes
May 31, 2006

pointsofdata posted:

apl/k/q are all great should be supported as a dsl within other languages, like regex
NumPy exists, OP.

Soricidus
Oct 21, 2010
freedom-hating statist shill

pointsofdata posted:

apl/k/q are all great should be supported as a dsl within other languages, such as regex

I improved your idea

Nomnom Cookie
Aug 30, 2009



eschaton posted:

like I’m a Lisp proponent and still understand why some people initially dislike it, you do have to learn to read “through” the parentheses (same as people new to Objective-C have to learn to read “through” the square brackets)

but APL and its derivatives make intentionally-obfuscated Perl and MUMPS both look like goddamn COBOL, the only thing comparable to them in sheer opacity is loving Urbit and it was designed by a crazy bigot to be intentionally opaque and establish a priesthood

urbit! now that’s a fuckin badlang

Internet Janitor
May 17, 2008

"That isn't the appropriate trash receptacle."

eschaton posted:

like I’m a Lisp proponent and still understand why some people initially dislike it, you do have to learn to read “through” the parentheses (same as people new to Objective-C have to learn to read “through” the square brackets)

but APL and its derivatives make intentionally-obfuscated Perl and MUMPS both look like goddamn COBOL, the only thing comparable to them in sheer opacity is loving Urbit and it was designed by a crazy bigot to be intentionally opaque and establish a priesthood

mumps is a fairly normal imperative programming language with weird looking syntax and numerous footguns because it was invented in the 1960s and still bears the scars of those early constraints

apl is an opportunity for lisp and haskell people to experience the sensation of a totally unfamiliar language again, much like the sensation that people who know python or js get when they look at something genuinely different like lisp, haskell, prolog, or forth for the first time. the dissonance between mastery of other things and the unfamiliarity of something new makes many experienced programmers shut down and stick their fingers in their ears. it rubs their egos the wrong way

for those who make it past the first filter, the second gut reaction everyone has is to try to recreate the apl primitives as a library for their favorite language, with conventional-looking spelled-out names and all the functions underloaded-apart into more specialized ones. this still misses the point. the notation is important. concise, consistent notation that reveals patterns through idioms instead of wrapping ideas in abstractions is valuable. Aaron Hsu has given some good talks about this:

https://www.youtube.com/watch?v=v7Mt0GYHU9A

the most frustrating thing about working with apls is that literally every discussion of apl online contains exactly the same knee-jerk critique, formed after scarcely a moment's contemplation of the subject

Athas
Aug 6, 2007

fuck that joker
I like to think that my dislike of APL isn't completely knee-jerk, because I did put some effort into learning it, and even helped write an APL compiler that targeted GPUs (not co-dfns, another one). Maybe I just got stuck in the third filter, but I found lots of performance poison in APL. I do get what Iverson was going for, and I can definitely see why APL is nice for some things. Mostly I ended up being disillusioned because all the parallelism promises were hot air.

I do sometimes get the urge to properly learn one of the K dialects. Has any interesting publicly available software been written in APL, K, or J?

Gazpacho
Jun 18, 2004

by Fluffdaddy
Slippery Tilde

Internet Janitor posted:

you'd read x@&:'+!(#x)#2 aloud as "x indexed by where each of the transpose of the count of x take 2"
hmm, pretty sure i wouldn't op

Blinkz0rz
May 27, 2001

MY CONTEMPT FOR MY OWN EMPLOYEES IS ONLY MATCHED BY MY LOVE FOR TOM BRADY'S SWEATY MAGA BALLS

Internet Janitor posted:

code:
/ a vector of symbols- interned, atomic strings. good for dictionary keys
`a`b`c

/ curly braces enclose lambdas. x is implicitly the first argument to a lambda
  {x}`a`b`c
`a`b`c

/ unary # is count of x
  {#x}`a`b`c
3

/ binary # is take- make copies or resize a list
/ evaluation is strictly right to left unless there are parentheses
  {(#x)#2}`a`b`c
2 2 2

/ unary ! of a list is odometer- see above
  {!(#x)#2}`a`b`c
(0 0 0 0 1 1 1 1
 0 0 1 1 0 0 1 1
 0 1 0 1 0 1 0 1)

/ unary + is transpose- flip the axes of a matrix
  {+!(#x)#2}`a`b`c
(0 0 0
 0 0 1
 0 1 0
 0 1 1
 1 0 0
 1 0 1
 1 1 0
 1 1 1)

/ unary & is where- collect the nonzero indices
  &0 0 1 0 1 1
2 4 5

/ the symbol ' is each- map the operation on the left over the list on the right
  {&:'+!(#x)#2}`a`b`c
(()
 ,2
 ,1
 1 2
 ,0
 0 2
 0 1
 0 1 2)

/ binary @ is index- note that this indexes with the entire structure on the right
  {x@&:'+!(#x)#2}`a`b`c
(()
 ,`c
 ,`b
 `b`c
 ,`a
 `a`c
 `a`b
 `a`b`c)
you'd read x@&:'+!(#x)#2 aloud as "x indexed by where each of the transpose of the count of x take 2"

you have to learn K's operators before you can read it, and once you do it's very clear and comprehensible

our summer interns pick this stuff up in a few days

what the gently caress even is the point of all this

Cybernetic Vermin
Apr 18, 2005

Blinkz0rz posted:

what the gently caress even is the point of all this

for this kind of philosophizing about the evils of software in general the 'wander into the woods' thread is recommended

Dylan16807
May 12, 2010

Blinkz0rz posted:

what the gently caress even is the point of all this

Internet Janitor posted:

here's a cute way of generating power sets from a list:

Internet Janitor
May 17, 2008

"That isn't the appropriate trash receptacle."

Athas posted:

I like to think that my dislike of APL isn't completely knee-jerk, because I did put some effort into learning it, and even helped write an APL compiler that targeted GPUs (not co-dfns, another one). Maybe I just got stuck in the third filter, but I found lots of performance poison in APL. I do get what Iverson was going for, and I can definitely see why APL is nice for some things. Mostly I ended up being disillusioned because all the parallelism promises were hot air.

I do sometimes get the urge to properly learn one of the K dialects. Has any interesting publicly available software been written in APL, K, or J?

I think the parallelism claims for apl are sort of like the lisp claims about being "good for ai": not impossible, but mostly left as an exercise for the reader. perhaps it was more true by the standards of the day when these languages were young, but the woo has aged poorly

nick psaris has written some interesting open-source libraries in q, like his funq project that provides q implementations of a wide range of machine learning algorithms. it's mostly cool how it's possible to distill them all down to common elements and highlight similarities and differences

i haven't played with it but nick nickolov of dyalog has released ngn k, which is presumably much faster than mine and based on a more modern dialect of k than kona. my interpreter is still the only one that comes with snake and asteroids implementations, though. :)

dyalog also has some interesting examples on their site

dyalog, q, and k all being commercial products will probably forever stunt the open-source ecosystems of these languages, though. it's a shame.

Sapozhnik
Jan 2, 2005

Nap Ghost
yeah was going to say proprietary languages aren't really going to flourish outside of specific ecological niches these days irrespective of their other merits

"hmm i'd like to gently caress around with this unusual lang for a weekend. oh a license for the compiler is 10 grand? cool, guess i'll just go gently caress myself then"

fritz
Jul 26, 2003

Zlodo posted:

brb writing some apl code

*wipes rear end with keyboard*

i didnt realize your posts were in apl all this time

Gazpacho
Jun 18, 2004

by Fluffdaddy
Slippery Tilde
the very thought of people priding themelves on knowledge of niche & legacy PLs infuriates me tbh

rjmccall
Sep 7, 2007

no worries friend
Fun Shoe

Internet Janitor posted:

I think the parallelism claims for apl are sort of like the lisp claims about being "good for ai": not impossible, but mostly left as an exercise for the reader. perhaps it was more true by the standards of the day when these languages were young, but the woo has aged poorly

yeah, high-performance parallelism is really tricky even for experts working on a concrete problem. gpus offer amazing amounts of parallelism but also some painful limitations and the overheads and memory costs make them unworkable for a lot of applications. simd parallelism is incredibly complicated and getting good performance means doing weeks of experiments to discover crazy new micro-architectural limitations that you never even imagined and then channeling that dark magic into precise bits of assembly, and then doing it all over again for the next processor release. concurrent parallelism burns hilarious amounts of power and hardware. none of these things are really a fixable by the programming model

Notorious b.s.d.
Jan 25, 2003

by Reene

SAVE-LISP-AND-DIE posted:

It depends on your definition of Lispiness. Clojure tried this and the Lisp weenies refuse to use it because it doesn't implement cons cells, the literal function names car/cdr and it uses reader macros for useful datatstructures instead of reimplementing garbage a-lists and whatever the hell else who cares

be fair to the lisp weenies

clojure is 0% compatible with common lisp, so it can't use any pre-existing libraries, and is also not faster than common lisp, and also does not have better tooling than common lisp

why would anyone who already uses lisp want to adopt clojure? java inter-op?

redleader
Aug 18, 2005

Engage according to operational parameters

Internet Janitor posted:

code:
/ explanation
you'd read x@&:'+!(#x)#2 aloud as "x indexed by where each of the transpose of the count of x take 2"

you have to learn K's operators before you can read it, and once you do it's very clear and comprehensible

our summer interns pick this stuff up in a few days

ty for this effortpost response to my knee jerk and predictable response. fwiw i'm glad that you have a strange, unconventional lang that you enjoy and get paid to use

excellent bird guy
Jan 1, 2020

by Cyrano4747
The seasoned gnu beards laugh when i ask to learn elisp, they say its a really lovely language!

Notorious b.s.d.
Jan 25, 2003

by Reene

excellent bird guy posted:

The seasoned gnu beards laugh when i ask to learn elisp, they say its a really lovely language!

elisp is lovely but also look at the alternatives

would you rather spend your time with vimscript

champagne posting
Apr 5, 2006

YOU ARE A BRAIN
IN A BUNKER


Notorious b.s.d. posted:

be fair to the lisp weenies

clojure is 0% compatible with common lisp, so it can't use any pre-existing libraries, and is also not faster than common lisp, and also does not have better tooling than common lisp

why would anyone who already uses lisp want to adopt clojure? java inter-op?

java inter-op is the reason

SAVE-LISP-AND-DIE
Nov 4, 2010

Notorious b.s.d. posted:

be fair to the lisp weenies

clojure is 0% compatible with common lisp, so it can't use any pre-existing libraries, and is also not faster than common lisp, and also does not have better tooling than common lisp

why would anyone who already uses lisp want to adopt clojure? java inter-op?
I can think of 2 reasons:
More jobs because the JVM is a safe bet.

Rich Hickey is reasonably opinionated about how to build business apps. You could write Clojure in CL but you'd be the only shop doing it.

The tooling sucks, apparently it's a direct tradeoff between compiling to Java and supporting good things like conditional restarts and a proper debugger.

Xarn
Jun 26, 2015

Internet Janitor posted:

apl is an opportunity for lisp and haskell people to experience the sensation of a totally unfamiliar language again, much like the sensation that people who know python or js get when they look at something genuinely different like lisp, haskell, prolog, or forth for the first time. the dissonance between mastery of other things and the unfamiliarity of something new makes many experienced programmers shut down and stick their fingers in their ears. it rubs their egos the wrong way

So I want to touch upon this idea, both because I think I can empathize, and also that I no longer understand it. My PL-learning progression went something like Python/Java/C++ -> Lisp -> Prolog -> Haskell, and at some point along the way I also tried Forth for a bit, but disliked it. And I have to say that for as long as I was at Uni, working on stupid and unimportant poo poo, I really enjoyed dabbling with new and obscure languages.

However, after finishing my masters and becoming a lead of a small team working on solver/optimizer for a niche combinatoric optimization problem, my PoV shifted much more to

Gazpacho posted:

the very thought of people priding themelves on knowledge of niche & legacy PLs infuriates me tbh

which I ascribe to working in domain that taxes me intellectually, so I don't need to look for intellectual stimulation in the language I write with (not that C++ is not taxing :v:).

Cybernetic Vermin
Apr 18, 2005

that line of argument runs completely counter to my experience with k/q though, they are not at all mentally taxing, less so than on the surface seemingly simpler languages. the real usecase is very much in prototyping computational stuff, where the complexity is such that it is preferred to have the whole thing in front of you tinkering at it, rather than building up layers of abstraction.

which also touches upon an earlier question: why are there no significant public projects with k/q/j/apl. beside the proprietary nature of most implementations; even working with k/q for a bunch of years the pattern was very much that any k/q project which grew over time it was rewritten in java. plenty of stuff stayed k/q, but it was then services which were pretty much written-and-done, deployed and spinning away, very rarely touched.

SAVE-LISP-AND-DIE
Nov 4, 2010

Xarn posted:


which I ascribe to working in domain that taxes me intellectually, so I don't need to look for intellectual stimulation in the language I write with (not that C++ is not taxing :v:).

AMA about working in fintech, the most tedious of techs

Xarn
Jun 26, 2015
Nah, I like being happy and undepressed.

distortion park
Apr 25, 2011


Cybernetic Vermin posted:

which also touches upon an earlier question: why are there no significant public projects with k/q/j/apl. beside the proprietary nature of most implementations; even working with k/q for a bunch of years the pattern was very much that any k/q project which grew over time it was rewritten in java. plenty of stuff stayed k/q, but it was then services which were pretty much written-and-done, deployed and spinning away, very rarely touched.

I think part of this (at least for k/q and whatever that thing that one bank tricks its hungarian grad intake into doing) is that the main users are financial institutions which don't do much open source, and someone who knows any of them well will normally be sucked into their orbit by the high pay and job security on offer.

distortion park
Apr 25, 2011


Gazpacho posted:

the very thought of people priding themelves on knowledge of niche & legacy PLs infuriates me tbh

the way people do this with JS is really annoying. people showing off their big brains by telling new starters about all the way they've hosed up. Normally they'd have to keep it to complex features but with js they can do it for null checking.

Adbot
ADBOT LOVES YOU

Subjunctive
Sep 12, 2006

✨sparkle and shine✨

I think the discussion of badlang missed an essential element: it should have numeric semantics that map poorly to modern processors, such as a 55-bit mantissa for its floating point types, and overflow semantics that change representation like we put in JS because man who knew it was ever going to end up as machine code anyway

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply