Comments (6)
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.
If you'll be cleaning up the stuff coffee shits, I recommend using return
instead of plain undefined
s, because it's used in js.
from chaplin.
@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.
@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.
Can this be closed now?
from chaplin.
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)
- Access control checks on Controller#beforeAction HOT 3
- Access Control implementation
- View::render - return origin result from wrapped method HOT 5
- noWrap:true doesn't work properly in subviews when top-level element in template is not div HOT 2
- Model not set in Backbone Collection HOT 1
- Backbone 1.2.0 HOT 3
- jQuery#html => setHTML doesn't work in IE11 on win7 HOT 2
- (npm) Update to newer Backbone HOT 4
- itemView with nowrap=true doesn't work when template produces TR HOT 1
- delegate in itemview
- Internet Explorer reload on link with relative URL HOT 1
- Uncaught TypeError: Cannot read property 'undefined' of undefined HOT 8
- CollectionView insert new rows in opposite order to backbone collection models
- Incompatibility upgrading to 1.2.0 from 1.1.1 HOT 3
- Not working Backbone.js link in README.js HOT 1
- New release?
- ListenHash: remove 'model', 'collection' limitation
- Internet Explorer invalid pointer error
- Composer Doc is wrong in regards of `check` method
- Archive the organization
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from chaplin.