So is
public var user:Object = {};
user["firstName"] = "Bill";
user["lastName"] = "Cosby";
slower than if I have a value object like User?
var user:User = new User();
user.firstName = "Bill";
user.lastName = "Cosby";
So is
public var user:Object = {};
user["firstName"] = "Bill";
user["lastName"] = "Cosby";
slower than if I have a value object like User?
var user:User = new User();
user.firstName = "Bill";
user.lastName = "Cosby";
More importantly than any speed benefits, strong typing gives you compile-time type checking so you don't typo property names - saving a lot of developer time, which is far more expensive than clock cycles.
Though yes, static typing does carry speed benefits as well.
Simple speed test shows that TypedObject (
User
) is roughly 3-3.5x faster than UntypedObject ({}
), but it's nothing you'd ever notice in the day-to-day. Try out Grant Skinner's Performance Test Harness to run some better/advanced tests :).3 simple trial runs:
Verdict: Typed is faster than Untyped.