Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.arch.embedded > #26726

Re: Portable Assembly

From Don Y <blockedofcourse@foo.invalid>
Newsgroups comp.arch.embedded
Subject Re: Portable Assembly
Date 2017-06-06 07:03 -0700
Organization A noiseless patient Spider
Message-ID <oh6che$1pm$1@dont-email.me> (permalink)
References <ogckfb$qcb$1@dont-email.me> <op.y07n39ubj0diun@thanatos.lan> <oh3qeq$7lt$1@news2.open-news-network.org> <oh3vin$npm$1@dont-email.me> <606cjc9l3kkpjq48efls9ddr8cqe8tc5aa@4ax.com>

Show all headers | View raw


Hi George,

Snow melt, yet?  :>  (105+ here, all week)

On 6/5/2017 9:24 PM, George Neuner wrote:
> On Mon, 5 Jun 2017 09:10:10 -0700, Don Y <blockedofcourse@foo.invalid>
> wrote:
>
>> C's portability problem isn't with the language, per se, as much as it is
>> with the "practitioners".  It could benefit from much stricter type
>> checking and a lot fewer "undefined/implementation-defined behaviors"
>> (cuz it seems folks just get the code working on THEIR target and
>> never see how it fails to execute properly on any OTHER target!)
>
> The argument always has been that if implementation defined behaviors
> are locked down, then C would be inefficient on CPUs that don't have
> good support for <whatever>.

Of course.  When you design a language, you seek to optimize some set
of *many* (often conflicting) design criteria.  Do you want it to be
portable?  Deterministic?  Require minimal keystrokes?  Lead to
pronounceable code?  etc.

Most "programmers" like to consider themselves "artists" -- in the same
vein as authors/novelists.  The fewest constraints on the way we practice
our craft (art?).  Imagine if all novels *had* to be written composed entirely
of simple sentences built in a subject-predicate order.  Or, if every subject
had to be proper noun, etc.

Alternatively, you can try to constrain the programmer (protect him from
himself) and *hope* he's compliant.

Of course, the range of applications is also significant.  A language
intended for scripting has a different set of goals than one that can
effectively implement an OS, etc.

> Look at the (historical) troubles resulting from Java (initially)
> requiring IEEE-754 compliance and that FP results be exactly
> reproducible *both* on the same platform *and* across platforms.
>
> No FP hardware fully implements any version of IEEE-754: every chip
> requires software fixups to achieve compliance, and most fixup suites
> are not even complete [e.g., ignoring unpopular rounding modes, etc.].
> Java FP code ran slower on chips that needed more fixups, and the
> requirements prevented even implementing a compliant Java on some
> chips despite their having FP support.
>
> Java ultimately had to entirely back away from its reproducibility
> guarantees.  It now requires only best consistency - not exact
> reproducibility - on the same platform.  If you want reproducible
> results, you have to use software floating point (BigFloat), and
> accept much slower code.  And by requiring consistency, it can only
> approximate the performance of C code which is likewise compiled. Most
> C compilers allow to eshew FP consistency for more speed ... Java does
> not.
>
> Of course, FP in general is somewhat less important to this crowd than
> to other groups, and C has a lot of implementation defined behavior
> unrelated to FP.  But the lesson of trying to lock down hardware
> (and/or OS) dependent behavior still is important.

Yes.  But this moves the languages design choices on the axis
AWAY from (inherent) "portability".

You can write "portable" code, in C -- but, it requires a conscious decision
to do so (and a fair bit of practice to do so WELL).

And, what does it mean to claim some piece of code is "portable"?  That
it produces the same results without concern for resource usage, execution
speed, code size, etc.?  (who decided that THOSE criteria were more/less
important?)

For example, My BigDecimal package will tailor itself to the size of the
largest integer data type in the target.  But, this is often NOT what you
would want (it tends to make larger BigDecimals more space efficient), esp
on smaller machines!  E.g., on a 16b machine, there might be support for
ulonglong's that my code will exploit... but, if the inherent data type
is "ushort" and all CPU operations are geared towards that size data,
there will be countless "helper routines" invoked just to let my code
use these "unnaturally large" data types, even if they do so inefficiently
(and the code could have just as easily tailor itself to a data size closer
to ushort)

> There is no question that C could do much better type/value and
> pointer/index checking, but it likely would come at the cost of far
> more explicit casting (more verbose code), and likely many more
> runtime checks.

And, more contortions from programmers trying to "work-around" those
checks ("Yeah, I *want* to dereference NULL!  I want to 'jump 0x0000'")

> A more expressive type system would help [e.g., range integers, etc.],
> but that would constitute a significant change to the language.
>
> Some people point to Ada as an example of a language that can be both
> "fast" and "safe", but many people (maybe not in this group, but many
> nonetheless) are unaware that quite a lot of Ada's type/value checks
> are done at runtime and throw exceptions if they fail.

IME, that's the only way to get the degree of checking you *want*
(i.e., you, as an individual programmer on a specific project coding
a particular algorithm).  But, that voids many tools designed to protect
you from these evils.

> Obviously, a compiler could provide a way to disable the automated
> runtime checking, and even when enabled checks can be elided if the
> compiler can statically prove that a given operation will always be
> safe.  But even in Ada with its far more expressive types there are
> many situations in which the compiler simply can't do that.
>
> More stringent languages like ML won't even compile if they can't
> statically type check the code.  In such languages, quite a lot of
> programmer effort goes toward clubbing the type checker into
> submission.

I'd considered coding my current project in C++ *just* for the
better type-checking.

E.g., I want new types to be syntactically treated as different
types, not just aliases:

typedef long int handle_t;        // reference for an OS object
typedef handle_t file_handle_t;   // reference for an OS *file* object
typedef handle_t lamp_handle_t;   // reference for an OS lamp object

extern turn_on(lamp_handle_t theLamp);
extern unlink(file_handle_t theFile);

main()
{
    file_handle_t aFile;
    lamp_handle_t aLamp;

    ...  // initialization

    turn_on( (lamp_handle_t) aFile);
    unlink( (file_handle_t) aLamp);
}

should raise eyebrows!

Add the potential source of ambiguity that the IDL can introduce
and its too easy for an "uncooperative" developer to craft code
that is way too cryptic and prone to errors.

Imagine poking bytes into a buffer called "stack_frame" and
then trying to wedge it "under" a function invocation...
sure, you can MAKE it work.  But, will you know WHY it works,
next week??

Back to comp.arch.embedded | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Portable Assembly rickman <gnuarm@gmail.com> - 2017-05-27 15:39 -0400
  Re: Portable Assembly Grant Edwards <invalid@invalid.invalid> - 2017-05-27 21:05 +0000
    Re: Portable Assembly Mel Wilson <mwilson@the-wire.com> - 2017-05-27 21:29 +0000
    Re: Portable Assembly upsidedown@downunder.com - 2017-05-28 00:36 +0300
      Re: Portable Assembly Grant Edwards <invalid@invalid.invalid> - 2017-05-27 21:56 +0000
        Re: Portable Assembly Hans-Bernhard Bröker <HBBroeker@t-online.de> - 2017-05-28 14:36 +0200
      Re: Portable Assembly David Brown <david.brown@hesbynett.no> - 2017-05-29 09:53 +0200
  Re: Portable Assembly Les Cargill <lcargill99@comcast.com> - 2017-05-27 16:17 -0500
    Re: Portable Assembly Dimiter_Popoff <dp@tgi-sci.com> - 2017-05-28 00:31 +0300
      Re: Portable Assembly Theo Markettos <theom+news@chiark.greenend.org.uk> - 2017-05-27 22:52 +0100
        Re: Portable Assembly Grant Edwards <invalid@invalid.invalid> - 2017-05-27 21:58 +0000
          Re: Portable Assembly upsidedown@downunder.com - 2017-05-28 07:37 +0300
            Re: Portable Assembly rickman <gnuarm@gmail.com> - 2017-05-28 01:28 -0400
            Re: Portable Assembly Tom Gardner <spamjunk@blueyonder.co.uk> - 2017-05-28 07:33 +0100
              Re: Portable Assembly rickman <gnuarm@gmail.com> - 2017-05-28 03:22 -0400
                Re: Portable Assembly Tom Gardner <spamjunk@blueyonder.co.uk> - 2017-05-28 08:49 +0100
                Re: Portable Assembly upsidedown@downunder.com - 2017-05-28 15:03 +0300
          Re: Portable Assembly Tauno Voipio <tauno.voipio@notused.fi.invalid> - 2017-05-28 12:26 +0300
        Re: Portable Assembly Dimiter_Popoff <dp@tgi-sci.com> - 2017-05-28 01:04 +0300
        Re: Portable Assembly David Brown <david.brown@hesbynett.no> - 2017-05-29 10:43 +0200
          Re: Portable Assembly Anssi Saari <as@sci.fi> - 2017-05-31 10:19 +0300
            Re: Portable Assembly Don Y <blockedofcourse@foo.invalid> - 2017-05-31 01:49 -0700
            Re: Portable Assembly Tauno Voipio <tauno.voipio@notused.fi.invalid> - 2017-05-31 15:56 +0300
        Re: Portable Assembly Don Y <blockedofcourse@foo.invalid> - 2017-05-29 02:33 -0700
          Re: Portable Assembly upsidedown@downunder.com - 2017-05-29 23:46 +0300
            Re: Portable Assembly Don Y <blockedofcourse@foo.invalid> - 2017-05-29 13:54 -0700
      Re: Portable Assembly Don Y <blockedofcourse@foo.invalid> - 2017-05-27 15:52 -0700
        Re: Portable Assembly Dimiter_Popoff <dp@tgi-sci.com> - 2017-05-28 02:14 +0300
          Re: Portable Assembly Don Y <blockedofcourse@foo.invalid> - 2017-05-27 17:14 -0700
            Re: Portable Assembly Dimiter_Popoff <dp@tgi-sci.com> - 2017-05-28 03:38 +0300
              Re: Portable Assembly Don Y <blockedofcourse@foo.invalid> - 2017-05-27 18:42 -0700
      Re: Portable Assembly Stefan Reuther <stefan.news@arcor.de> - 2017-05-28 18:45 +0200
        Re: Portable Assembly Dimiter_Popoff <dp@tgi-sci.com> - 2017-05-28 20:47 +0300
          Re: Portable Assembly Stefan Reuther <stefan.news@arcor.de> - 2017-05-29 18:43 +0200
            Re: Portable Assembly Don Y <blockedofcourse@foo.invalid> - 2017-05-29 10:23 -0700
            Re: Portable Assembly "Boudewijn Dijkstra" <sp4mtr4p.boudewijn@indes.com> - 2017-05-30 16:31 +0200
        Re: Portable Assembly Grant Edwards <invalid@invalid.invalid> - 2017-05-29 01:59 +0000
          Re: Portable Assembly Dimiter_Popoff <dp@tgi-sci.com> - 2017-05-29 05:21 +0300
      Re: Portable Assembly Les Cargill <lcargill99@comcast.com> - 2017-05-28 22:04 -0500
        Re: Portable Assembly Don Y <blockedofcourse@foo.invalid> - 2017-05-29 02:57 -0700
      Re: Portable Assembly David Brown <david.brown@hesbynett.no> - 2017-05-29 11:00 +0200
        Re: Portable Assembly Dimiter_Popoff <dp@tgi-sci.com> - 2017-05-29 15:08 +0300
          Re: Portable Assembly David Brown <david.brown@hesbynett.no> - 2017-05-29 15:06 +0200
            Re: Portable Assembly Dimiter_Popoff <dp@tgi-sci.com> - 2017-05-29 20:02 +0300
              Re: Portable Assembly David Brown <david.brown@hesbynett.no> - 2017-05-29 23:13 +0200
                Re: Portable Assembly Dimiter_Popoff <dp@tgi-sci.com> - 2017-05-30 16:53 +0300
                Re: Portable Assembly David Brown <david.brown@hesbynett.no> - 2017-05-31 11:36 +0200
                Re: Portable Assembly Dimiter_Popoff <dp@tgi-sci.com> - 2017-06-01 22:43 +0300
                Re: Portable Assembly David Brown <david.brown@hesbynett.no> - 2017-06-02 13:27 +0200
          Re: Portable Assembly Grant Edwards <invalid@invalid.invalid> - 2017-05-29 13:48 +0000
    Re: Portable Assembly Don Y <blockedofcourse@foo.invalid> - 2017-05-27 15:46 -0700
    Re: Portable Assembly Tim Wescott <tim@seemywebsite.really> - 2017-05-28 23:59 -0500
  Re: Portable Assembly Dimiter_Popoff <dp@tgi-sci.com> - 2017-05-28 00:23 +0300
  Re: Portable Assembly jim.brakefield@ieee.org - 2017-05-27 16:54 -0700
  Re: Portable Assembly Walter Banks <walter@bytecraft.com> - 2017-05-29 17:23 -0400
  Re: Portable Assembly "Boudewijn Dijkstra" <sp4mtr4p.boudewijn@indes.com> - 2017-06-02 17:03 +0200
    Re: Portable Assembly Mike Perkins <spam@spam.com> - 2017-06-05 15:39 +0100
      Re: Portable Assembly David Brown <david.brown@hesbynett.no> - 2017-06-05 18:10 +0200
      Re: Portable Assembly Don Y <blockedofcourse@foo.invalid> - 2017-06-05 09:10 -0700
        Re: Portable Assembly George Neuner <gneuner2@comcast.net> - 2017-06-06 00:24 -0400
          Re: Portable Assembly David Brown <david.brown@hesbynett.no> - 2017-06-06 11:05 +0200
          Re: Portable Assembly Don Y <blockedofcourse@foo.invalid> - 2017-06-06 07:03 -0700
            Re: Portable Assembly David Brown <david.brown@hesbynett.no> - 2017-06-06 16:58 +0200
              Re: Portable Assembly Tauno Voipio <tauno.voipio@notused.fi.invalid> - 2017-06-06 21:26 +0300
            Re: Portable Assembly George Neuner <gneuner2@comcast.net> - 2017-06-06 16:42 -0400
              Re: Portable Assembly Don Y <blockedofcourse@foo.invalid> - 2017-06-06 23:16 -0700
                Re: Portable Assembly George Neuner <gneuner2@comcast.net> - 2017-06-08 06:38 -0400
                Re: Portable Assembly Dimiter_Popoff <dp@tgi-sci.com> - 2017-06-08 15:58 +0300
                Re: Portable Assembly upsidedown@downunder.com - 2017-06-08 21:34 +0300
                Re: Portable Assembly Les Cargill <lcargill99@comcast.com> - 2017-06-10 15:27 -0500
                Re: Portable Assembly Les Cargill <lcargill99@comcast.com> - 2017-06-10 15:23 -0500
                Re: Portable Assembly Tom Gardner <spamjunk@blueyonder.co.uk> - 2017-06-08 14:50 +0100
                Re: Portable Assembly Tauno Voipio <tauno.voipio@notused.fi.invalid> - 2017-06-08 17:38 +0300
                Re: Portable Assembly Tom Gardner <spamjunk@blueyonder.co.uk> - 2017-06-08 16:37 +0100
                Re: Portable Assembly George Neuner <gneuner2@comcast.net> - 2017-06-09 14:14 -0400
                Re: Portable Assembly Tom Gardner <spamjunk@blueyonder.co.uk> - 2017-06-09 22:25 +0100
                Re: Portable Assembly Clifford Heath <no.spam@please.net> - 2017-06-10 09:54 +1000
                Re: Portable Assembly Don Y <blockedofcourse@foo.invalid> - 2017-06-09 00:06 -0700
                Re: Portable Assembly George Neuner <gneuner2@comcast.net> - 2017-06-09 22:14 -0400
                Re: Portable Assembly Don Y <blockedofcourse@foo.invalid> - 2017-06-09 22:50 -0700
                Re: Portable Assembly George Neuner <gneuner2@comcast.net> - 2017-06-10 21:01 -0400
                Re: Portable Assembly Don Y <blockedofcourse@foo.invalid> - 2017-06-11 00:39 -0700
                Re: Portable Assembly George Neuner <gneuner2@comcast.net> - 2017-06-12 23:27 -0400
                Re: Portable Assembly Don Y <blockedofcourse@foo.invalid> - 2017-06-12 22:42 -0700
                Re: Portable Assembly Ed Prochak <edprochak@gmail.com> - 2017-06-13 14:24 -0700
                Re: Portable Assembly Don Y <blockedofcourse@foo.invalid> - 2017-06-13 21:57 -0700
                Re: Portable Assembly Reinhardt Behm <rbehm@hushmail.com> - 2017-06-14 13:26 +0800
                Re: Portable Assembly Don Y <blockedofcourse@foo.invalid> - 2017-06-13 23:58 -0700
                Re: Portable Assembly Ed Prochak <edprochak@gmail.com> - 2017-06-19 06:48 -0700
                Re: Portable Assembly Don Y <blockedofcourse@foo.invalid> - 2017-06-19 16:45 -0700
                Re: Portable Assembly Ed Prochak <edprochak@gmail.com> - 2017-06-20 15:07 -0700
                Re: Portable Assembly Don Y <blockedofcourse@foo.invalid> - 2017-06-21 07:37 -0700
              Re: Portable Assembly David Brown <david.brown@hesbynett.no> - 2017-06-07 09:20 +0200
          Re: Portable Assembly Niklas Holsti <niklas.holsti@tidorum.invalid> - 2017-06-07 00:30 +0300
            Re: Portable Assembly George Neuner <gneuner2@comcast.net> - 2017-06-07 02:02 -0400

csiph-web