> In nim it is also true that strings are just lists of chars, but for some reason the compiler will not allow you to treat it as such!
That's actually a feature - Nim is designed to be a type safe[0] language. Type safety has a number of advantages:
- Compile-time checks: Type system catches many potential issues and silly bugs early at compile time.
- API discoverability: IDEs and other tools can provide better autocompletion and type hints because they know exactly what operations are available on a string.
Nim tries to strike a balance between flexibility and type safety. Instead of having strict restrictions, you have explicit control with slightly more verbose code. For example, if you want to treat a string as an array, you can use the `openarray` type (`openarray` is a special type that acts as interface to all array-like types and is supported by most of stdlib): var hello = "Hello, World"
proc foo(s: seq[char]): bool = discard
proc bar(s: openarray[char]): bool = discard
echo foo(hello) # this doesn't compile because string != seq[char]
echo bar(hello) # this compiles because openarray[char] is compatible with string / seq[char] / etc..
[0] - https://en.wikipedia.org/wiki/Type_safety