Re: [Cbor] Self Described CBOR - Little Endian

Carsten Bormann <cabo@tzi.org> Wed, 24 March 2021 20:27 UTC

Return-Path: <cabo@tzi.org>
X-Original-To: cbor@ietfa.amsl.com
Delivered-To: cbor@ietfa.amsl.com
Received: from localhost (localhost [127.0.0.1]) by ietfa.amsl.com (Postfix) with ESMTP id 9EAC93A3578 for <cbor@ietfa.amsl.com>; Wed, 24 Mar 2021 13:27:09 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -1.899
X-Spam-Level:
X-Spam-Status: No, score=-1.899 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no
Received: from mail.ietf.org ([4.31.198.44]) by localhost (ietfa.amsl.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id UFn8Cyd9Vy2j for <cbor@ietfa.amsl.com>; Wed, 24 Mar 2021 13:27:05 -0700 (PDT)
Received: from gabriel-vm-2.zfn.uni-bremen.de (gabriel-vm-2.zfn.uni-bremen.de [134.102.50.17]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ietfa.amsl.com (Postfix) with ESMTPS id 0F68A3A3575 for <cbor@ietf.org>; Wed, 24 Mar 2021 13:27:05 -0700 (PDT)
Received: from [192.168.217.118] (p548dc178.dip0.t-ipconnect.de [84.141.193.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by gabriel-vm-2.zfn.uni-bremen.de (Postfix) with ESMTPSA id 4F5KXQ45ZVzyXX; Wed, 24 Mar 2021 21:27:02 +0100 (CET)
Content-Type: text/plain; charset="utf-8"
Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.120.23.2.4\))
From: Carsten Bormann <cabo@tzi.org>
In-Reply-To: <ED83658C-0602-4845-AD5B-9850F803BDD7@cursive.net>
Date: Wed, 24 Mar 2021 21:27:01 +0100
Cc: "cbor@ietf.org" <cbor@ietf.org>
X-Mao-Original-Outgoing-Id: 638310421.904785-8e9eb1af8b978f138e8d79f64733cbf9
Content-Transfer-Encoding: quoted-printable
Message-Id: <5513CABE-CDD5-411B-9FA9-8E1D631BB173@tzi.org>
References: <BY5PR20MB2898CBA491A4C0AED983C81CD2649@BY5PR20MB2898.namprd20.prod.outlook.com> <113AF95E-4048-4093-AC07-44B9E1E3DB0B@felipegasper.com> <ED83658C-0602-4845-AD5B-9850F803BDD7@cursive.net>
To: Joe Hildebrand <hildjj@cursive.net>
X-Mailer: Apple Mail (2.3608.120.23.2.4)
Archived-At: <https://mailarchive.ietf.org/arch/msg/cbor/u2g0WHxjVdvJGOzQAV-ZU72XGvc>
Subject: Re: [Cbor] Self Described CBOR - Little Endian
X-BeenThere: cbor@ietf.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: "Concise Binary Object Representation \(CBOR\)" <cbor.ietf.org>
List-Unsubscribe: <https://www.ietf.org/mailman/options/cbor>, <mailto:cbor-request@ietf.org?subject=unsubscribe>
List-Archive: <https://mailarchive.ietf.org/arch/browse/cbor/>
List-Post: <mailto:cbor@ietf.org>
List-Help: <mailto:cbor-request@ietf.org?subject=help>
List-Subscribe: <https://www.ietf.org/mailman/listinfo/cbor>, <mailto:cbor-request@ietf.org?subject=subscribe>
X-List-Received-Date: Wed, 24 Mar 2021 20:27:10 -0000

On 2021-03-24, at 21:09, Joe Hildebrand <hildjj@cursive.net> wrote:
> 
> The `s390x/node` docker image emulates big endian (slowly), and includes Perl 5.24.1
> 
> I test with "docker run --rm -it -v ${PWD}:/root/cbor -w /root/cbor s390x/node npm test”

I used to have an iBook (PowerPC CPU, run as big-endian) set up as a CI system…

But to answer the original question, CBOR is big-endian because IETF protocols generally are.  Creating a little-endian fork of CBOR wouldn’t really help that much.  (Turns out my (endian-independent) code is usually shorter for big-endian transfer than it is for little-endian — remember that you'll have to byte-shift the numbers anyway to maintain alignment on the decoded side, so it’s not that much more effort to arrange them.)  And it would hurt a lot; even with a magic number in front of it (see [1] for our current view of how magic numbers for CBOR-based file encodings should look like).

Grüße, Carsten

[1]: https://www.ietf.org/archive/id/draft-ietf-cbor-file-magic-00.html