3 ms·
It is a part of the language rules that you can't ever change if you don't want it. It is magic in that sense.
by lifthrasiir 2y ago
It is a part of the language rules that you can't ever change if you don't want it. It is magic in that sense.
- mariusor 2y agoI always thought that lack of "magic" in a programming language means that when (as a human) you read through source code you are able to reach the end of the program. Opposite to that, in a language that has "magic" you reach a point where you don't know where execution will go next without the help of the compiler (or a heavy duty IDE that translates for you).
- lifthrasiir 2y agoThat's very subjective I guess, because it would also depend on your familiarity with the subject matter. I can for example easily read and understand a recursive descent parser in any language because I have implemented it multiple times and can catch a common pattern. Unless the language in question corrupts that pattern (highly unlikely unless it's an esolang :-), that definition of "magic" should be largely independent from the language itself.
- mariusor 2y agoIt's not about understanding the language, it's about how an element in the code can mean different things. Think how in Ruby you can get monkey patched behaviour that overwrites a method name for some type, or even the init() function in Go, that someone mentioned in the sibling comments that gets executed at module load, so when you encounter state that should be a zero value, it's actually not. If as a developer reading the code, there's no way to know if the compiler injects some behaviour in or around the thing that you're looking at, that's magic.
- yencabulator 2y agoYou also can't change the if statement, is that now magic too?
- lifthrasiir 2y agoYes, that's why I needed "in that sense". As noted in replies, I believe many naive notions of magic really depend on one's background and context.