3 ms·
This is has been a popular topic for decades and I feel like most people get two fundamentals always twisted. Syntax and semantics. Syntax != Semantics. Code r
by vrnvu 4y ago
This is has been a popular topic for decades and I feel like most people get two fundamentals always twisted. Syntax and semantics. Syntax != Semantics.
Code readability = syntax that make semantics obvious.
If a block of code is written in an imperative style or functional style doesn't matter. Ask yourself instead, are the semantics clear? Are we coping or moving the values? Are we cloning the references? Are we iterating over mutable references or copies of the value?
A good language, with good code readability, makes semantics obvious. A good programmer, encourages good readability. With good readability we don't have doubts about what a piece of code is doing.
- ge96 4y ago> imperative style or functional style doesn't matter. Semi-related, can you have something like Haskell that seems hard to "read" eg. () :: -> but written in something easier to read like C++. Idk maybe I'll get used to it like the transition from old JS functions to arrow funcs
- anko 4y agoThis is a really good comment, and I hadn't really thought of it in those terms. So it's insightful to me. It encapsulates a lot of things I hadn't really directly tried to answer before. My previous answer is that good code makes it easy to discover intent. But I think the semantics are important too - for example in scala we use monad transformers to treat futures (async code) much like lists. But the problem with this approach is it's not clear without inspecting the type signature if you're doing something that has a high algorithmic complexity eg. spawning threads or not. I think the best language i've ever read for semantics is elixir. But i think the lack of static typing makes it harder to code review, especially on github. Maybe Gleam is the answer? What language do you like?