18
dstm
2y

Saw this today in the exercise code of a deep learning lecture. These people are doing their PhDs in deep learning 😳

* the snippet has no side effects

Comments
  • 5
    I'm annoyed. Fucking abbreviations.

    The waste bin feels offended by the offering it it was printed and thrown away...
  • 8
    6 lines and an extra variable what could directly be done in 2 lines 😕
  • 4
    @cafecortado worst thing is that they put the clear form in the comment. So the extra code is bloody more confusing than the 2 liner.

    #FIXME: come up with better variable names
    fxph = f(x+h)
    fxmh = f(x-h)
  • 0
    Which uni?
  • 0
    Wait this is what they taught you in university?
  • 0
    nm. what am I not noticing ?
  • 0
    its the extra variables isn't it ?

    they could just do a f( x+h) and f(x-h) eh ?
  • 2
    @AvatarOfKaine That... Plus the naming.

    f(x) is a function call.

    I dunno what they want to achieve by writing code with such unclear meaning, but it is a bad idea TM
  • 0
    @IntrusionCM the way its written at first i thought they just skipped the +/- h

    all over again.

    say all over again for me.

    say i am still here.
  • 1
    @AvatarOfKaine Yeah... The way the code is written obfuscates it's meaning.

    It's completely unclear by the way way oldval was introduced at all.
  • 1
    Side effect free programming at home:
  • 1
    @12bitfloat yeah and storing/reverting it is the worst way to do this. I hope that it's not used in a parallel environment.

    No side effects is reached by copying (ideally by passing as non ref argument) and using the copy for the remainder of the context.
    When no changes to data can be made it's clear and guaranteed to have no side effects.
  • 1
    The fact that these people probably make like twice my wage...
  • 0
    Clearly mathematicians not programmers.
Add Comment