2011-07-30

when software capitalists become dictators

7.4: adds/security
/when software capitalists become dictators:
. we see what a mess engineers have made of
the internet and computer security;
as chips make more decisions in our appliances,
they are like new laws imposed upon our nature;
this is where capitalists would be legislators;
and they must therefore submit to our constitution:
ie, representatives are elected,
initiatives can be brought by the people
and laws are open to public scrutiny .
. not only is opensource software not communism
(Bill Gates was misquoted as suggesting this);
but software as private capital
is sure to present an inevitable tyranny
just like a communism will
without the checks and balances of
democracy and separation of powers .

7.15: adds/robot/constitution with context casing:
. one way to balance private and public interests
is by including a context chip,
which has the ability to override other chips
whenever it senses the robot is on public property .
. it would also have final say over
the use of force the public is interested in .

TDD (Test-Driven Development)

web.adds/sw.dev.process 
/TDD (Test-Driven Development):
7.1:
"( my python web app is obs ! )
"( you forgot your TDD unit tests, pal )
. what is TDD?  Test-Driven Development
TDD != Unit Testing Dave Rolsky 2009
7.5: synth:
. in test driven development,
rather than ask "(how to impl this feature?),
we ask "(how do you prove
that a feature is impl'd?)
-- and that drives your interface design
(ie, the tests are designed even before
the interfaces, not just the bodies).
links:
sw.dev.process @ wiki
Xunit options for obj'c

agilepainrelief.com:
 I’ve been on projects where we tried to write
all of our tests after the classes were written.
Our test suite was valuable
 and prevented many regressions.
But it allowed many issues to slip through.
Weaker elements in API’s were often missed
and were changed only at a later date
at some expense.
Tightly coupled code was allowed to evolve
making some elements of the application
very difficult to test
without having to create dozens of
other (often unnecessary) objects.
As a result of all this
it became more difficult to write test cases over time.
Would TDD have solved all of these problems?
Perhaps not but it would have forced us to
confront many of them sooner.  
unit testing vs Test-driven_development
. the unit test tries to verify
all features of a given module;
 tdd (Test-driven development) is about
using tests as documentation:
. assuming you already have
libraries of utilities and datatypes,
you design the interface first
then the tests, and finally the bodies
that will make the tests pass .
. if you are writing your documentation first;
then you won't have any problems with also
writing test harnesses before the app is built .

. this is supposed to complement prototyping:
the developer often needs a semi-working model
to get ideas for a more polished model .
. the prototype is then used as the basis
for a high-reliability app
that writes the final design as a set of
user doc's, unit tests,
maint'doc's, feature tests,
and functional tests (having each function
beginning with precondition testing
and ending with postcondition testing).

. reverting to the last version that passed all tests
may often be more productive than debugging.

instead of relying on platform services directly,
they should be accessed through a wrapper,
so that functional testing can be applied .
--
See dependency inversion principle

including obj'c features

7.23: adda/oop/including obj'c features:

