Mentally Manage Dynamic Types

last modified: January 7, 2014

Continued from ValueExistenceProofTwo (was WeakProgrammersRelyOnBadDocumentation)

It's not hard to get confused over dynamic typing because of the horrid writing about it out there.

Speak for yourself.

If you think your writing is clear to most, you are truly delusional.

What does that have to do with what I wrote? You're claiming it's "not hard to get confused over dynamic typing because of the horrid writing about it". That implies that it's easy to get confused about dynamic typing. I see no evidence that this is so; it appears to be nothing more than a personal opinion. If it's nothing more than a personal opinion, then you should make it clear that it's your own opinion, and not necessarily anyone else's. It certainly isn't mine. Whilst I agree that there's a lot of bad documentation, it is no hindrance to understanding popular imperative dynamically-typed programming languages. They are trivially simple. Given the number of programmers successfully writing programs -- including children of single-digit ages successfully programming RaspberryPis and the like -- it seems bad writing is no hindrance to understanding dynamically-typed imperative programming languages.

We've been over this many times already repeatedly and redundantly. It's my personal observation about typical programmers, and apparently it differs from your personal observation about programmers. It's an AnecdoteImpasse. Your life is not the standard reference source for universal truth.

Re: "you should make it clear that it's your own opinion" -- I made it clear it was my personal observation multiple times. If you forgot that and mistook it for an official study due to your forgetfulness, it's not my goddam fault. Get some Reagan meds for it. You seem to be mistaking your lack of memory for lack of existence. On the upside, you don't have to buy new magazines because the same one can be reused every week and always seem fresh to you.

Whilst I can certainly remember the few times you've agreed that it's merely your own observation, and by no means a general condition, it's unlikely the casual WikiReader will assemble your collected unsigned writings into a cohesive statement of your views. Therefore, when you write, "[i]t's not hard to get confused over dynamic typing because of the horrid writing about it out there," it has all the appearances of a statement of truth when it is not.

It's true, I should mark paragraphs with my handle more frequently, ideally, but YOU don't mark either. In fact, you don't even have a fucking handle. Pot. Kettle. Black. A guy without a handle complaining that I don't sign enough, get a load that, people! Stop being a hypocritical dick. I have a lot of reasons to complain about your writing and evidence presentation style, but arguing about arguing gets boring after a while, at least to most of us. Thus, I suggest you not throw rocks from your glass house. Anyone who's been married knows that criticism invites counter criticism and it can flow fast and furious once it gets started. Often it's better to shut up about small things. -t

I'm not complaining about your lack of handle. That's fine. I'm complaining about your assumption that the casual reader should be aware -- despite the lack of handle -- that you "made it clear it was my personal observation multiple times" (see above).

Strange that you don't seem bothered when your OWN writing has the same issue.

Feel free to point out where I have stated personal opinions as generally-accepted facts.

The problem is you THINK they are facts because you mistake your personal head models for universal truths. Pointing them out wouldn't add new complaints nor new material.

I have claimed no universal truths, only emphasised that which is generally accepted. It would appear that the actual problem stems from your mistaken belief that because multiple models may be possible, that all possible models should be equally recognised and accepted.

You didn't justify "generally accepted" (outside of interpreter writers). And I didn't claim all models should be equally accepted: they should be weighed against explicitly stated goals. I gave reasons and justification as detailed as a can for the decisions I made with regard to the tag model, and those decisions closely fit both the goals and the stated assumptions about typical developer WetWare, which I described in as much detail as I can. We just come to a AnecdoteImpasse regarding the WetWare evidence we use.

"Generally accepted" is trivially evidenced by the wealth of computer architecture texts and language documentation that present the same model. Your goals and stated assumptions are bogus; they appear to be constructed solely to sustain an already exceedingly weak argument in favour of your model. It looks like nothing more than an attempt to rationalise your erroneous omission of a valid concept of values.

For compiler/interpreter BUILDER documentation, perhaps they present the "same model". But that's NOT true outside of constructor docs. You seem to be conflating builder docs with user docs. Otherwise, we'd have to consider stacks part of the standard semantics, because they are presented in the same or similar material. And how are the goals "bogus" exactly? It's kind of late to start complaining about my stated goals. And you tossed in the "erroneous" claim as if it was a fact without citations or links. Didn't you just get in my ear about that kind thing? -t

PageAnchor elbow-grease-72

And if non-builder docs indeed do back your model unambiguously, please quote them and show exactly how they uniquely fit your model, word for word. If you don't want to do the elbow work, then shut the hell up and concede the one-and-only-one-semantics claim like an honest, trustworthy scientists would, instead of an ego-driven stubbornite.

See http://docs.python.org/2/reference/ The first sentence is, "This reference manual describes the syntax and 'core semantics' of the language." See http://www.rubyist.net/~slagell/ruby/variables.html "The variables ... have no type." See http://docs.python.org/dev/reference/datamodel.html#objects-values-and-types "An object’s mutability is determined by its type; for instance, numbers, strings and tuples are immutable [...]" Etc.

Probably because the "type" is in the object, which your model also lacks as given. See near "Here's a contradiction between the Python doc" for more on this.

