It ain’t what you think it’s the language that you think in

<p>A few weeks ago I was talking to&nbsp;<a href="https://www.linkedin.com/in/wardeio/" rel="noopener ugc nofollow" target="_blank">Michal</a>, who is a Lead Security Engineer over at&nbsp;<a href="https://resonance.security/" rel="noopener ugc nofollow" target="_blank">Resonance Security</a>. We were planning to discuss cross-chain issues, but as is always the case, the conversation meandered off into different fields, mostly concerning how the programming language you use shapes your view of the world.</p> <h1>Theory of mind</h1> <p>There is a theory of mind based on language with a name that sounds like it came straight out of Star Trek.</p> <p>The Sapir-Whorf hypothesis.</p> <p>Simply put, it proposes that the grammar and vocabulary of the language we think in, and the society that we live in and which spawned that language, profoundly influence the way we interpret the world around us. Together, both frame and limit what we are able to mentally conjecture about.</p> <blockquote> <p>&ldquo;We cut nature up, organize it into concepts, and ascribe significances as we do, largely because we are parties to an agreement to organize it in this way &mdash; an agreement that holds throughout our speech community and is codified in the patterns of our language.&rdquo;<br /> &mdash; Benjamin Lee Whorf [1]</p> </blockquote> <p>Wittgenstein, arguably the foremost philosopher of the 20th century (that is to say, his friends and colleagues argued that he was the foremost philosopher of the 20th century), put in a few simple albeit somewhat inscrutable words:</p> <blockquote> <p>If a lion could speak, we could not understand him<br /> &mdash; Ludwig Wittgenstein [2]</p> </blockquote> <p>Nobody truly understands Wittgenstein though, possibly because he thought in an Austrian version of the German language, and then translated his thoughts into English.</p> <h1>function thoughts(language) { &hellip;</h1> <p>The thing that springs to the mind of any inquisitive software developer reading about these kinds of things is to wonder, &ldquo;Does the programming language I choose to program in significantly affect the way I think about the tasks at hand? Am I restricting myself by only writing in C++?&rdquo;</p> <p>(The answer to both those questions is, &ldquo;Probably, yes.&rdquo;)</p> <p>You wouldn&rsquo;t be the first to have such thoughts. Here&rsquo;s what Paul Graham said about it, a couple of decades ago:</p> <blockquote> <p>&ldquo;[programmers are] satisfied with with whatever language they happen to use, because it dictates the way they think about programs&rdquo;<br /> &mdash; Paul Graham [3]</p> </blockquote> <p>But it&rsquo;s not just programmers who are affected by this.</p> <p>If you are a test engineer or an auditor, and you are reviewing smart contracts, the problem of programming language dissonance can be especially acute. You may be using one language, say, JavaScript, to write tests for smart contracts written in another language, for example, Solidity.</p> <p>This involves exhausting context switching as you shift your focus from one programming language to another, and tired test engineers are always tempted to cut corners. Worse still, it can restrict your thought patterns and cause you to miss some significant areas of testing.</p> <h1>The imperative mood</h1> <p>JavaScript and Solidity are syntactically not that different. They are both imperative languages &mdash; abstractions of assembly language. And their syntax is very similar; it&rsquo;s like comparing Spanish to Italian. But there are some notable problems. For example, when passing a value from JavaScript to a Solidity smart contract using Hardhat, you are often going to rely on your framework implicitly converting a JavaScript string to Solidity bytes. The behind-the-scenes conversion can cause bugs to slip through the cracks of your test coverage.</p> <p><a href="https://kf106.medium.com/it-aint-what-you-think-it-s-the-language-that-you-think-in-417a217e2ff0">Visit Now</a></p>
Tags: mood Language