Code Monkey home page Code Monkey logo

Comments (6)

karellm avatar karellm commented on August 15, 2024

I've learned CS quite recently and I'm amazed by little details that really improve javascript as a language. Though, I tend to really despise the generated code and I feel I lose control over my code at the end.

This article is the perfect exemple (thanks for sharing). Plus, I finally don't really like the syntax (never liked indentation based languages). Granted the code is short, but at the same time quite unreadable. When I look at some Chaplin files, it is quite obscur where a statement end. For exemple, bla: -> is quite a confusing way to create an empty function.

@molily How do you personally feel about coffeescript?

from chaplin.

paulmillr avatar paulmillr commented on August 15, 2024

If you'll be cleaning up the stuff coffee shits, I recommend using return instead of plain undefineds, because it's used in js.

from chaplin.

molily avatar molily commented on August 15, 2024

@karellm: Like any programming language, CoffeeScript itself is dumb and inefficient in its generality. When writing Chaplin I had a look on the compiled code most of the time. I didn’t use some of CoffeeScript’s features even when they could be used because they might get compiled to inefficient, overly complex and incomprehensible code.

Using CS is surely a tradeoff, it has its downsides. But in total it’s easier to write decent CoffeeScript code then consistent, performant and safe JavaScript code. CS gives you strict mode per default and enforces rules you would need to check with ugly tools like JSHint instead.

Currently I don’ have an issue with the generated JS code. Some things are superflous like IIFEs, return statements, list comprehensions. But they do not impair the performance significantly. Probably three or four kilobytes could be saved if we switched to bare JavaScript and try to optimize by hand. After minification and compression, this is probably half a kilobyte. So it’s not a priority for me at the moment. I doubt that the code would be more readable in the end. Many people praised the readable code of Chaplin, only a few were scared off because it’s mainly written in CS.

from chaplin.

karellm avatar karellm commented on August 15, 2024

@paulmillr I like that idea better. I would even make sure that empty function return.

@molily Makes sense. Beside performance, I guess my main issue really is the readability. I tend to like curly braces :)

from chaplin.

paulmillr avatar paulmillr commented on August 15, 2024

Can this be closed now?

from chaplin.

molily avatar molily commented on August 15, 2024

Fot the time being, yes. In the long term I’d like to define the return values of all methods more explicitly. At the moment, most return values are quite random because we’re relying on implicit returns. Basically, all methods which do not have a meaningful return value should return undefined in the end. At least in my humble opinion.

from chaplin.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.