And I've pointed out many times with dynamic languages it's usually easy to "spot fix" specific problems encountered without having a fuller understanding of the underlying TypeSystem of a specific language. I've done so myself with newly encountered languages. The practical differences are usually somewhat subtle such that one can get by just fine with general and rough notions of various dynamic typing approaches of various dynamic languages. A rigorous understanding of a particular language's dynamic TypeSystem is thus NOT necessary to be productive. Your implication appears to be "they are productive in the language, therefore they have a rigorous understanding of its type system". That's false logic.

The TypeSystem implementations of popular imperative programming languages, including the DynamicallyTyped ones, are trivially simple. I can only attribute an apparent lack of understanding, in an otherwise capable programmer, to laziness.

The kind of or pool of "rules" (techniques) they tend to use are indeed relatively simple, HOWEVER, the implementation profile is not. It's almost like saying binary numbers are simple because they only have "1" and "0". However, knowing when/what/where the "1" is used instead of a "0" can be a bear. One cannot know the behavior of each operator just by looking at the basic operator description or guessing based on the operator name using experience from similar languages. For example, it's not easy to know whether each operator uses type-tag based (explicit type indicator) or parse-based dispatching/selection-of type-related behavior. And then there are inconsistencies such as Php's is_number() versus is_bool() where one uses what I call "parse-based" typing and the other uses what I call "tag based" typing. And some languages like ColdFusion don't have (detectable) type tags at all for scalars.

That's some fine molehill mountaineering you've done there. This is all trivial stuff, it's even well-explained on a function-by-function basis in the otherwise-dire PHP manual, and also described in TypeSystemCategoriesInImperativeLanguages. There's no need for constructing new terminology like 'parse-based typing' and 'tag based typing' -- all values have a type, and some operators in some languages rely on the fact that a literal of one type can encode literals of other types. That accounts for "inconsistencies such as Php's is_number() versus is_bool()" and why what you describe as, "languages like ColdFusion don't have (detectable) type tags at all for scalars", is simply the fact that in ColdFusion all values are strings so they can encode any literal of any type.

In my personal observations and casual conversations with field programmers, the vast majority don't use any rigorous model to know/remember which technique a given operator uses. A good portion of the time it "just works" because tag-based and parse-based ACT very similar under typical usage patterns. And if problems or confusion is encountered, one can "shore up" related code by putting in explicit validation at the form (data source), or wrap variables/expressions with explicit conversion operations, such as Round() or toNumber(), depending on the language or circumstance. One can "organically deal with them" to get work done: knowledge of a clear model is NOT necessary to get work done[1]. Still, it's nice to have an explicit model and know the "tag profile" of each operator of a given language. The manuals are poor at providing this info, and you agreed that at least Php did a poor job at such. -t

Why do you believe your "tag model" will make language quirks any less quirky, or any less likely to be worked around in the usual fashion by typical programmers?

Further, the dynamic language designers themselves don't seem to give type issues much thought, creating unnecessary inconsistencies and confusion, such as overloading "+", the is_number versus is_bool inconsistency in Php, and the excessive number of screwy non-printable null-like "characters" in JavaScript. -t

I suspect dynamically typed language designers have enough programming experience to not bother giving these negligible "type issues" any thought beyond documenting them as appropriate (e.g., the "is_number versus is_bool inconsistency in Php"), or they regard them as handy shortcuts (e.g., overloading '+') for experienced programmers rather than pitfalls for weak programmers. I can't justify the Javascript type system -- it is full of quirks -- but you get used to them. I suppose they're not surprising, given that the first implementation of Javascript was hacked together in 10 days.

I don't see how overloading "+" is a "handy shortcut". A different concatenation operator can take up just as little space (such as Microsoft's and ColdFusion's "&". Php's "." should have been reserved for object pathing in my opinion.) Using an overloaded "+" was probably just a pseudo-clever fad to make one feel they are skilled OO'ers, the big fad of late 90's. One can always claim that people confused by odd features are "weak", but one must ask if the "problem feature" is really necessary, or just a quirk of happenstance. I suspect most language designers did not give much thought and vetting to their dynamic typing design, copying "in" fads instead. That's human nature.

Overloading "+" is certainly a handy shortcut when you have various numeric types and wish to make it easy to intermix them.

Sure, for numbers, but not for strings. (Dynamic languages don't really need to make a distinction between Integer, Real, Double, etc. for their typical usage. Sometimes we need to check for integer-ness for form validation, but it doesn't have to be an explicit type. In fact, I'd argue that "max decimals" is a more flexible validation function/check, and can be used to check for (interpret-able) integer-ness. In my opinion they should use some kind of decimal-based computations as described in FloatingPointCurrency. It would probably be slower than the current approaches, though, and not act that much different from the current approaches the vast majority of the time.)

I think this is wandering well OffTopic.


Footnotes:

[1] The environments where dynamic languages are used are generally not "fragile" enough that occasional type-related confusion-caused bugs results in significant damage. Bugs are fixed as encountered. In a domain/project where lack of app bugs really matters, one should probably use a strong- and staticly-typed language. However, development productivity is often slower under such languages, and some argue they are not as flexible to change. Fastidiousness is not cost-free. The loose nature of JavaScript's typing makes it ill-suited as a SystemsSoftware language for web-GUI sub-systems, creating many of the browser GUI headaches out there. An explicitly typed language would be better suited for such use. JavaScript is sufficient as a "glue language" for browser objects/parts, but not the guts.


JanuaryFourteen


Loading...