In the first case, any sane static language will use type inference, so you won't have to write out "int foo", just "let foo" or equivalent. (I'd also argue that any sane static language would disallow or at least heavily discourage mutable variables, but that's neither here nor here).
The second case is easily handled by static languages, for example, in Swift:
var mydata = ["foo": Dictionary<String, MyObject>()]
mydata["foo"]["bar"] = MyObject()
This is only longer than it needs to be because of using two lines, you wouldn't need the explicit declaration to do it in one:
Comments
In the first case, any sane static language will use type inference, so you won't have to write out "int foo", just "let foo" or equivalent. (I'd also argue that any sane static language would disallow or at least heavily discourage mutable variables, but that's neither here nor here).
The second case is easily handled by static languages, for example, in Swift:
This is only longer than it needs to be because of using two lines, you wouldn't need the explicit declaration to do it in one: This also gets rid of mutable state!