Appropriate high-level binary processing language

I need to write a small tool that parses text input and generates some binary encoded data. I would rather stay away from C and the like, in favor of a higher level (optional) of a safer, more expressive and faster development of the language.

My choice language for this kind of task is usually Python, but for this case, processing binary source data can be problematic if you are not very careful with numbers that advance to bignums, signature extensions, etc.

Ideally, I would like to have records with named bit fields that are portable for sequential sequential processing.

(I know that there is a strong side to this in a language that I have already mastered, although this is not optimal, but I think this may be a good opportunity to learn something new).

Thanks.

+4
source share
6 answers

Oddly enough, I think Erlang might fit the bill. Ignoring, if you do not want to use them, parallel tools, it has its own tools for processing bit strings very easily. Examine the documentation under the term bit syntax.

+4
source

The second time I voted for Erlang; Despite its oddities, it has excellent support for bit-level binary data control. (As you might expect, this is a telecommunications language.) Another language worth paying attention to is PADS , which is a more specialized language (also from the telecommunications industry) designed for high-speed ad hoc data processing. I believe PADS supports binary data, but I cannot swear.

+3
source

If you want to stay in Python, this is a bitstring option that removes most of the pain when working with binary data.

It's pretty simple to build and analyze arbitrary binary structures, so it might be worth a look if Erlang doesn't work for you!

+2
source

Ada has a lot of support for these kinds of low-level data representations, as you described, in the form of presentation clauses for data types. See for example

http://www.adaic.org/standards/05rm/html/RM-13-5-1.html

With view suggestions, you can determine the exact location and alignment (if necessary) for all your data in a portable way. Similarly, it is very easy to change the view, for example, for performance purposes, for example. using booleans stored as bits and machine destinations.

+2
source

IMP, itโ€™s faster to use a language that you already know. If you do not want to learn a new language for fun.

0
source

C structures are one of the main points of this kind of thing. If you don't like the rest of the language, you can define your data formats in C and all your Python access code and bridge the gap with SWIG . I have not used SWIG, so I donโ€™t know how far you can get it to work. If you cannot do all the code in Python, you can put small bits (WriteStructToFile, etc.) in C, as they can be very small and well-defined.

0
source

Source: https://habr.com/ru/post/1307693/


All Articles