ATTENTION: You are viewing a page formatted for mobile devices; to view the full web page, click HERE.

Other Software > Developer's Corner

Best Language For Binary Parsing?

(1/2) > >>

Ehtyar:
Hi all.
If you needed to parse some binary data (for examples, PE headers), what scripting language would you use and why? I've seen a few in Python (though they've all been too complex what I require), though I would probably be more comfortable in Perl. Anyway, I just wanted to see if anyone had any opinions before I start investing too much time in it. Any suggestions are welcome.

Thanks for any replies, Ehtyar.

Ehtyar:
Well, as one might imagine, a dynamically typed language makes for quite a nightmare in attempting to parse binary data. Usually you've got either a string or an int, and usually when reading from a file, you get a string.
There was a lot of ord(), a lot of pack()/unpack(), a lot of sprintf() and a lot of split()/join(), but I've managed it in Perl in a most un-elegant manner which I'm entirely unhappy with. Ironically, where I would have liked a scripting language, a compiled one would have suited far better (when will someone make a C script that is usable).I was going to try it in Python also, but I'm now painfully aware that Python would be just as difficult-a-language to write this in as Perl.
To rephrase my original question, is anyone aware of a statically typed scripting language that I could possible employ in this endeavor?

Thanks, Ehtyar.

mouser:
because python is so closely tied to an underlying base of C code and exposes most of it, i would think python could be a good option.

scancode:
Euphoria (1, 2) seems well suited for the task. Just load the file on a sequence and hack away :)

Ehtyar:
For the uninformed, I spoke to Mouse Man and Scan Man outside of the forum, and unfortunately Python's typing is not quite strong enough, and while Euphoria appears to be strongly typed, it is mostly superficial.
My solution came in the form of C#, believe it or not. When I came across the BinaryReader class I did some further investigation (because who would not want to use that for binary parsing), and eventually found C# scripting engines. The strong typing, coupled with BinaryReader made C# a perfect choice.
Those that know me well will be shocked to pieces at the thought of Ehtyar using .NET....never fear friends, the script interpreters run on Mono ;)

Ehtyar.

Navigation

[0] Message Index

[#] Next page

Go to full version