Hacker News new | past | comments | ask | show | jobs | submit login

Maybe your use of quotes is to make fun of the article, but in any case, I'll say this: I disagree it is a bug, rather it is a shortcoming of a minifier that it does not preserve the semantics of the input program.

Since this shortcoming is hard or impossible to overcome completely, case-specific post-processors to help out the minifier sound reasonable to me.




I think it's simply a flawed design to use reflection to read function parameter names and then use that information to apply semantics. I think parameter naming is something that shouldn't directly be semantic, as that's what most developers except. If, for example, I'm supplying a callback function to a library, I don't except the library to read the parameter names and then do stuff differently depending on the variable naming I happened to use.

I think your point about the minifier being "broken" is a good one, but the real problem is with AngularJS in my opinion.


Isn't this exactly what Active Record in Rails does?


No, ActiveRecord never looks at argument names. (unless you're talking about Ruby's named parameters, which is nothing like Angular's DI and not AR-specific)


What I meant is db tables and field names get converted into ruby class names and properties/methods. This is basically convention over configuration. It's the same with angular.


I agree, it's flawed design and a crutch that comes about due to the lack of a better type system. But the cited reason (that it doesn't work with a minifier) is bogus.


The way you spell your parameters does not fall under the "semantics of the input program". That is purely syntax, and it should have no bearing on the execution of the program.

This shortcoming is easy and possible to avoid in the first place, totally eliminating the need for case-specific post-processors to help out the minifier.

Some advice: next time you design a framework, how about designing it not to require case-specific post-processors from the start? Then you won't end up with so many shortcomings that are hard or impossible to overcome completely.


Actually the naming of parameters do have meaning in many programming languages and changing a name of a parameter is there considered a breaking change. In both Python and c# you can call a function like foo(bar=4), where bar is the parameter name. Whats interesting here is also that python is dynamic and c# staticically compiled. Automatic mapping of functions to xmlrpc or other serializing would be another example.

I'd say that angulars behavior here is very unexpected, by mapping parameter names to registered controllers, but I'm not sure if the minifier can be said to be incorrect. If javascript has a way to get the names of the parameters, is it then incorrect to assume this can be used? Strictly speaking if you want to conform fully almost nothing can be minified since object==dictionary but you have to draw the line somewhere, maybe parameter names are moving over that line.


> The way you spell your parameters does not fall under the "semantics of the input program". That is purely syntax, and it should have no bearing on the execution of the program.

I agree that identifier names should not matter for semantics, but it's quite possible to write JS (and other language) programs that do. So, your first sentence is simply incorrect, it is part of the semantics.

So yes, it's not best practices to do this, but it's not exactly "insane". Constraining your design on non-semantic-preserving minifiers is not the answer.

Also: In your last sentence, like in the linked article, it sounds like you and the author are under the belief that framework/api design is easy - and anyone who gets it wrong is an idiot.




Join us for AI Startup School this June 16-17 in San Francisco!

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: