2010-06-30

journaling . elder care helps dev's too

6.1: adde/journaling/elder care helps dev's too:
. so many computer problems and clues;
trouble trusting my mem now ...
. computers for elders definitely aren't here yet!
we need a modular architecture
where no app does anything
-- inputting our outputting --
without a log recording it .
. you would think this is
the first thing designers would do;
they are always fielding calls like:
"( I don't know what I did .
how can reproduce the problem?)
and always giving advice like:
"( please be aware
of every little keystroke you make;
so that you can recreate the problem,
noting (eg, logging)
what conditions are triggering the behavior
-- the platform, its config', and your input).

gooey gui portability

6.28: pos.adda/dev.gui/stay with the mainstream tools:

. sdl (simple directmedia layer)
reminds me that being low level
could get you into trouble;
the original adda plan
to simply write a native code compiler
for each system, might be
not only cleaner, but also safer,
since a platform's own code and tools
are likely to take better care of you
if not with a safer language,
then at least with documentation
that warns you where the landmines are .

. a browse through sdl-style portability
points out that c is not multi-core .
. the goal of portability
-- as in maximal c coding --
could interfere with some
very smart c concurrency extensions .
. if concurrency should be pervasive,
your code will be riddled with non-std c
(don't even bother trying for portable).
[6.30: but the mvc pattern could help with
turning concurrency into a module? ]

adda exceptions performance

6.27: web.adda/exceptions/performance:
. I'm wondering how c++ exceptions
were inherently slowing c programs:
the addx vision of exceptions
is that there is always a scheduler
pre-empting functions for multitasking;
and, this scheduler is
gathering all the exceptions in a library;
... but it's not just routines
that handle exceptions:
every sub.block with a routine
can provide a unique handler for an exception;
and, these "(catch blocks) can be nested .
impl' idea#1:
. catch.blocks need to push their address
onto an exception stack;
then after an exception,
the scheduler can look on this exception stack
to the addresses of handlers .
. a program that has no handlers
would have an exception stack with
only one item:
the system's set of handlers .

web: Exceptions performance penalty:
In C++ Programming Language 3rd edition section 14.8
Stroustrup writes that it's possible to
implement exception handling
in such a way that there is
no run time overhead
when no exception is thrown
-- but it's not easy .
There is generally some overhead
as we have to keep track of the local objects
whose constructors have run,
so when exception is thrown
their destructors are called.
see Scott Meyer's "More effective C++" .

. g++ creates exception tables.
From the value of program counter
you can know which function/scope you're in.
For each scope you then know
which destructors have to be called
and using the stack address
you delete the apropriate objects.

We suppose that you can get
{ __builtin_return_address (LEVEL)
, __builtin_frame_address (LEVEL)
} for the ESP and EPC
of the caller of level LEVEL.

plain old c ... minus

6.25: pos.adda/plain old c ... minus:
[6.30:
. google's native-code sandboxes
in Android and in Chromium OS
are an important platform,
and should be considered before
deciding what "std" C is .] [6.28:
. many platforms will restrict the std libraries
in order to further enhance security
or adapt to smaller, energy-wise situations .]

. keep in mind what's available in
the android ndk:
libc (the C library), -- as Bionic, not glibc.
JNI interface, -- controller-view of your mvc;
OpenGL ES {1.1, 2.0} (3D graphics)
libm (Math),
libz (Zlib compression)
liblog (Android logging)
libjnigraphics (JNI Pixel buffer access)

. the API is included with the sdk;
so, get that installed on ubuntu
(eclipse runs better there than mac?) .

details of android's custom libc:
. customizing libc (as Bionic)
was necessary for three reasons:
* License:
keep GPL out of user-space.
Bionic code uses the BSD license.
* Size:
Bionic is half the size of glibc
* Speed:
custom pthread implementation.
Bionic has built-in support for
important Android-specific services
such as system properties and logging.

It doesn't support certain POSIX features,
like wide chars (wchar_t)
-- The world has moved on to Unicode
with its various fixed and variable
width encodings,
which the wide character type
is not particularly useful for.

. use ICU for internationalization support,
(International Components for Unicode)
instead of LOCALE .
ICU is a mature, widely used set of
C/C++ and Java libraries providing
Unicode and Globalization support
for software applications.
ICU is widely portable
and gives applications the same results on all platforms
and between C/C++ and Java software.
threads
The bionic C library has it's own thread API,
not the same as either original LinuxThreads or NPTL.
It implements only support for Dalvik JVM,

Mutexes, rwlocks, condvars, etc
are all implemented using kernel futexes,
-- see Ulrich Drepper's futex whitepaper.
There is no pthread_cancel().
Threads can exit,
but can not be killed by another thread.
There is no pthread_atfork().
Thread local storage is implemented,
with up to 64 keys handled.
Android reserves several of these for its own use:
the per-thread id and errno,
as well as two variables related to OpenGL
whose function I do not understand.

stdio, stdlib, string, unistd:
. removed the LOCALE support from strtod()
(i.e., is the decimal point a period or a comma?
In the Bionic library it is always a period).

{openlog(), syslog()} are replaced with
__libc_android_log_print()

Bionic uses Doug Lea's malloc, dlmalloc.
Bionic also provides a hash table
to track allocations
looking for leaks, in malloc_leak.c.

no asynchronous AIO routines
aio_read() or aio_write().

no crypt()
-- uses OpenSSL for that .
. dispenses with most file-based Unix administration.
no getfsent,
because no /etc/fstab.
. there is a /var/run/utmp,
and so there is a getutent()
Android implements its own account management,
and does not use /etc/passwd.

. no getpwent(),
and getpwnam()/getpwuid() are implemented as
wrappers around an Android ID service.
At present, the Android ID service consists of
25 hard-coded accounts in android_filesystem_config.h

. no termios support (good riddance).

Bionic is a BSD-based libc with support for
Linux system calls and interfaces.
If limitations prove untenable,
the syscall and pthread mutex implementation
could be repurposed into the heavier
FreeBSD/NetBSD/OpenBSD libc,
though handling thread cancellation
while using the Bionic mutexes
could require additional work.

oop theories, designs, implementation notes

6.1: adda/oop/based on vari-sized records:

. the 3 sorts of inheritance:
# subtyping:
. inheritors are assignment compatible .
# symbolic description:
. describes one type in terms of
another (incompatible) type .
# generics:
. an object's function is selected by
the function's name (or hash of that)
-- rather than referring to methods by
index, pointer, or offset .
-- this is the obj'c meaning of inheritance; [6.7:
obj'c also supports subtyping . 6.30:
... actually,
any system that supports generics,
implicitely supports subtyping .]
. after review oop ideas,
I wondered if the the trailer idea
would be useful for oop subclassing .

