Hacker News new | ask | show | jobs
by giacomocava 464 days ago
All the pain to get echo working was 100% worth it! What a great release
2 comments

Thinking back on how Python 3 broke nearly all existing Python beginner code because they made print a function instead of a statement feels ironic now.

Sure print being a function has slight benefits in certain cases but the Gleam team also makes very compelling arguments to implement echo as a special keyword.

So what do we learn from that? Maybe don't do breaking changes to your language. Maybe debugging and actually printing should be separate things, one a statement, the other a function? I don't know.

I don’t know enough about Gleam’s implementation to say how applicable this is, but from a more general language design perspective… a keyword isn’t inherently imbued with special capabilities that a function call wouldn’t be. They’re semantically interchangeable for this use case, if the function can access requisite information about the underlying stack.

I’m not sure it’s possible to extrapolate any lessons for Python from this Gleam language feature or the chosen syntax.

That's the problem though: I think the thing that makes functions functions it that they operate on values alone (whatever “value” means in the context of the language — but it almost certainly doesn't include code or AST or anything like that), and don't care about, or even get to see, the particular expression that produced a given value. The thing that makes statements (or macros, or various other compile-time stuff) not-functions is that they don't just have access to values, but to the code as well, which lets them do stuff like print the expression that produced a value, which a function could never do (in most languages; I'm sure there are some out there, maybe a LISP or something, that attach the AST to expressions as metadata).
Right, and that strict definition of “function” is especially important in a language like Gleam. It may be less so in a language like Python where “function” is a much more malleable concept already. All the more reason I don’t think one could reasonably extrapolate lessons about the latter from syntax design decisions in the former.
As a dyed-in-the-wool print debugging advocate, and a Gleam-curious Erlang/BEAM enthusiast, this is very interesting for me.

Thanks for all your work, great to see how well the language and tooling are maturing.

print debugging is the best debugging <3 Thank you for the kind comment!!
Nah it's just the easiest and most reliable way. Usually anyway; sometimes you have extreme timing or space constraints and can't even use that. On microcontrollers I sometimes have to resort to GPIO debug outputs and I've worked on USB audio drivers where printf isn't an option.
hello fellow print debugging enjoyer, rejoice!
Indeed, for me, the IDE debuggers became useless when we started writing multi threaded programs.

Printf is the only way to reliably debug multi threaded programs.