News for hackers. Stuff that matters.
Re:Software Engineering principles to make teams better by CodeMage on Wednesday June 30, 2021 @05:44PM (#27693735)
This was the first time I've encountered the mention of "referential transparency", so I looked it up and went down a deep rabbit hole. It seems that it's normally used to describe the property of not having side effects, however, I also found this long explanation on Stack Overflow: https://stackoverflow.com/a/9859966/58099

So now I'm more confused than when I initially read your comment. Do you mean "referential transparency" as in "expressions without side effects" or do you mean it in some other way that I don't understand yet?

Re:Software Engineering principles to make teams better by akiselev on Wednesday June 30, 2021 @10:42PM (#27695793)
It's more subtle than than "no side effects". Take Python prior to version 3, for example, which made possible the most egregious violation of referential transparency I've ever seen: `True, False = False, True`

Python code (pre-v3) that branches cannot be referentially transparent by definition because runtime context (the state of True/False bindings) is a hidden input in every boolean expression. You could have millions of lines of side effect free code and it will break completely if that one statement is run before the rest of the code.

Programmers depend on the referential transparency of keywords like "true", "false", "for", etc whether they're writing pure functional code or imperative spaghetti messes.

Re:Software Engineering principles to make teams better by macintux on Wednesday June 30, 2021 @05:49PM (#27693783)
I just mean it in the sense of functions without side effects on data in the program (I’m not fussed about I/O).
Re:Software Engineering principles to make teams better by naiwenwt on Wednesday June 30, 2021 @07:19PM (#27694671)
In this particular case do you just mean pure functions then?
Re:Software Engineering principles to make teams better by macintux on Wednesday June 30, 2021 @07:21PM (#27694685)
Sure. I’ll be honest, the distinctions are challenging to me.