Skip to content

Just curious #3

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
josdejong opened this issue Feb 4, 2016 · 5 comments
Closed

Just curious #3

josdejong opened this issue Feb 4, 2016 · 5 comments

Comments

@josdejong
Copy link

Is there some special reason why you use bracket notation this["re"] instead of dot notationthis.re to access properties? I find the latter easier to read.

@infusion
Copy link
Collaborator

infusion commented Feb 4, 2016

Yep, I like the latter also better, but I set these on all the attributes I want to keep as they are, when they run through closure compiler in advanced mode. I started to use the advanced mode for all my projects and so I rename the attributes after finishing a project to the bracket version. This is only a little tradeoff compared to the things closure compiler brings in advanced mode, like function inlining, and code rewriting in a more optical way.

@infusion infusion closed this as completed Feb 4, 2016
@josdejong
Copy link
Author

Ah, does closure compiler mangle the property names too?! hm, that's not nice. I didn't know that

@infusion
Copy link
Collaborator

infusion commented Feb 4, 2016

Yep, closure compiler tries to minimize them (1-2 chars) if they are not getting exported. By using this explicit syntax, you can mark them as an api. It also tries to remove objects at all. For example the P object, you don't like - if the compiler sees this object has constantly 2 attributes, it will make two variables of it (I'm not sure if in the case of P this really happens, but it tries to flatten internal objects)

@josdejong
Copy link
Author

Well, it makes sense of course - mangling internal variable names. But it's not handy debuging in this case, you want to see re and im.

As for P being replaced by two variables - that actually sounds like a good idea - it's just internals and will probably improve performance :D

@infusion
Copy link
Collaborator

infusion commented Feb 4, 2016

I think not performance, as the lookup mechanism of v8 is quite advanced with it's hidden classes. Closure compiler tries to optimize for gzip, meaning building a lot of similar chunks of code, which at the end benefits performance as performance in the web means loading time.

And for debugging: You shouldn't debug your minimized code in the best case ;P

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants