Re: what does "serialization" mean?

From: Edward G. Nilges (spinoza1111_at_yahoo.com)
Date: 06/26/04


Date: 25 Jun 2004 21:14:53 -0700

Programmer Dude <Chris@Sonnack.com> wrote in message news:<c00nd05in60rcnkn2k0eda6biptvc4fsio@4ax.com>...
> Edward G. Nilges writes:
>
> >> False for any subject matter.
> >
> > This may be a false humility.
>
> Not at all. I can name no subject in which I could genuinely claim
> expertise, for I have always taken the Jack of All side of pursuing
> knowledge. I believe I can claim I have strong areas, however.

Sounds fine with me.
>
> > Do you use VB.Net? If you do then the claim that the VB.Net user
> > needed to use a Set statement was merely a brain fart, if a large one.
>
> As stated several times previously, I have never used any .Net product
> (unless it happened under some hood beyond my ken). I recently began
> reading about C#, which interests me. Subject to change, at this point,
> VB.Net doesn't interest me (for resource reasons).
>
You can get the framework and the compiler (minus the GUI) for
absolute free from Microsoft.

>
> > OK, let's change the tone here. I have a question for you.
>
> Ok...
>
> > For i = 1 to j*8
> >
> > A student said it was "inefficient" since it "unnecessarily multiplied
> > j times 8" each time through the loop.
> >
> > I demonstrated that the evaluation in this language is "by value"
> > since the product of j and 8 is calculated once. He then said, OK,
> > but it's still "confusing".
> >
> > And when it's translated to C or Javascript, he said, it does indeed
> > perform poorly because the calculation in a for loop in these
> > languages is "by ref".
> >
> > My personal opinion of the for structure in C and Javascript is that
> > it should have been drowned at birth. What is yours, and obey
> > O'Dwyer's request to not restart a flame war.
>
> ...but it's Switch'n'Bait. Too bad, it started off so nice. In fact,
> so nicely, I fell for it and devised an honest answer to your Bait
> Question. FWIW, here it is:
>
> What your student may have been expressing is that, if J*8 is KNOWN to
> be constant, you are being--in effect--dishonest in your code. Code
> expresses intent (as do most other forms of text writing) and as with
> other forms of writing saying what you really mean to say is a writing
> skill that must be acquired.

This response, while very intelligent, is a misinterpretation of
Kernighan's law: code what you mean.

That is because you assume that in

For i = 1 to j*8
    bnoog
Next i

you have assumed that the reader will assume, in turn, that the scope
of the For is from the F, so to speak to the end.

Whereas many intelligent programmers know that the For line includes
one-time code, including the calculation and stacking of j*8.

In C, the one time scope starts at the first colon.

Therefore I do not think it any clearer to code

Dim k
.
.
.
k = j*8
For i = 1 to k

In fact I think it to be regressive and clumsy for it introduces an
unneeded variable k, and furthermore retards the Long March away from
the "how" of assembler languages to the "what" of functional and logic
languages.

>
> Saying "j*8" implies a reason saying it thus, and that reason hints that
> j may change and thus the expression is worth evaluating each time.

That would be part of its connotation but that is in the mind of the
reader. To reason that the mere appearance of a variable in an
expression hints, implies, connotes "may change" means that
expressions shouldn't contain constants either and this is nonsense.

Furthermore, the implication is a good thing, for "all things must
pass, all things must fade away" and properly considered a program
text must write its own death in the form of intimations that "this
solution may change". This is why it is better to use named constants
rather than "magic" numbers or quoted strings.

>
> Note that this view transcends languages and doesn't rely on special
> knowledge of exactly how a specific language reacts under the hood.
> As a general programming heuristic, if an expression appears anywhere
> in any kind of "loop statement", the implication is that the expression
> belongs there.
>
The problem is that it is in fact an error to think that all of the
For line is inside the loop and one's style should not perpetuate
error.

The programmer should be made to see through the For loop to exactly
what is happening behind the scenes, if necessary by being momentarily
arrested by the appearance of a formula...which is as you know
evaluated ONCE in VB but MANY TIMES in C and other deeply flawed
languages.
 
> The strength of this view is that you are less likely to mess up when
> you do work in a language that evaluates loop expressions.
>
> As for your Switch Question, I don't honestly favor C++ over VB over
> Java over C over JavaScript (to name, in order, the languages I work
> in most). Each has a purpose. Compare them to hammers and saws and
> oscilloscopes and steam shovels. The toolset is varied. Last weekend

No, I prefer not to do that. I demur strongly from the Sears Craftsman
model of programming in which it is "just like" puttering about the
woodshed with tools for the very good reason that programming is "more
like" writing.

> I wrote a VB program for work, two nights ago I wrote a quick C++
> (but not OO) program to quickly convert Unicode files down to ASCII.

Glad to see you've adopted my usage for ASCII.
>
> I would not have liked doing either task in the other language.
> Neither was up to the task performed easily by the other.

> So I find both are worthy tools and good friends.
>
> > A related issue for me is whether it might be better to abandon
> > numeric indexes especially for collections which in various flavors
> > of VB have different origins.
>
> Not a matter I've given much thought. I only use Collections when I
> WANT to index by (what amounts to) string values. I don't fully trust
> Collections to maintain ordinality, so I would never count on a GIVEN