. in the expression"( a`b(x)`c ),
the ( a`b(x) ) means
the object"a has a procedure b(x)
that returns an object location
whose available functions include c .
. the syntax"(a`b) is not necessarily
involving self-modification;
it simply means subprogram"b has access to (a)
as an inout parameter
(the subprogram's object parameter).

. is there some efficient way of doing a`b`c
without passing pointers ?
I was thinking there was some virtual way
that doesn't really need pointers
(oop doesn't really need
all the pointers it thinks it needs)...

. if a subprogram's object param
returns a reference to something other than
the object param,
then in the c translation of same
this subprogram takes a destination param;
ie, a param that inputs a destination address
showing where the caller wants the return placed .

. why wouldn't it always take a destination param
even when returning self? ...
because the caller is already housing that obj .

7.26:
. my original concern here
was allowing the passing of references
and the use of object param's,
just like obj'c oop does,
while still using the sort of oop system
that did not generate garbage .
todo:
. I think obj'c has the convention that
even if ( a`b(x) doesn't return anything
if an object reference is expected as a return,
as is the case in "( a`b(x)`c ),
then it will use a reference to (a);
ie, ( a`b(x)`c ) would equal:
( a`b(x); a`c ) .

protecting the stack limits

7.22: adda/protecting the stack limits:

. how can one test for stack limits per platform?
if you test it once per platform
could the limit become smaller later?
it could depend on number of processes,
and current ram count ?
the user or an error could downgrade ram .
some help from addm:
. one thing that helps the stack problem
is assuming that user programs are addm code
rather than native code;
addm uses the c stack in a very limited way
and puts the user's stack entirely in the heap;
the user does call standard libraries
that in turn are native code;
but these can be designed to conserve stack space
(eg,
all recursive routines are finding some way to
serialize the large jobs;
eg, instead of giving gig's to quicksort,
the sorter breaks the job into mbyte sections,
and gives the quicksort's sections to mergesort ).
...
but can't the user can program natively? yes:
(see adda/natively coded extensions)
the user isn't restricted to addm,
so adda must be aware of some stack limits
and provide protections against overflow .

symbol table linking

7.14: 7.15: adda/symbol table linking:

. etrees (expression trees)
are tree nodes with pointers into
global and local dictionaries of symbols
(symbol tables).
. every etree module
implies access to a global symbol table,
and must specify any needed local symbol tables .
. there can be more than one local symbol table;
because, a dictionary can include procedures;
and, procedure definitions can have
local dictionaries:
the parent procedure becomes the
scope of its local dictionary,
hence the term "(nested scopes),
involving stacks of local symbol tables .
. each module has a tree of symbol tables .
. a typical scope path is:
module/subprog/nested sub/nested block/nested block .

. the 3 main uses of "(library) include
system, standard, and custom .
. the system library of an addx installation
is a service for organizing and linking
the modules that are available for reuse .
. a standard library is a module that is
declared by the system's language .
. a custom library is one added by the user .
. each module has a list of imported modules,
and a tree of symbol tables
to match its tree of nested scopes .

. when designing the pointer that is
going from etree nodes into symbol tables,
there must be an efficient coding,
and it should support efficient copying
even when it involves context changes
(re: adde/object copy & paste).

etree node variants for library symbols:
. there is first a bit to distinguish
symbol location type in {library, local}:
# library location:
. there may be many libraries in use (15-bit),
and many symbols per library (16-bit) .
# local location:
. there's often no more than
4 nested levels of locals (2bit);
and often less than 256 symbols per local (8bit).
but if node`size is in increments of 16bit chunks
that division could be 4 bits for 16 nested scopes,
and an 11-bit space for locals,
or less if the descriminant is more than 1 bit .
[7.30:
... in any case, the more space you save,
the less efficient it is to remap etree nodes
to a new symbol table after a context change .]

details of library location:
. there could be an infinity of libraries over time,
so the library codes in an etree node
don't represent specific libraries,
rather they represent a slot in the module's
list of imported or required libraries;
however, standard libraries can be specified,
since there are a finite number of them;
ie, if the code is in the range that is
reserved for standard lib's,
then that is the same code used by
the system library;
otherwise, we need to use the module's import list
to convert the symbol table's code
into one that the system library recognizes .

. the system library creates a custom lib's code
by taking a Secure Hash of its interface
. as long as that didn't change,
it would be considered the same library . 

natively coded extensions

7.22: adda/natively coded extensions:
. the adda compiler helps turn adda code
into obj'c code,
and then the user plugs that into xcode
to generate mac programs .
. there are 2 styles of user programming:
# extending addm:
. the user want's their library unit to be
seen by addm,
so that user's library unit is callable from
user's other scripts .
. this entails compiling the library unit,
recompiling addm to bind with the library unit
and relinking addm with the entire library .
. this is known as pythonic development:
a module is run as translated vm code
until it's perfected:
then it's promoted to native code
and made available in the account's library .
# building native apps:
. in building a native app,
adda code is translated to the native lang
(eg, mac speaks obj'c & cocoa).
. the native program then imports
the relevant adda libraries
and includes addm as a component
so that the program or its user
can run arbitrary adda scripts .

object copy & paste

7.14: adde/object copy & paste:

. the typical copy & paste
is a char-string operation;
whereas, an object selection
is operating over etrees (expression trees)
which are tree nodes with pointers into
dictionaries of symbols (symbol tables).
. there can be more than one symbol table;
because, a dictionary can include procedures,
and procedure definitions can have local dictionaries;
hence, a single etree can be within
the scope of multiple dictionaries
represented by stacks of local symbol tables .

. a copy becomes a module
meaning it needs its own copy of
any local symbol tables;
however, the cost of copying
depends on the destination:
if the paste location is within the source's scope
it shares all the same symbol tables .
. when some symbol tables are
not shared between source and destination
those tables must be copied;
and, affected etree nodes adjusted
to point into the new tables .

. when an arbitrary substring is selected
it can be representing fractions of etrees,
eg, given a+b+c, a selection can include
all of term-b and partials of terms {a,c} .

. there may be parts of the given language where
partial terms don't have the same meaning;
ie, there would be nothing but a
char-string translation of the object selection .
. in any case,
the quickest, most general way to define a selection
is to get links to the entire chain of symbol tables;
and, copy the entire subtree that contains
all the fragments of the selection;
then include a descriptor that shows
where the selection is beginning and ending .

. when would you want fragments and still want
the etree object rather than a char string?
for orthogonality,
we have to provide for the possibility
that one of adde's plug-in app's
can find some use for such a selection;
ie, in many cases of user interaction
the selection is for a function other than
cut or copy .

7.15:
. when designing the pointer that is
going from etree nodes into symbol tables,
there must be an efficient coding,
and it should support efficient copying
even when it involves context changes .

. both the source and destination of a copy
have scope paths:
if the scope paths aren't the same
we have to identify any scopes not shared
and copy their symbol tables
for merging with the destination .
if this is a cut instead of a copy,
there are fewer choices,
since the destination space is smaller .

. a complication of multiple nestings of scope
is the orphaned symbol from ancestor scopes:
these imply some sort of communication with
a context which no longer exists .
. we have to remind the user
that the orphan's place in the destination
may need special attention:
should it be added to the new parent scope,
or some higher scope ?
. the default location would be relative height,
ie, the same number of scopes up the path
as it was in the source location .
. in any case, we have to assist the user
in keeping track of these orphan relocations,
and make sure that all affected contexts
are adjusted to create a sensible communication
such that, the role of the source ancestor
is now provided by the new context's procedure .

tags, link-trees, and file-trees

7.3: 7.30: adde/tags, link-trees, and file-trees:
. how to integrate tags with folder systems?
placing a file in a folder is tagging it;
 a hierarchy is a tag with segments;
ie, each path name is one tag .
. while a file can be in only one folder,
it can be assigned to many tags .

. tags can be thought of as
a list of links to its members;
and, equivalently, as attributes of a file:
each file or file link can list all the tags
to which it is a member,
just as it can tell the folder path it's in .

link-trees vs file-trees:
. a file-tree is the usual folder tree,
it contains actual files rather than links;
so, a file can be a member of only one file-tree .
. the link-tree is like a file-tree
except it contains only links to files
rather than actual files;
thus, a file can belong to many link-trees,
and may be in many places
within the same link-tree .
7.30:
. the main idea for these distinctions
is that file-trees are low-level concerns;
the only reason they need to be accessed
is when the space limits require
deletions or archiving .
. most file system operations
are concerned only with organizing files,
not managing limited space,
and each activity should have its own
customized view of the file system;
so, most file accesses should be done
through link-trees .
. tags can be applied to either files or links,
depending on the tag's scope:
tags on files are global;
tags on links apply only to
a specific link-tree;
ie, each link-tree has its own set of tags:
both the ones induced by the global tags
belonging to files it's linking to,
and the tags specified by the
user of the link-tree .

binary operation aggregation

7.10: adda/cstr/binary operation aggregation:
. biop's (binary operations)
can be seen as aggregated
by a rule book showing combinations of biops
that should be considered to be
one subprogram call
ie, binding to a particular subprogram;
eg, {?, else} are both biops,
and the rule book would say that
(?, else) is a single function:
?-else(truth,proc,proc).proc
or ?-else(truth,fun,fun).fun .

references for security and speed

7.9: adda/oop/references for security and speed:
. notice how oop would rather
create a new object and modify a pointer
than modify the value of a current object .
. I call this the "(pervasive pointers).

. from an encapsulation view there is no diff',
since only the owning type
can do these mod's .
. what it does seem to uniquely do though,
is encourage the sharing of objects;
ie, if you can modify your value
then I have no interest in sharing its object
because it's no longer synonymous with
the intended value at some past time .
--
. oop is doing for every value
what c does only for arrays .
7.10:
. it does promote strong
capability-based security;
because if everything is through reference,
and ref's are encryptable,
then that is a much stronger encapsulation
unless the system is already protected
by allowing only system-compiled code .
7.11:
. another interesting property of
pervasive pointers
is that by comparing pointers,
one can tell quickly whether
even huge structures are identical;
though if the pointers aren't equal,
they might still represent equal values .
. python has a speed hack where the
first 100 ints have reserved pointers
so in the many loops controlled by small ints,
pointer compares are decisive .

local resource accesses and wrappers

7.3: adda/portability/local resource accesses and wrappers:
. wondering how adda can provide portable features
and yet also provide access to
individual platform features .
. per each platform,
represent its features as a library,
and then map adda's features to that .
. users can expect portability from
staying with the model;
and can get more into their specific platform
by importing the lib's it offers .
. additionally,
there will never be a portable model of
what paths you can modify;
instead, you have to list per system,
what volumes are available,
and whether they are writable or rom .
7.5:
. adda must include all the storage models,
and must map them to diversely contstrained models:
eg, some platform may offer nothing but a database,
so, adda must provide a hierarchical filesystem
that is implemented by a database .

go's defer statement

7.1: adda/go.lang/defer:
. go.lang has a defer
that is like a type mgt's finalization routine
only it's used by a function
for things that should happen on return .
. ideas I got from that are:
# on return: ... [7.30:
. "(on *condition*) would generally mean
rule-based vs imperative programming;
so (on return: s) would add (s) to
the list of things to do before returning .]
# self`end`+ ... [7.30:
. this is modeled after i`+ 1
which is shorthand for i= i+1 .
. the self is the current subprogram;
it already has an "(end)
listing things to do before ending;
and a (`+) would add to that list .]

Ousterhout's dichotomy

7.1: news.adda/Ousterhout's dichotomy:
. John Ousterhout, designer of Tcl,
noticed that high-level programming languages
tend to fall into two groups,
"system programming languages"
and "scripting languages".
[ie you can't have a language that is
optimal for both .
. in defence of that claim,
pypy tried to have a system language Rpython
that was as much as possible like
Python, the scripting lang;
because they wanted
a self-hosting python compiler
ie, one written in python instead of c .
[7.30: like adda,
Rpython is designed to translate into c
for the purpose of avoiding c:
system programmers can use Rpython
yet still take advantage of c compilers .]
. the closest Rpython could get to python
is a subset of it that added static typing;
because, some features that support
coder productivity
are antithetical to features that support
algorithm efficiency .
. Ousterhout was likely pointing out that
scripting lang efficiency was not so important;
because, scripts are glue for
subprograms of sufficient size,
such that most of the run time
is spent in the parts defined by the system lang .
7.30: web:
D. Ancona, M. Ancona, A Cuni, and N. Matsakis.
RPython: a Step Towards Reconciling
Dynamically and Statically Typed OO Languages.
In OOPSLA 2007 Proceedings and Companion, DLS'07:
Proceedings of the 2007 Symposium on
Dynamic Languages, pages 53-64. ACM, 2007(pdf)
. an approach that attempts to preserve
the flexibility of Python,
while still allowing for efficient execution
is limiting the use of
the more dynamic features of Python
to an initial, bootstrapping phase.
This phase is used to construct
a final RPython (Restricted Python) program
that is actually executed.
RPython is a proper subset of Python,
is statically typed,
and does not allow dynamic modification
of class or method definitions;
however, it can still take advantage of
Python features such as mixins and
first-class methods and classes.
This paper presents an overview of RPython,
including its design and its translation to
both CLI and JVM bytecode.
We show how the bootstrapping phase can be
used to implement advanced features,
like extensible classes and generative programming.