Output to Console in Bnlang

The simplest way to write to the terminal is the built-in print function — it accepts any number of arguments, separates them with spaces, and adds a trailing newline. For anything beyond a quick script, reach for the log library, which adds severity levels and a configurable sink.


print("Hello, World!");
print("user:", "Alice", "age:", 25);
print(1 + 2 + 3);

print and লিখুন are aliases for the same built-in — pick whichever reads better to you. There's no separate printf; build the string yourself with + or pass multiple arguments.


The log Library — Levels and Structure

For real programs you want severity (info vs warning vs error), timestamps, and a single place to redirect output. The log library handles all three.

import "log" as log;

log.info("server starting");
log.warn("port", 3000, "already in use, falling back");
log.error("could not bind, exiting");

Writing to stderr

print writes to standard output. Errors usually belong on stderr so they aren't captured into your data pipeline. Use sys.write_err:

import "sys" as sys;

sys.write_err("something went wrong\n");

Best Practices

  • Use print freely while prototyping; switch to the log library before deploying.
  • Send anything that isn't program output (warnings, errors, progress) to stderr so callers can pipe stdout cleanly.
  • Don't log secrets — API keys, tokens, passwords — even at debug level.