简体   繁体   English

CoffeeScript服务器不如Node.js服务器可靠吗?

[英]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. 我将Node.js服务器的代码转换为CoffeeScript,然后在Heroku上进行了尝试。 It crashes when it receives a long JSON string, whereas the original version handles it without any problem. 收到长JSON字符串时,它会崩溃,而原始版本会毫无问题地处理它。 Is this normal? 这正常吗?

I'd say writing in CoffeeScript is (potentially) much more reliable than writing pure JavaScript. 我说书面的CoffeeScript是(潜在的)可靠得多比写纯JavaScript。

From CoffeeScript's documentation : CoffeeScript的文档中

CoffeeScript: CoffeeScript的:

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

Generated JavaScript: 生成的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 . 我对您一无所知,但是我通常会忘记根据function检查类型,否则我就懒得考虑nullundefined Besides, it makes JavaScript code much uglier and harder to read and maintain. 此外,它使JavaScript代码更难看,更难以阅读和维护。

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 . 确保了解并利用do(i){} ,即for key, value of hashfor item,index in array Explicitly return at the end of functions, and double check variable scopes. 在函数末尾显式return ,并仔细检查变量范围。 I'm sure you'll find that it was a bug in your port (as did I, a few weeks back). 我相信您会发现它是您端口中的错误(几周前我也是如此)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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