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
tef
May 30, 2004

-> some l-system crap ->

Mr Dog posted:

programming in the 80s and early 90s was about cleverness because you had to fit an elephant of functionality into a thimble of hardware. discipline is the order of the day, not cleverness. but that's not very appealing to "rock stars"

you are being nostalgic for a time you never experienced and at the same time claiming seniority over the youth of today. i find this amusing.

Adbot
ADBOT LOVES YOU

tef
May 30, 2004

-> some l-system crap ->

Mr Dog posted:

like i've dealt with way too many precious snowflake .~*code poets*~. writing illegible poo poo to consider anything but the most mundane language "power" features to be worth having around.

Unfortunately at the same time you're embracing weird performance driven features. Why can't we all just use a bignum type and stop it with these fixed width integers and floating point. Those hardware types are a premature optimization which leads to complexity.


quote:

programming in the 80s and early 90s was about cleverness because you had to fit an elephant of functionality into a thimble of hardware.

Somewhat, but a lot of the programming was just dumb batch scripts and payroll. You're thinking of games. The same is often true today of games.


quote:

these days we have ample compute power, although it's often distributed, unreliable, and nondeterministic. discipline is the order of the day, not cleverness.

all of those things were true back then, and so was your conclusion.

quote:

but that's not very appealing to "rock stars" born 20 years too late to claim a massive chunk of the new frontier of computing from their garage, now is it.

rock stars are somewhat a modern phenomenon but there has always been programmers showing off.

Malcolm XML
Aug 8, 2009

I always knew it would end like this.

AlsoD posted:

i genuinely have no idea what that does so i'm going to find out and demonstrate the process. my first port of call is the docs.

hoogle search: (%%@=) +lens
clicking the function takes you to its documentation.

poo poo that really is a nasty type sig

so %%@= is the state version of %%@~ (aka withIndex) which is the indexed version of %%~

now the docs for %%~ make a lot more sense - it's like %~ but, given a Lens' s a, rather than applying an (a -> b) to its target* it applies a (Functor f => a -> f b).

therefore %%@~ takes an (Functor f => i -> a -> f b) where i is your index type
therefore %%@= takes the same function except as well as adjusting the target (inside the state) you can return a value i.e. the Functor has to be (r,).

for example.
code:
sumIxTimesState :: State [Int] Int
sumIxTimesState = fmap getSum $ itraversed %%@= (\i x -> (Sum (i*x), x))

main = print $ evalState sumIxTimesState [3,1,2,4] -- 17
there. the worst, most alphabet soup operator in lens is successfully decoded. are there better ways of doing this particular example? of course. the point is though that this works even in a much more complicated state without getting any more difficult


*: there can also be more than one target (i.e. operating over a list or whatever) in which case you need a Traversal rather than a Lens, an Applicative instead of a Functor and r has to be a monoid to combine the results from the function

christ all that for fmap (sum . zipWith (*) [0..]) get (or get <$> sum .zipWith (*) [0..] for the cool kids)

i mean i get why generalized indexed generalized traversals inside a generalized MonadState that preserve state are cool but gently caress if that requires 10 type parameters

Malcolm XML fucked around with this message at 21:32 on Feb 8, 2014

Malcolm XML
Aug 8, 2009

I always knew it would end like this.

Notorious b.s.d. posted:

in lisp it's not the norm at all to abuse operators

since names like "+" and "-" and "8===D~!" get no special precedence or infix notation, there is no temptation to use them outside of a math context.

quite to the contrary, most lisp libraries seem to give you long wordy names

lmao

"I don't like syntax foolery so i will advocate for the language that has the most powerful syntax fooling system known: macros"

ever stared at the loop macro? i will take %%@= over that any day of the week

funroll loops
Feb 6, 2007
CAPSISSTUCK
you know chat complaining about math notation is usually reserved for dimwit hners in the hn thread, but what do you guys actually think is better? long names almost certainly isn't the answer. typing math is really bad as it is now. i'd be interested to see one of you solve a longish somewhat difficult problem that required a knowledge level of like diff eq to solve.

i mean, what do you do when your proof is actually about generic numbers? write "real1" instead of "a"?

tef
May 30, 2004

-> some l-system crap ->

Malcolm XML posted:

lmao

"I don't like syntax foolery so i will advocate for the language that has the most powerful syntax fooling system known: macros"

ever stared at the loop macro? i will take %%@= over that any day of the week

look it's bad when we use punctuation to introduce syntax, but it's ok when we implement our own evaluation order if it has a alphanumeric name

FamDav
Mar 29, 2008

funroll loops posted:

you know chat complaining about math notation is usually reserved for dimwit hners in the hn thread, but what do you guys actually think is better? long names almost certainly isn't the answer. typing math is really bad as it is now. i'd be interested to see one of you solve a longish somewhat difficult problem that required a knowledge level of like diff eq to solve.

i mean, what do you do when your proof is actually about generic numbers? write "real1" instead of "a"?

uhhh you don't write your types?

F : ℝ -> ℝ

coffeetable
Feb 5, 2006

TELL ME AGAIN HOW GREAT BRITAIN WOULD BE IF IT WAS RULED BY THE MERCILESS JACKBOOT OF PRINCE CHARLES

YES I DO TALK TO PLANTS ACTUALLY

funroll loops posted:

you know chat complaining about math notation is usually reserved for dimwit hners in the hn thread, but what do you guys actually think is better? long names almost certainly isn't the answer. typing math is really bad as it is now. i'd be interested to see one of you solve a longish somewhat difficult problem that required a knowledge level of like diff eq to solve.

i mean, what do you do when your proof is actually about generic numbers? write "real1" instead of "a"?

mathematical ideas are best communicated with prose. the notation's just there to a) provide rigour where plain english can't and b) so the reader doesn't have to invent their own notation when they themselves want to manipulate the ideas at hand.

coffeetable fucked around with this message at 21:55 on Feb 8, 2014

funroll loops
Feb 6, 2007
CAPSISSTUCK

FamDav posted:

uhhh you don't write your types?

F : ℝ -> ℝ

right, but people are mad about that i guess? people are mad about that being unclear.

honestly the example im thinking of is solving some sort of classical mechanics problem involving a lagrangian except with whatever notation people think is better subbed in. long descriptive names all along the way seem like a nightmare for even a fairly simple problem (ie, something someone with a bs in physics could solve).

and then even when you have descriptive names you're still hosed because actual pure math might have no physical analogs to name variables after

fritz
Jul 26, 2003

coffeetable posted:

mathematical ideas are best communicated with prose.

that's what they used to do back thru like the 17th century and: that poo poo sucked

fritz
Jul 26, 2003

computer parts posted:

why yes, let's use a mixture of latin letters and the letters of a language that directly preceded and influenced latin, nothing can go wrong here

there's like no overlap in the lower case letters except in maybe omicron and the only time that ever gets used is in little-o notation (i guess nu kind of looks like a scripty v)

tbh id like to see more hebrew and cyrillic letters getting used, only ones that show up are aleph (and sometimes beth) and once in a while sha

FamDav
Mar 29, 2008
sometimes π is neither π nor π

fritz
Jul 26, 2003

Notorious b.s.d. posted:

incidentally, the classic example of "good" operator overloading, math, sucks poo poo. mathematical notation is a crime against sentience. it's a jungle of bad loving ideas that we were all trained on as children, so now it is familiar.

when you write a math paper, you are obligated to use centuries-old notation, no matter how terrible, because it is the common language of your audience. by the same token, if you wish to express a new idea, you have to extend the old language.

you're totally free to make up your own notation, crazy people do it all the time

fritz
Jul 26, 2003

FamDav posted:

sometimes π is neither π nor π

it used to bug me a little when people would use π to mean a permutation or probability distribution but now i just deal with it

distortion park
Apr 25, 2011


it's up to you when you write your maths thing to choose symbols and define them properly when you are describing what is happening. normally this works pretty well

