简体   繁体   中英

Are CoffeeScript servers not as reliable as Node.js servers?

I took the code for my Node.js server and converted it to CoffeeScript, then I tried it on Heroku. It crashes when it receives a long JSON string, whereas the original version handles it without any problem. Is this normal?

I'd say writing in CoffeeScript is (potentially) much more reliable than writing pure JavaScript.

From CoffeeScript's documentation :

CoffeeScript:

zip = lottery.drawWinner?().address?.zipcode

Generated JavaScript:

var zip, _ref;

zip = typeof lottery.drawWinner === "function" ? 
      (_ref = lottery.drawWinner().address) != null ? 
      _ref.zipcode : void 0 : void 0;

I don't know about you, but I usually forget to check the type against function , or otherwise am too lazy to consider null or undefined . Besides, it makes JavaScript code much uglier and harder to read and maintain.

It's certainly a bug in you poring your app. Make sure you understand and exploit what do(i){} , for key, value of hash , for item,index in array . Explicitly return at the end of functions, and double check variable scopes. I'm sure you'll find that it was a bug in your port (as did I, a few weeks back).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM