This behaviour happens with file handles also:
Applying the handle to data appends it to the file as bytes.
Applying the neg
of the handle to char data appends it as text. The result of a successful operation is the positive or negative handle.
File system | Basics | kdb+ and q documentation – Kdb+ and q documentation (kx.com)
As to why I am not sure. The choice could have been made to return a generic null (::) instead possibly.
For stdout and stderr it can feel strange at first but it is not printing ‘hello1’ in one go. Instead ‘hello’ is printed as you requested then as you are in an interactive session the q) prompt wants to display the returned object so it then prints ‘1’.
q)1"hello"; //The ; stops the q) prompt from printing the returned object '1' hello
q)
q)-1"hello"; //-1 is often more useful as it includes a n newline char hello