. parameters that vary in size
are accommodated by replacing value with
a mini-pointer (an index into
an associated trailer array)
that then leads to the value .
. a vari-sized record is organized as
a head (the mini-pointers)
and body (the trailer).
. in the vari-length record,
the number of fields is fixed,
whereas in multi-inheriting oop,
not only does the body grow
but the head too is vari-sized .
. provide a mini-filesystem (fs)...
[6.30:
. each class expects to find
it's own instance variables
arranged in the usual way
even when it's one of many ancestors
of the obj's class .
. in a mini-fs, the directory
doesn't have to be on the obj;
just containing a type.tag,
will be eno', since that is a
key to using the lib mgr's map:
(instance's class, ancestor.class) ->
offset into instance .
-- this map shows what offset to use
into the instance
to get to an inherited class's
embedded instance record .]

6.30: todo.adda/oop/obj'c dynamic linking:
. when there is multi-inheritance,
you have an instance variable where
there are separate sections
for each subclass's privates .
. it would be efficient if type-mgr is
passed ptr's to the operated obj's;
and generally,
how is each type-mgr supervised
so as to insure that they
don't affect any surrounding bits?
. you trust your compiler,
but then in obj'c,
you can relink modules dynamically;
and, the new module might be
code from another compiler .
. need to review obj'c
for how to best use,
and not be used by, that subsystem .

6.5: adda/oop/how does c do obj'c dynamic bindings:
. the generic-oop functionality of obj'c
comes from being able to launch a subrogram
when given a function`name and a type.tag;
this could be done in unix by calling to the os
to execute a shell command;
. without that ability,
each addition to the class library
would require editing the obj'c run-time engine
and re-linking it with the expanded class library .

6.7: adda/oop/subclasses as subtypes:
. what is a new type, vs a subtype, in adda?
subtypes can't remove or ignore
inherited functions,
but new types can do a reuse but remove;
how does Ada do this ?
inheritors are new types (meaning it's
not assignment-compatible
with the inherited type);
if you want a variable to have subtype polymorphism
(ie, be assignment-compatible with
all inheritors of Baseclass),
then you need to declare the var's type to be
Baseclass'class .

6.23: pos.adda/obj'c and cocoa bindings:
. the reason to not interface cocoa
is that it's very inefficient with its
ref'counting and its (typical) way
of implementing oop .
. to the extent there does need to be
a binding to it (for the sake of
getting the usual services)
the binding will not be direct:
the mac gives all the power to the developer,
whereas addx will give the user
most of the gui design .
. for example, in nu,
"( locally-scoped assignments are
instances of NSMutableDictionary; )
this might look like an
excellent chance to reuse,
but you might be using thousands of those,
which means juggling a lot of within
both your subsystem's heap
and the mac's system heap .
. it might be ok for prototyping,
but eventually, you want basic services
to be based on your own mem'mgt .

adda with mac, lisp, & nu

6.23: pos.adda/lisp/reuse of nu:
. can adda reuse nu by mapping to nu trees?
the primary job of adda is to
translate my lang to the platform's;
nu may not be a direct translation,
esp'ly given that it's completely oop
and maps to obj'c rather than
trying to stay in ansi c .
. the way nu could be quite handy
is to study how it implements
the lisp-like behaviors on the mac .
holy grail:
. here in this neontology example
he's got code for everything that is
usually done by the gui tool"InterfaceBuilder .
. replacing that is holy grail of addx .

6.23: adda/lisp/including s-expressions:
. the users of nu and lisp
like to remind us that
using a lang based on s-expressions
is not just being lazy:
it's just much easier to understand
when designing code that reads code .
. therefore, adda must have both modes:
english-math,
and s-expressions .
. english-math actually follows
syntax rules convenient to humans;
whereas, s-expression is simply
converting nested parentheticals
directly to nested trees .

adda's enumerated types

6.22: adda/type"enum:
. for the sake of readability,
adda`enums should be translated
directly to c`enums;
however, c`enums do need a lot of
helper functions in order to provide
ada-style functionality .
. it should also add -- in addition to Ada's way --
the same functionality for enums
that c has for pointers:
eg, if the ptr points at 4-byte ints,
then ptr+1 actually means ptr+4;
likewise for enums:
(e+1) means find the enum value
of next enum;
. if the enum is complicated by
non-consecutive values:
eg, { off, green:10, yellow:50, red:100 }
then it needs to generate a table
that enumerates the enum values:
eg, if the value will be in {0, 10, 50, 100}
then the table: value -> ordinal
is {0:0, 10:1, 50:2, 100:3};
with the ordinal value,
the encoded value is found from
an array lookup: {0, 10, 50, 100};
so if e=green+1; then
{ off, green:10, yellow:50, red:100
}(green) -> 10:
e= val#10 + ord#1 then
{0:0, 10:1, 50:2, 100:3}(10) -> 1:
e= ord#1 + ord#1 = ord#2 then
{0, 10, 50, 100}(+2) -> 50:
yellow
--. if there are only a few var's
it would be more efficient to
store both the ordinal and value in e .
. if values are consecutive
then after possibly shifting for a non-zero start,
the ordinal equals the value;
so, the enum`arithmetic functions need only
check for [out of range] .
. there should be unique type`names for
the 3 classes of enum types:
* subtype"simple-enum
has consecutive values that are
bijecting to names;
* subtype"encoding-enum has
non-consecutive bijections;
* subtype"entyping-enum is non-bijective:
there is no functional mapping
from code to name;
rationale for the name "(entyping):
traversing the values of the entyping-enum
then returns a sort of typing or
partitioning into equivalence classes:
eg, a mapping of enum`names to {0,1}
{ off:0, green:1, yellow:1, red:1 }
would have a traversal that returns
sets:
the first set is all names encoded as 0:
{ off }
the next set is names encoded as 1:
{ green, yellow, red } .

pointer syntax depends on typing

6.21: adda/pointer/syntax depends on typing:
. my current ideas of adopting folder syntax
as the syntax for pointers dereferences
seems to go against how folders are
normally used: (dir/) is same as (dir) .
. my semantics have said
(dir/) is body of folder
whereas
(dir) is ptr to folder .
. nevertheless,
the semantics are the same if
considering the type expected:
(eg,
a (copy) or (move) operation
is not expecting to operate on
pointers implementing the container
) .
a var' expecting a pointer
converts either case to a pointer,
whereas, a var' expecting subfolder
converts either case to a subfolder .

adda formatted strings

6.5: adda/formatted strings:
. the same escape code ( a "!" in [brackets] )
is used for adde's markup language for
indicating a command rather than literal text;
it could also work like a c`formatting string:
when the escape code is embedded in string
it means the following expression
is replaced with the eval of same
(the value returned by the eval'd expression
will have an image attribute that is applied
to merge the value with surrounding string).
. in the general case
(not knowing the string until run.time),
having escape codes embedded in strings
requires a virtual machine (like addm)
for run-time compile and eval's .
. the eval could be static by
doing it c's way:
limit the string var's syntax to
just being a param`index number, etc,
but that would be hard to read
like c's formatting string;
it can be both readable and not needing addm
if it limited the escaped expressions
to just symbols (ie, the names of active var's);
eg, "(var= [ ! ]var's-name)
. any subprogram that accepts a formatted string
also uses another parameter
for accepting its caller's environ pointer
which gives access to caller's locals .
. this environ is the same the symbol table
used by the compiler's parser:
as it finds a name in the source code,
it checks the environ else adds it;
and then replaces the string string name
with the symbol table index
until the entire string
is a tree of mini-pointers to symbols
(ie, symbol table indices).
. the symbol table then includes
stack offsets for finding the value at run.time .
. these same facilities can be used by
subprograms wanting a value given a var`name:
(namestring, environ) -> val .
. the efficient way to do that
(without such reflection facilities)
is to allow only constant literal strings
to be used as format strings;
then the compiler can replace it with
a concatenation expression;
eg, "(var = [ ! ]var`name)
becomes: "(var=) & var`image .

adda keeping things documented

6.4: adda/syntax decl's for freedom with readability:
. as much as possible, the code should be
readable from just knowing english and math;
that means,
that if you want to do strange things like
,() = (,,,)
then you need to describe that in a
syntax declaration, something at the top of
every source file [6.30:
though it could by pointer,
and then the code reader would auto'ly
expand all such pointers .]

6.20: adda/monkey patch vs freedom:
. after learning of "(monkey patch),
the place to be is full documentation:
if there are any ways that relinking
can modify a given package,
the state of current linkage needs to be
readable as part of the source,
so that linkage changes show up as
a modification to the package .


2010-05-18

in's and out's of Ada programming

4.8: todo.co.addn/dev.ada/ask about c infiltration:
. from looking at the F35 project,
it seems like c has won the war with Ada;
and, that got me realizing that
much of what I like about Ada
could be transferred to c .
. the essential Ada features could be introduced
just like the enum types were;
and,
perhaps some version could try
the same route that c++ did:
"(this is a superset);
the industry really went wild for that .

4.15: Atego’s Aonix ObjectAda:
Military Embedded Systems`Editor's Choice award:
Atego’s Aonix ObjectAda Real-Time®
for Windows
targeting Intel x86 architectures
running Wind River’s VxWorks RTOS
Atego is the recent merger between
Artisan Software Tools and Aonix.
mission-critical systems
safety-critical systems
software development tools;
allows all teams
-- architecture, systems, software
and hardware engineering --
to [Work as One]SM
- from concept through to
delivery, maintenance and support.

Artisan Software Tools
. the world’s largest independent supplier of
industrial-grade, collaborative modeling tools
for complex, mission and safety-critical systems and software
Artisan Studio®, supports OMG SysML™, UML®
and Architectural Frameworks.

Aonix ObjectAda Real-Time
consists of a fully compliant
ACATS 2.5 Ada 95 compiler .
. Aonix ObjectAda for VxWorks leverages
the Eclipse-based Wind River Workbench .
Aonix PERC® secure java vm for embedded systems .
4.30: web.addn/dev.ada/online studies:
. searched site:faculty.cs.wwu.edu/reedyc/CS141_Spring_2005
and site:faculty.cs.wwu.edu ada
for ada study materials .

graphics for google'knol

4.19: sci.addn/net.knol/graphic html is ok:
. does google'knol display picts from the web?
ie, can I create some html with graphics
that will work the same in a knol page
as it does from my desktop browser?
eg, will knol show links to picts
that are stored on the picasa website?
yes:
. I took an url from picasa
made an html image with adjusted size in seamonkey.composer,
and was able to paste-in that html
into knol's html mode .
(this practice image is in my knol home page)
. the tag, with a typical picasa url:
img style="width: 346px; height: 259px;" alt="dig-it!"
src="http://lh4.ggpht.com/_v2G-__eT7bA/S0lMhrqQ4vI/
AAAAAAAAAk0/kSx5k7V56lk/
IMG_2425%20spear%20 beside%20me%20shows%20depth%20of%20holes.jpg"

search function for google'knol

4.27: web.addn`gear/net.knol/search:

. google custom search; is it for knol?
google'cse (custom search engine):
doshdosh.com shows how to use it on your site:

. however, if your site is on knol,
do an author-specific knol'search:
. put a link on your page entitled:
[search my knol pages]
and link it to here(example my= philip-torrance's).

. this works much better than
google(site:knol.google.com/k/philip-torrance)
because that search misses some main content pages
and it links to many unrelated words
just because they are showing up in the side bar
which contains unrelated or duplicate trivia
by listing other pages by this author .

. there's an api for custom search:
[5.18: todo:
. could this be used for improving a knol search?]

2010-05-01

nui (natural user interface)

4.14: news.adde/nui (natural ui):

Don’t Over-Interpret Apple: Cross-Platform Development Isn’t a Sin
(a reference to Apple's disallowing code generators)
. Intua BeatMaker looks native,
but this app is built with a
cross-platform library, nui:
the multiplatform C++ API
for 3D hardware accelerated GUI .
. Yapuka.app is a NUI project generator for Xcode .
NUI (natural user interface):
. the GUI relied on metaphors for
interacting with on-screen content or objects.
The 'desktop' and 'drag' for example, being
metaphors for a visual interface
that ultimately was translated back into
the strict codified language of the computer.
The natural user interface removes the metaphors,
and many of the artificially learned devices,
to allow users to more directly manipulate content
using more Natural movements, motions and gestures.
. 'intuitively' describes how users interact with it.
. the seminal paper for post-WIMP interfaces
is Non Command User Interfaces .
. Michel Beaudouin-Lafon subsequently proposed
a framework called instrumental interaction(pdf),
that defines a design space for
Post-WIMP interaction techniques
and a set of properties for comparing them.
Examples of Post-WIMP interaction include
tui (touch ui):
. "(tui) can also stand text (lexically-graphical) ui;
it should be renamed to avoid confusion with touch ui; [5.1:
lui (lexical ui)? ]

2010-04-30

oop's dot notation

4.28: bk.adda/ada05`oop/why is dot notation needed?:
. didn't ada have a problem with needing oop's x.f
to avoid a redundancy problem with f(x) ?
. 05's rationale for oop syntax changes
is not compelling in adda's context:
. they noted that x.f can look a lot neater than f(x);
esp'ly in math formulae;
but, adda allows f x * ...
which means the same as f(x) * ... .
. they liked the fact that components and primitives
could be accessed with the same syntax .
. what should adda say x`f means?
the possessive character (`)
was supposed to remind one that
some modifications could be happening;
and, to offer a c.lang convenience like (x+= b)
-- which means x= x+b --
adda offers x`+ b .

parse pref's for stack-based eval's

4.26: adda/oop/parse pref's for stack-based eval's:
. whenever the type T has a lot of operations
(vs functions, ie, having a form like:
T->T, or TxT->T,
where all the arg's and returns
are all of the same type.class),
then it should be more efficient to
send it all as one call:
numstacker(output/.c, input#.c, opcode#.s) .
-- the arrays are constant,
so the call's parameter activation record
is just 3 ptr's
no matter how large the expression .
. there may also be a compiler advice function
that tells how to transform an etree
(expression tree)
to be most precisely eval'd;
but this might depend on current values?
. the type'mgt supplies a function:
parse(tree).tree
which the compiler uses to get advice of
special precedence or other type-specific rules .
. once the parse advice has been taken
the compiler stacks the etree:
ie, it loads an array
with the pointers to the arg's .

binary operator support for evolvers

4.25: adda/oop/biop'support for evolvers:

. unlike polymorphs such as type"number,
when an evolver gets a biop (binary operation),
it doesn't have a type'mgt that knows
who all its subtypes are,
so it doesn't know how to do conversions,
and can't delegate a biop call
to a particular subtype .

. one approach, though not generalizable,
is to have all biop methods be defined by
the root type,
and defined in terms of unary operations .
. all evolutions of that root type
would then inherit a working biop,
even if they had defined their own unary op's .

. the unary op's should provide code too,
just to be consistent?
ie, evolver subtyping involves complete impl'inheritance ?
[4.30:
. it should be up to the individual root.type
as to whether or not it chooses to
share a given method;
but if it wants the biop's to work
the way they do for polymorphs,
then it will provide the methods for all biop's .]

. a dynamic scripting approach,
like one might expect from a lisp system,
would be where all evolutions or subclasses
are allowed to read and modify
a supertype's biop-managing script .
. a subtype would register itself
and complete a table:
subclass x subclass x biops;
or, do whatever other rescripting was needed
in order handle the various combinations of subclasses
that are sent a biop message .

. a strategy for how to design evolvers
is to keep in mind why inheritance is good here:
it offers a form of type-checking
along with interface-based programming .
--[4.29: it offers nominal in addition to
structural subtype polymorphism (generics).]
. generics is when any type will do
if it supports the same interface
(I call these typeless obj's "(generals)).
. nominal type checking includes
the given type'name and all its descendants .
1130:
. the type'tag points to type'mgt
which is a node in a tree (or lattice);
that node has ptr's to all sources of inheritance .
. the 2 arg's of a biop must share
one or more supertypes,
and one of the supertypes must support that biop .
. if more than one?
[4.29: as when using multiple ada`packages,
the biop could be qualified to indicate
which node in the type.class lattice
the operation should be executed by .]
[4.30: qualifying an infix operator
could look rather confusing;
another option is raising an exception when
multi-inheritance is getting ambiguous .
. Ada05 allows multi-inheritance only with
interfaces (methods are not inherited,
and there's no concept of a biop).]


4.29: adda/oop/evolvers supporting biop's:

. what if an evolver wanted to inherit from a polymorph?
as long as adda promotes generics or interfaces .
[4.30:
. inheritance that expresses a
nominal subtype polymorphism
may not be good for contract-based prog'ing:
. types that support the same interface
could be modeling very different things;
so there should be a distinction made between
whether the model or the interface is supported .
eg, when I say the formal is a number,
I probably don't mean
the assigned obj'should do clock arithmetic
-- even if the interfaces are the same .]

. how does it support biop's ?
it needs to ask both arg's who their type'mgt is,
and see if they have a common superclass,
then see if any of them have a method for that biop .
but, num is a closed type, (not an evolver):
the biop it supports is not tolerating any
unrecognized subtype names .

. similar to the idea that there are
separate inheritances for interface and impl',
not every interface inheritance
has to imply the type is compatable with
the one it inherited from .

. just as polymorphs have some way of cooperating
in order do binary operations on various subtypes,
the evolvers need some universal way of describing value:
ie, the one job of the root.type
is having a way to define the supported values
in terms of some composition of public types;
[4.30: ie,
a subtype doesn't have to reveal how it stores a value,
but it does need to support exporting of a value
in some public form,
similar to offering a printed version
but instead of exporting as text,
it would be an efficient binary form .]
. for example,
number could describe its polymorphs
as an evolver would:
instead of subtypes knowing each other
and providing conversion routines,
the root.type, number,
could define a record of integers
(or a pointer to symbol in one case)
that describes all the parts of any number:
( mant'int#, [irrational]/ -- mantissa
, mant'frac'numerator#
, mant'frac'denominator#
, exp'int#, exp'frac# -- exponent
, sign'int#, sign'frac# -- large for complex numbers .
); [4.30:
. for types that are not numeric,
the root.type could express itself as
some tree of certain classes of symbols,
like the way english can be described,
with a grammar and a vocab' .]

. is that idea useful for the problem of
integrating popular notions of oop with biop's?

. the obj'c oop is assuming privacy from
even subclassers, not just clients;
therefore, any biop's must be defined in terms of
the superclass's unary op's .
. as shown by class"numbers,
there will be situations where only a
universal value format will be useful:
the biop will ask both arg's
to convert themselves to universal,
and then after working on a pair of univerals,
the biop can ask the receiver
to convert the universal to the type prefered;
[4.30: ie, within an evolver class,
one of the subtype's assignment functions
is expected to accept a universal-formatted value .]

live obj's have a guest.tag

4.25: adda/{oop, concurrency}/live obj's have a guest.tag:
. type.tags could be shorter than a ptr
by being a node-specific typeId#,
where the term "(node)
is supposed to conjure up the idea of networking
as being a collection of communicating modules .
. a node-based library is specific to
either a computer or a user account .
. if a live object is passed between nodes
then how is the typeId associated with
an implementation of a type'mgt?
[4.29:
. a live obj' is sent from a guest node
to a host node;
the guest-host handshake starts by
associating a type'name with the
type'mgt's body of code,
and after that,
the host can then refer to that type
using a pair of both the guest#,
and the obj's typeid# .
. the handshake ends with the host
telling the guest or the messaging system
what the guest's guestID# is .
. after that,
all obj's come in from a guestID#,
and all obj's contain a type.tag that's
understood within the context of a given guest .]

structural subtype polymorphism

4.25: adda/oop/structural subtype polymorphism:
. in addition to polymorphs and evolvers
there are generals, where type is not named;
instead,
the given obj' must support the same operations
as expected by the formal symbol
that the obj' was assigned to;
and, in order to show
where it's getting this support from,
the obj' must carry a type.tag;
this would be in addition to
a possible subtype tag that the type'mgt would use
to discriminate between a polymorph's subtypes .

polymorphic vs evolutionary subtyping

4.23: adda/oop/polymorphic vs evolutionary subtyping:

. the crux of subtyping is being
compatable with multiple types;
structural subtyping is allowing compatability between
any interfaces that share operations having
the same name and parameters;
nominal subtyping is where compatability is declared:
a subtype is compatible with its supertype
because it defined itself as supporting that supertype .
. the 2 types of nominal subtyping
are tentatively named here:
polymorphic subtyping, and
evolutionary subtyping .
. the term polymorphic refers to a single genome
that results in individuals of varying form;
eg, drones, queen, workers .
. evolution is about extending the capabilities
that were inherited .
. when considering the design of syntax for oop,
I noticed a difference between
{polymorphic subtyping (polymorphs)
, evolutionary subtyping (evolvers)
} that would cause their syntax to differ:
. the polymorphs are exemplified by the numbers,
which include the subtypes {Q,R,N,Z,C,...}.
. an obj' of type"number needs to recognize
all the binary operations (biop's)
that are recognized by any of its subtypes; [1]
this implies that a subtype's set of biop's
can never be an extension of
its supertype's biop set
-- it must instead be a subset .
. this is in stark contrast to evolvers
where a subclass's set of operations
come from not only inheriting those of superclass's
but also by declaration of new operations .
1:
proving (using number as an example)
the supertype of a polymorph needs to recognize
the union of all its subtypes' operations:
. any time a binary operation occurs on
on an arbitrary pair of subtypes of number,
the most general response must be
to ask the supertype how to handle
any combination of subtyping in
{Q,R,N,Z,C,...}x{Q,R,N,Z,C,...} .
. even though there may be biop's
that only one subtype can perform,
in the general case
-- with dynamically changing subtypes
and user-defined polymorphs --
the only modular approach
is to leave it up to the supertype
to decide on whether a pair of subtypes
can legally be used by a given biop .
. the alternative to modularity
is to reprogram the compiler
to know what the supertype's job is,
so that it can supply that code implicitely .
. that might make sense for numbers,
but can compilers be changed in the general case?
(eg, with plugins); otherwise,
polymorphs need to put that code
in their supertype's body .

. the compiler should be able to use
the supertype's body, in a high-level way,
for optimizing code;
eg, if every twin pair (M,M) results in
delegating the implementation to M's method,
then in-line code could include
a run-time check for whether a pair were twins .

subtype polymorphism replacing polymorphic records

4.22: adda/oop/subtype polymorphism replacing polymorphic records:

. the example in [cocoa patterns].book/hierarchy
of using a graphics tree to express subgraphics
reminded me of how expressions use trees:
. generic trees are intuitively implemented as
variant records, (I'm not sure why these aren't called
polymorphic records ...)
and, this had me realizing how oop subclasses
are using their subclass tag
as a variant record discriminant:
[4.28: for example,
an expression tree has an eval operation
for both the branch and leaf variants
of its variant record structure;
therefore, it's a candidate for replacement by
an oop structure:
the branch subclass's eval
has to eval all args's
then apply the given operation;
the leaf subclass's eval
has to return its immediate value .]
. in both the case of oop and of variant record,
the low-level implementation could involve
a tagged record:
a record where one of the fields
is a code indicating which variant or subclass
the current state belongs to .

. to see a record as an ADT (abstract datatype),
imagine its list of components rephrased as
the operations that come with those components .

. show how oop's subtype polymorphism can save space
the way a variant rec's polymorphism can .
[4.28: variant rec's assume
that the size of all variants
is known at compile time;
and if all the sizes are known to be
approx'ly the same,
then the implementation might use
an immediate placement
rather than a pointer .
. among oop cases, it's true for polymorphs (eg, numbers)
that the size of all variants is known at compile time;
but not generally true for evolvers
(because they can evolve after compile time)
so then, polymorphs can benefit from a
tag system that can indicate
whether the obj's placement is immediate
or found by a pointer .
. on the other hand, oop's polymorphism can be
a time waster:
if half the instances
implement an operation as null,
then it would be more efficient to
case the tag
and make the call only when the instance
supports that operation;
that, in fact,
is why oop allows both styles:
oop can do anything a variant record can
by allowing a client to ask an obj'
what subclass or variant
it currently belongs to .
. summary of variant discrimination
vs subclass polymorphism:
. every node visit can either case the tag
in order to decide on operations to apply;
or a visit can simply
use those operations that are
supported by every subclass .
so, when you ask an oop obj' to do an act,
you're asking a subtype
to do its version of the act .]

read-only subtypes

4.22: adda/oop/read only:
. the interface view of "(readonly)
is that the usual obj' has accessors
that allow both read and write .
[4.28:
. generally though, the obj's body defines
when operations are allowed to do modifications
so an instance needs a tag that indicates
whether this obj' should be changing,
and then methods that normally do any mod's
need to check this bit .]
. also,
the need for read-only subtyping is common;
so, for syntax,
something compact is needed, like the (!)
but that's still unresolved
since that clutters the (/) pointer symbol;
ie, you want it compact like c,
but you don't want c's reputation of looking like
math's full-blown greek .
[4.28:
. it could be changed by an editor preference,
where type T read-only was displayed either as
(T!) or (T-ROM) .]

cross-platform means a deep binding

4.11: news.adda/cross-platform means a deep binding:

summary:
. Apple is disallowing the use of code
that uses an intermediary translation
or compatibility layer .
. the important thing is that when intelligently done,
intermediary translations are no different than
people translating pseudocode to the target language .
. you'll know when it's intelligent
because they won't be able to enforce it .

rationale:
. this rule is just being fair to
dev's that spend the extra time
to get their code designed for efficiency;
Apple is acknowledging how important it is
to be first to market with an idea,
and if people are creating virtual machines
this will make it easy to be first to market
but at the expense of keeping the app' efficient .
. the xcode system will generate code that follows certain rules,
and it would not be easy to quality-check the app'
unless the code is following those rules .

rationale @ daringfireball.net
. what Apple does not want
is for some other company to establish a
de facto standard software platform
on top of Cocoa Touch.
Consider a world where some other company’s
cross-platform toolkit proved wildly popular.
Then Apple releases major new features to iPhone OS,
and that other company’s toolkit is slow to adopt them.
At that point, it’s the other company
that controls when third-party apps
can make use of these features.

co.android alerts dev's to Apple's major change .

daringfireball.net 8 April 2010
. section 3.3.1 of the iPhone Developer Program License Agreement:
Applications may only use Documented APIs
in the manner prescribed by Apple
and must not use or call any private APIs.
. the 4.0 SDK beta now adds:
Applications must be originally written in
Objective-C, C, C++, or JavaScript (iPhone OS WebKit engine)
and only code written in C, C++, and Objective-C
may compile and directly link against the Documented APIs
(e.g., Applications that link to Documented APIs
through an intermediary translation
or compatibility layer or tool
are prohibited).
Steve Jobs explains:
“intermediate layers between platform and dev'
ultimately produces sub-standard app's
and hinders the progress of the platform.”
a response:
. it doesn’t make sense to limit
source-to-source conversion tools like Unity3D
--
unity3d creates a complete XCode project that just works!
. using iPhone Remote,
you can use an actual iPhone or iPod Touch device
to view and test your game live,
right from the Unity Editor. [using javascript on the web]
--
Unity3d's CEO:
. In the ancient days of the App Store (July 2008),
Apple very late changed the kernel to disallow
JIT (just-in-time) compilation.
What we did instead was spend several months
changing Mono to compile scripts
AOT (ahead of time) instead
(this is why some dynamic constructs in our JavaScript
doesn’t work on the iPhone).
my response:
. if Unity3D is disallowed,
at least they are ahead with a source-to-source tool;
now all they have to do is make it a deep binding:
convert their graphics library functions calls
directly into cocoa graphics calls .

4.29:
. the mac#iphone expects code to follow the idioms,
and this is achieved by very intelligent transforms:
adda code -> mac idioms .
. each platform needs its own adda backend;
adda's oop system should not be concerned with
having a shallow binding to various other oop systems .
. adda's front end should turn human ideas into
expression trees that can be analyzed by computer,
rather than using the idioms of a given platform;
and then,
adda's backend for the mac#iphone
should be able to translate human ideas to
iphone`particulars
-- the same way a programmer does
(this is the sort of work lisp was invented for).

4.30: my response after reviewing the issue:

Ludd·ite:
Pronunciation: \App'll\
Function: noun
Etymology: perhaps from Ned Ludd, 18th century Leicestershire workman
who destroyed a knitting frame
Date: 1811
. one of a group of early 19th century English workmen
destroying laborsaving machinery as a protest;
broadly : one who is opposed to especially technological change .
— Luddite adjective .

Air Vehicle c coding standards compete with Ada

4.8: news.adda/av c++ coding standards:

stn vol3#1 p36/c can be safe too!
. while Ada is the technically superior
and more robust language compared to C,
-- where anything can be type-cast into anything,
type-casting was a problem with
hiring college students for Ada coding:
it was seen as an unmarketable experience base .
. reliability issues with C
have been due only to
the way in which it was used;
however,
another possible problem with C
comes at the time of inspection,
when some code reviewers may find Ada
to be more self-documenting .

. the auto industry had a safe-subset standard for c;
and the F-22 used static code analyzer (SCA) tools
to enforce restriction to a safe-subset of Ada 83 .
. with the same idea in mind,
the F-35 Joint Strike Fighter found a safe subset
of both C and C++ for the safety critical systems
developed by the team of Lockheed Martin Aeronautics,
Northrop Grumman Aerospace, BAE Systems
and the F-35 supplier team.
. the F-16 had safety-critical software
that was all assembly coded,
and some of their team helped the F-35 team with
deploying a safe subset of c
-- both c and asm are similarly low-level lang's .

. an SCA tool's analyzer is like an observer
in a pair programming operation:
a much faster way of getting up to speed
than learning a new language like Ada .
--. after reading that,
I wondered how many C cowboys from college
were still banging their head on restricted C ?
(either the 216 new rules in the form of compiler spit,
or a 140 more pages of manual ...).

air vehicle c++ coding standards (doc) (google's cache)
. less-critical portions of Air Vehicle (AV) code
will be developed in C++
(safety-critical portions are to be in C);
the air vehicle c++ coding standards
provide safe, reliable, testable, and maintainable
C++ programming .
. these rules are required for all
Air Vehicle C++ development
and recommended for any
non-Air Vehicle C++ development.
Vehicle Systems Safety Critical Coding Standards for C,
is based on:
MISRA Guidelines (Motor Industry Software Reliability Assoc)
For The Use Of The C Language In Vehicle Based Software,
but is providing a more comprehensive set
of language restrictions
applied more uniformly across
all Vehicle Systems safety critical applications.
. AV Coding Standards build on the
Vehicle Systems Safety Critical Coding Standards for C,
by including:
C++ language-specific guidelines and standards.

. unit testing with full structural coverage
is typically done only at the source level
for non-critical code .
. but since compilation to object code
will result in some structural changes
as high-level control structures
are translated to a maze of goto's,
safety-critical code is also
unit-tested at the object level .
. that precaution has even found
some compiler bugs!

. it may seem more efficient to do Ada's practice
of validating one compiler per platform,
rather than unit-testing every translation;
in fact,
Ada compiler validation
has been for language enforcement only:
any safety-critical code for
military, aviation, [or medical?]
is routinely unit-tested at the object level
regardless of what language (Ada, C, ...)
the compiler was translating .

. from seeing how things went on the F-35 project,
the F-22 maint crew, when switching to new cpu's,
decided to convert their code base from Ada 83 to C .

soon-to-be-Dr. Robb at lockheedmartin.com
--. watch the F-35 do its first vertical landing(video) .

2010-04-01

battery-saving architecture

3.27: addx/batt'saving architecture:

notifications:
. without notification systems or hardware interrupts
ipc (interprocess communication) requires
a polling loop which uses power all the time
just checking for whether anything needs power!
. notifications work by having service agents
tell the os what they are checking for,
and then the os will call them back when it happens .

power-saving mode:
. another needed control system is batt'savings mode;
because, agents can provide
higher levels of service if they know
whether the user has nearby access to more batt's .

. services can vary their levels of service by
putting optional services in a separate thread,
and then marking that thread as optional
which then affects its scheduling priority .
. the user can indicate how much to conserve,
and then the system sets a power.conserve.flag .
. the scheduler can use that flag
to adjust the way it schedules the optionals .

. put all optional work on a todo,
else if it's now-or-never,
tell the user what's not being done
while on min drain mode .
. another option while employing a user agent
is letting the agent handle the annoying,
repetitive questions from a service .

. the os uses the average recent rates of cpu useage
to estimate relative batt'life or work levels .
. the os also considers batt's charge age:
if the batt' is near the end of life,
then optional services should be cut anyway
since being in that state worsens the amount of
batt'drain per work done .

. if the system is working more than minimally,
it can then ask the user
whether they'd rather have more batt'life .
. it could do this with an alert
or an on-going notification (animated icons)
for both work intensity and remaining energy;
but, on some systems,
the remaining energy is not easy to measure .