Which you cannot when the Collection is being accessed from several
places...

> index being persistant. Neither do I index them numerically when
> iterating. I prefer the merged index/assign sense of For Each, and
> since I used Collections as UNORDERED bags, I don't much care what in
> order the builtin iterator provides them.

In that case the collection should be called a set (an unordered bag
with no duplicates) and in that case machine level set operations
should be available. One shouldn't have to reinvent them.

>
> > Another issue for me is the definition in C# and C++ of iterators as
> > objects. Have you seen this practice and does it make any sense to
> > you?
>
> Absolutely. Love'm! I'm radical; I make the iter object a subclass
> of its container class. Here's a stripped down frag from some lib
> code (cStrings is a linked-list of cString objects):
>
> cString
> cStrings::Join (const cString& delim) const
> {
> cStrings::Itor sx(*this); // make a String iterator
> cString s;
>
> for (sx=0; sx(); ++sx)
> {
> cString& item = sx.Item(); // (convenient ref to current obj)
>
> // [snip] build s from (s & item & delim)
> }
> return s;
> }
>
>
>
> Ball's back in your court.

I see no problem with this practice and shall adopt it ASAP. It cannot
be used in VB-6 because of the lack of Inherits but it can be used in
.Net.

However, one problem is that the concept of "iterator" doesn't
parallel any concepts from formal logic outside programming and that
is a danger sign.

Perhaps what one SHOULD do in place of defining, for all or most new
objects, an iterator, is defining a set-of that would expose
iteration.

The problem is that the cleanest way to implement this would be
through multiple inheritance which VB.Net doesn't support.

Define the concrete class BunnyRabbit. Have available the abstract
class set. A set-of Bunny Rabbits would have to be-a set and inherit
collectively all the capabilities of Bunny Rabbits. It would have to
Inherit Set and BunnyRabbit.

The problem I see with subclassing the itor is Ockhamian. It is that
you wind up with a lot of clockwork dolls, each distinguished from the
other only by what they iterate.

One potential flaw with multiple inheritance of set and something else
is that the collective would have to be meaningfully capable of ANY
individual property or method. We could I suppose consult Marx for
guidance on how this is possible because Marx believed that the
proletariat had "consciousness" and other capabilities ordinarily
ascribed only to persons by bourgeois theory but I digress.

Seriously, if Lonely is a property of BunnyRabbit, the BunnyRabbitSet
would also have to be meaningfully lonely. We could I suppose consult
David Reisman (author of The Lonely Crowd) for guidance but I again
digress.

Seriously, a danger with iteration is that it captures only part of
the more meaningful concept that "my object may exist, meaningfully,
in a collective or set of objects".

In fact and for some time, because I learned symbolic logic (inspired
to do so, I confess, in Robert Heinlein's Fascistic book, Starship
Trooper) before gaining access to computers, I have been puzzled as to
a major if unmentioned reinvention of the wheel.

This is the refusal to use noncomputer logical concepts including the
set in MIS programming and its replacement by partial mechanisms.

The iterator is in fact a procedural implementation of the universal
quantifier:

     (x)[Man(x) -> Mortal(x)]

which corresponds to the old style enumerated For loop

     for ( intIndex1 = 0:
           intIndex1 < numberOfBeings:
           intIndex1++ )
         if ( Man(x) ) assert( Mortal(x) );

This loop "breaks" if run in real time, for if during its execution a
child is born, numberOfBeings would change. This would be handled in
the above C example but not in a Visual Basic For loop, which would
take the numberOfBeings applicable on entry to the For.

But the loop still assumes that the numbering scheme for the Ten
Thousand Things does not change, therefore for each is cleaner:

     For Each being b
         If Man(b) Then Assert b & " is mortal"
     End

More generally, I'd ask why we still are using procedural languages at
all and are not programming in pure symbolic logic. Of course, I know
the answer: it is that the very best compilers for functional and
logic languages emit code for real processors that is at best 2 or 3
times as slow as procedural code.

Of course, this is an artifact of the Intel and similar architectures
which were built to run procedural code. But the day appears to be
past when you could build machines for your favorite style of
programming.



Relevant Pages

  • Is Biztalk an admission of OOP failure?
    ... A loop is a loop ... But, once you get past all the bells and whistles, Biztalk ... is a visual scripting environment for procedure languages. ... best practice for OOP programming. ...
    (microsoft.public.biztalk.general)
  • Re: beginner, idiomatic python
    ... languages I am familiar with. ... Is self.parent.GetPageCount'retrieved every loop'? ... for i in iterator: ...
    (comp.lang.python)
  • Re: compiler for Chinese development language
    ... This relates to the development of vernacular ... Indian vernacular display, OS and programming languages. ... Bangla and other vernaculars. ...
    (comp.compilers)
  • Re: Head-in-the-Sand Liberals (LA Times Columnist)
    ... You claimed to have known several computer languages, ... If you lie about knowing computer languages, ... of the programming loop for a functional ... You also don't know Java. ...
    (rec.org.mensa)
  • Re: Is there a mainframe skills shortage?
    ... That's because the author of the article is comparing it to standard SQL. ... and material around Lamdas and functional programming. ... obvious which languages were the ones to learn. ... stick to writing system software and leave applications to the COBOL ...
    (comp.lang.cobol)

Loading