You are missing the memory representation !
'a array
is a polymorphic type. This means that each array slot has a pointer to the actual 'a
value.
So a char array
is an array filled with pointers to individual characters. That’s neither efficient, nor what most system IO APIs expect.
A bytes
value is a contiguous sequence of bytes in memory.
In ascii-art terms for the string “abc” (not exactly see my correction below):
+---+---+---+
| . | . | . |
+-|-+-|-+-|-+
v v v
a b c
vs
+---+---+---+
| a | b | c |
+---+---+---+