gonadic io
Feb 16, 2011

>>=
the worst abuse of notation i've ever seen is when talking about n-spheres.

so a sphere in n+1 dimensions is called sn i.e. a normal sphere is S2. no it doesn't really make any sense but whatever, deal with it.

the function to turn a sphere into its higher dimension (there's various ways including projection or suspension or whatever) was labelled S.

therefore, Sn+1 := SSn

gonadic io fucked around with this message at 22:45 on Feb 8, 2014

FamDav
Mar 29, 2008
well the dimension of a sphere being one less is because the sphere is a particular n-dimensional object embedded in an n+1 space.

a ball is a n dimensional object in an n dimensional space.

funroll loops
Feb 6, 2007
CAPSISSTUCK

AlsoD posted:

the worst abuse of notation i've ever seen is when talking about n-spheres.

so a sphere in n+1 dimensions is called sn i.e. a normal sphere is S2. no it doesn't really make any sense but whatever, deal with it.

the function to turn a sphere into its higher dimension (there's various ways including projection or suspension or whatever) was labelled S.

therefore, Sn+1 := SSn

88^n hitler sphere, zeigheil

Notorious b.s.d.
Jan 25, 2003

by Reene

Malcolm XML posted:

lmao

"I don't like syntax foolery so i will advocate for the language that has the most powerful syntax fooling system known: macros"

ever stared at the loop macro? i will take %%@= over that any day of the week

the implementation of the loop macro will make you cry blood

consumption of the loop macro in your own code is really pretty ok to both read and write. (edit: i say this but i have literally never found myself wanting to use 'loop' in code i wrote myself)

Suspicious Dish
Sep 24, 2011

2020 is the year of linux on the desktop, bro
Fun Shoe
(loop repeat 5 for x = 0 then y for y = 1 then (+ x y) collect y)

Suspicious Dish
Sep 24, 2011

2020 is the year of linux on the desktop, bro
Fun Shoe
how is that any more readable than cencenpattis

Notorious b.s.d.
Jan 25, 2003

by Reene

Suspicious Dish posted:

how is that any more readable than cencenpattis

really?

if you have to ask, you don't deserve an answer

Suspicious Dish
Sep 24, 2011

2020 is the year of linux on the desktop, bro
Fun Shoe

AlsoD posted:

VVVV: ok i'll concede % being "cen" but = is "eek" so ~ can be "is"

jesus if you want to say something please post, don't make me look for random replies you made

the answer is it was a joke on hoon

http://www.urbit.org/doc/2013/11/18/ch7/

heres a json parser in hoon

code:
++ poja
  |= jas=tape
  =< (scan jas valu)
  |%
    ++ valu :: JSON value
      %+ knee *jval |. ~+
      ;~ pfix spac
        ;~ pose
          (cold ~ (jest 'null'))
          (jify %b bool)
          (jify %s stri)
          (cook |=(s=tape [%n p=(rap 3 s)]) numb)
          abox
          obox
        ==
      ==
    :: JSON arrays
    ++ arra (ifix [sel (ws ser)] (more (ws com) valu))
    ++ abox (cook |=(elts=(list jval) [%a p=elts]) arra)
    :: JSON objects
    ++ pair ;~((comp |=([k=@ta v=jval] [k v])) ;~(sfix (ws stri) (ws col)) valu)
    ++ obje (ifix [(ws kel) (ws ker)] (more (ws com) pair))
    ++ obox (cook |=(s=(list ,[@ta jval]) [%o p=(mo s)]) obje)
    :: JSON booleans
    ++ bool ;~(pose (cold & (jest 'true')) (cold | (jest 'false')))
    :: JSON strings
    ++ stri
      (cook |=(s=(list ,@) (rap 3 s)) (ifix [doq doq] (star jcha)))
    ++ jcha :: character in string
      ;~ pose
        esca
        ;~ pose
          :: Non-escape string characters
          (shim 32 33)
          (shim 35 91)
          (shim 93 126)
          (shim 128 255)
        ==
      ==
    ++ esca :: Escaped character
      ;~ pfix bas
        ;~ pose
          doq
          fas
          soq
          bas
          (cold 8 (just 'b'))
          (cold 9 (just 't'))
          (cold 10 (just 'n'))
          (cold 12 (just 'f'))
          (cold 13 (just 'r'))
          ;~(pfix (just 'u') (cook tuft qix:ab)) :: Convert 4-digit hex to UTF-8
        ==
      ==
    :: JSON numbers
    ++ numb
      ;~ (comp twel)
        (mayb (piec hep))
        ;~ pose
          (piec (just '0'))
          ;~((comp twel) (piec (shim '1' '9')) digs)
        ==
        (mayb frac)
        (mayb expo)
      ==
    ++ digs (star (shim '0' '9'))
    ++ expo :: Exponent part
      ;~ (comp twel)
        (piec (mask "eE"))
        (mayb (piec (mask "+-")))
        digs
      ==
    ++ frac :: Fractional part
      ;~ (comp twel)
        (piec dot)
        digs
      ==
    :: whitespace
    ++ spac (star (mask [`@`9 `@`10 `@`13 ' ' ~]))
    ++ ws |*(sef=_rule ;~(pfix spac sef))
    :: plumbing
    ++ jify |*([t=@ta r=_rule] (cook |*([v=*] [t p=v]) r))
    ++ mayb |*(bus=_rule ;~(pose bus (easy "")))
    ++ twel |=([a=tape b=tape] (weld a b))
    ++ piec
    |* bus=_rule
    (cook |=(a=@ [a ~]) bus)
  --

Suspicious Dish
Sep 24, 2011

2020 is the year of linux on the desktop, bro
Fun Shoe

Notorious b.s.d. posted:

really?

if you have to ask, you don't deserve an answer

its english words but it still doesnt make any sense. tell me what that does without running it.

Suspicious Dish
Sep 24, 2011

2020 is the year of linux on the desktop, bro
Fun Shoe
or, even, let's try easy mode: tell what it outputs without running it

Notorious b.s.d.
Jan 25, 2003

by Reene

Suspicious Dish posted:

its english words but it still doesnt make any sense. tell me what that does without running it.

i have no idea

but by virtue of it being english words, i'm gonna have a lot easier time looking for the documentation, discussing the problem with others, and explaining the solution when/if i find it

it's possible to write hideous code with sane syntax, no one is debating that

Notorious b.s.d.
Jan 25, 2003

by Reene
reminder: defending operator overloading is defending this
code:
(^^~) (^^=) (^~) (^=) (<<>=)
(^!!) (^!?) (^!) (^?!) (^?) 
(^..) (^.) (^@!!) (^@!?) (^@!) 
(^@?!) (^@?) (^@..) (^@.) (^#) 
(||~) (||=) (-~) (-=) (?~) 
(?=) (??) (//~) (//=) (.~) 
(.=) (*~) (*=) (**~) (**=) 
(#~) (#=) (#) (#%~) (#%=) 
(#%%~) (#%%=) (%~) (%=) (%@~) 
(%@=) (%%~) (%%=) (%%@~) (%%@=) 
(+~) (+=) (&) (&&~) (&&=) 
:> (|>) (.>) :>> (<^^~) 
(<^^=) (<^~) (<^=) (<~) (<||~) 
(<||=) (<|) (<-~) (<-=) (<?~) 
(<?=) (<//~) (<//=) (<.~) (<.=) 
(<.) (<*~) (<*=) (<**~) (<**=) 
(<#~) (<#=) (<#%~) (<#%=) (<%~) 
(<%=) (<%@~) (<%@=) (<+~) (<+=) 
(<&&~) (<&&=) (<&>) (<.>) (<>~) 
(<>=) (<<~) (<<.~) (<<.=) (<<%~) 
(<<%=) (<<>~) 

Notorious b.s.d.
Jan 25, 2003

by Reene

Suspicious Dish posted:

jesus if you want to say something please post, don't make me look for random replies you made

the answer is it was a joke on hoon

http://www.urbit.org/doc/2013/11/18/ch7/

heres a json parser in hoon

eheheh hoon. fun fact: hoon/urbit/nock are all written by mencius moldbug, the self-described "reactionary" and "jacobite" who believes that all political power should be surrendered to a corporation whose shareholders are the landed gentry

the libertarian nutjobs out there suspect that the purpose of the project is to escape un-trustworthy compute platforms touched by the evil government:

http://www.popehat.com/2013/12/06/nock-hoon-etc-for-non-vulcans-why-urbit-matters/

Notorious b.s.d.
Jan 25, 2003

by Reene
the first neoreactionary functional programming language to enjoin jacobite politics as-a-platform

in urbit, hoon virtualizes you

nock your way to will to power

Suspicious Dish
Sep 24, 2011

2020 is the year of linux on the desktop, bro
Fun Shoe

Notorious b.s.d. posted:

i have no idea

but by virtue of it being english words, i'm gonna have a lot easier time looking for the documentation, discussing the problem with others, and explaining the solution when/if i find it

it's possible to write hideous code with sane syntax, no one is debating that

I don't take such an extremist attitude. I think the loop syntax is insane, whereas I don't think anybody has trouble explaining "a + b" to a friend. Yes, it's a bit silly you can't use English words for operators, but I don't think

(loop repeat 5 for x = 0 then y for y = 1 then (+ x y) collect y)

should be held up as an example of something you want to emulate. Even knowing that macro, I'm wondering to myself, is the "x" loop the outer one or is the "y" loop the outer one? Is "repeat 5" for x or y? Without the breaks in the syntax, it's hard to parse.

Notorious b.s.d.
Jan 25, 2003

by Reene

Suspicious Dish posted:

I don't take such an extremist attitude. I think the loop syntax is insane, whereas I don't think anybody has trouble explaining "a + b" to a friend. Yes, it's a bit silly you can't use English words for operators, but I don't think

(loop repeat 5 for x = 0 then y for y = 1 then (+ x y) collect y)

should be held up as an example of something you want to emulate. Even knowing that macro, I'm wondering to myself, is the "x" loop the outer one or is the "y" loop the outer one? Is "repeat 5" for x or y? Without the breaks in the syntax, it's hard to parse.

let me turn this around for you.

leaving the 'loop' implementation exactly the same, do you consider this an improvement?

code:
(#%%~ ^@!? 5 ^. x = 0 <<.= y ^. y = 1 <<.= (+ x y) %@~ y)
each of these is a real operator from that haskell library.

did moving to arbitrary non-words improve or hurt the readability of a perverse mis-use of a macro that neither of us likes?

gonadic io
Feb 16, 2011

>>=

Notorious b.s.d. posted:

reminder: defending operator overloading is defending this

reminder: 90% of these are a normal haskell function with:
- possibly '<' in front of it (returns the value before applying the function)
- the infix function name itself
- possibly '@' (indexed)
- then either ~ (is a normal function lens) or = (is a lens affecting the state) after it

sure <<>~ looks like a tampon but <> is great.

how is this really that different from all of printf's operators? "%+-6.6f\n" is fine right you just have to know the spec or have it in front of you

Notorious b.s.d.
Jan 25, 2003

by Reene

AlsoD posted:

how is this really that different from all of printf's operators? "%+-6.6f\n" is fine right you just have to know the spec or have it in front of you

printf is also eye-blisteringly awful

before you ask, i think it should be replaced with a builder pattern that uses english words

Notorious b.s.d.
Jan 25, 2003

by Reene

AlsoD posted:

reminder: 90% of these are a normal haskell function with:
- possibly '<' in front of it (returns the value before applying the function)
- the infix function name itself
- possibly '@' (indexed)
- then either ~ (is a normal function lens) or = (is a lens affecting the state) after it

sure <<>~ looks like a tampon but <> is great.

so because the rest of haskell is loving terrible, the abortions in the lens library are supposed to get a free pass?

Deus Rex
Mar 5, 2005

Notorious b.s.d. posted:

printf is also eye-blisteringly awful

before you ask, i think it should be replaced with a builder pattern that uses english words

oh, nice, like the horror that is trying to write formatted strings to C++ streams :cool:

gonadic io
Feb 16, 2011

>>=
oh i get it, < on front returns the new value while << on front returns the old one so <<<>~ exists too. lol.
code:
(_2 <<>~  [3]) (0, []) -- ([3], (0, [3]))
(_2 <<<>~ [3]) (0, []) -- ([] , (0, [3]))
not convinced i'm ever going to use that

gonadic io fucked around with this message at 01:28 on Feb 9, 2014

Notorious b.s.d.
Jan 25, 2003

by Reene

Deus Rex posted:

oh, nice, like the horror that is trying to write formatted strings to C++ streams :cool:

iostreams has a lot of problems but the builder pattern isn't the root of them

in fact operator overloading is one of the problems with iostreams too. they had a shiny new toy and they were gonna use it, no matter how poorly it fit

weird
Jun 4, 2012

by zen death robot

Suspicious Dish posted:

I don't take such an extremist attitude. I think the loop syntax is insane, whereas I don't think anybody has trouble explaining "a + b" to a friend. Yes, it's a bit silly you can't use English words for operators, but I don't think

(loop repeat 5 for x = 0 then y for y = 1 then (+ x y) collect y)

should be held up as an example of something you want to emulate. Even knowing that macro, I'm wondering to myself, is the "x" loop the outer one or is the "y" loop the outer one? Is "repeat 5" for x or y? Without the breaks in the syntax, it's hard to parse.

if you write it how a normal person would write it:
code:
(loop repeat 5
   for y = 1 then (* y 2)
   collect y)
it isn't hard to follow at all, but even with your obfuscated version I think it's easy to follow what it's doing if you use whitespace
code:
(loop repeat 5
   for x = 0 then y
   for y = 1 then (+ x y)
   collect y)
I'm not sure what's hard to understand about that mechanically

Notorious b.s.d.
Jan 25, 2003

by Reene

VanillaKid posted:

if you write it how a normal person would write it:
code:
(loop repeat 5
   for y = 1 then (* y 2)
   collect y)

the goodness or badness of the loop macro is not the issue at hand anyway.

you can gently caress anything up if you try hard enough, but i still strongly prefer "loop repeat..." to "8==D #%%~..."

Adbot
ADBOT LOVES YOU

gonadic io
Feb 16, 2011

>>=
let's look at some real code, some of the worst examples from my game (well i call it that, it's barely at the stage where it's interactive)

code:
actions :: Float -> [(Key, State -> State)]
actions dt =
    [ (Char 'w', viewPort.vpTranslate._2 -~ 5  *dt)
    , (Char 's', viewPort.vpTranslate._2 +~ 5  *dt)
    , (Char 'a', viewPort.vpTranslate._1 +~ 5  *dt)
    , (Char 'd', viewPort.vpTranslate._1 -~ 5  *dt)
    , (Char '-', viewPort.vpScale        *~ 1-1*dt)
    , (Char '=', viewPort.vpScale        *~ 1+1*dt)
    , (Char 'r', const initialState)
    , (MouseButton LeftButton , setSelection      )
    , (MouseButton RightButton, moveSelectedPlayer)
    ]
"viewPort.vpTranslate._2" delves into a structure and then i modify its value using +,- or *. simple.

code:
handleInput :: Event -> State -> State
handleInput (EventKey k keyState _ _) s = s &
     keysDown . contains k .~ (keyState == Down)
in the field keysDown which is a set that contains the element k if the keyState is down

code:
handleInput (EventMotion xy) s = s &
    mouseOver ?~ invertViewPort (_viewPort s) xy
?~ is like .~ for a Maybe field i.e. (l ?~ x) is (l .~ (Just x))

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