Code Monkey home page Code Monkey logo

Comments (10)

emberian avatar emberian commented on May 20, 2024 2

Why is it big endian by default anyway?

from bincode.

aldanor avatar aldanor commented on May 20, 2024 1

There's a few equally valid choices here; I personally think it's also important to be able to serialise with native endianness (use case: serialising a sequence of structs to disk and them reading them back via python/numpy or other process on the same box/cpu which would use the native byte order by default). byteorder already provides NativeEndian so that's easy.

Off top of my head, I would probably expect a binary serialisation library to use native byte order unless explicit endianness is specified by the user. This has most chances to work for careless cross-process communication. Second best would be little endian since that's what all Intel CPUs are... most unexpected would probably be big endian (for general-purpose encoding/decoding, that is).

I wouldn't mind having to provide endianness explicitly though, until 213 lands (if it lands); then it's a separate choice of selecting a sensible default :)

from bincode.

TyOverby avatar TyOverby commented on May 20, 2024

@cmr: something about network byte order. Was probably a mistake. In the next breaking change I'll likely fix it.

from bincode.

aldanor avatar aldanor commented on May 20, 2024

Looking forward to this as well. It looks like RFC 213 is a good while from being stabilised due to uncertainty re: integer fallback, so maybe providing an explicit endianness parameter (or type parameter), or even encode_be(), encode_le() would be great.

from bincode.

TyOverby avatar TyOverby commented on May 20, 2024

@aldanor

What would you think about having the default methods use big-endian, but have an module with endian-choice methods?

once 213 lands, it would be easy to deprecate that module, but in the meantime, it wouldn't hurt new users that don't care about endianness.

Or maybe choosing endianness isn't that big of a deal and we should just make everyone do it until default method parameters land?

from bincode.

mikedilger avatar mikedilger commented on May 20, 2024

I'd be using this too. I'd be happy with a temporary separate module.

from bincode.

TyOverby avatar TyOverby commented on May 20, 2024

Honestly I'm leaning towards explicit endianness right now. It doesn't seem like a huge hit to usability and makes it pretty obvious what's going on.

from bincode.

TyOverby avatar TyOverby commented on May 20, 2024

I'm just hoping that I don't get hit with bugs from people using different endianness for encoding and decoding...

from bincode.

burdges avatar burdges commented on May 20, 2024

In C, there is a slight advantage to using "network byte order" aka big endian because you must write every endian conversion manually, so if you leave one out then it breaks on your little endian development machine, but this does not apply to Rust. In Rust, one should probably specify the endianness in a type parameter, not sure all type parameters accept defaults though.

from bincode.

aldanor avatar aldanor commented on May 20, 2024

cf. #103

from bincode.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.