Skip to content

Comment on Show HN: a compiler from Python syntax to JavaScript syntax (like CoffeeScript)

Comments

This is a really neat idea, and I'm definitely going to look into this more when I have time, but I have a small nit to pick.

print(...) is a common debugging, or output call in python, and I can see how in many use cases that would translate to console.log in javascript.

However, some browsers don't support console.log, and in serverside javascript, objects like console and window are not available. I don't know of any common output technique that would work in all browsers as well as with node.js and ringo. Depending on how much you care about supporting serverside js and different browsers, this may be a non-issue.

Thanks. I'll change

  pj.transformations.special.Call_print
to have the emitted code check if you've defined a print function, using console.log only if you haven't.
  ((typeof print !== "undefined" && print !== null) || console.log)(...)
AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.