All about static type security - at compile time we can know the type of expression. With a literal, the compiler can correctly say that if it can be converted to bytes. In byte a = 20 , 20 is convertible, so everything goes through a fine. byte a = 257 will not work (cannot convert 257).
In the case of byte b = a , we already know that a is a byte, so type safety is guaranteed. b = 100 is excellent again (it is statically known that 100 is convertible).
In b = a + 100 not known statically if a + 100 is a byte. a can contain 200, so a + 100 not represented as a byte. Therefore, the compiler forces you to say βYes, a + 100 always bytesβ through the cast, turning to your higher level knowledge.
Some types of more complex type systems do not suffer from this problem, but come with their own problems that most programmers will not like.
source share