Hacker News new | ask | show | jobs
by minetest2048 26 days ago
> remove bit twiddling — System programming languages like C, C++, Odin, and Zig need to manipulate bits, but a scientific DSL like Fortran does not need bit twiddling operators like &, |, ~, and so on. Bits are, after all, hardware-level concepts.

Yeah no, your language will be DOA if you don't have bit twiddling, because you can't write arbitrary binary file parser / writer without some sort of bit manipulation.

Even matlab have bit twiddling function

3 comments

Also bit twiddling is very useful in a scientific language when you want to "simulate" a lower level embedded processor, typically fixed or floating DSP or controls code. For example MATLAB/simulink are very commonly used as a high level language before porting the algorithm to a DSP, FPGA, or ASIC, and for this they support bit twiddling and integer/fixed point arithmetic.
Those who don't have bit twiddling instructions are doomed to rebuild them badly via heavier actions and compiler optimizations.
That brings up some weird memories.. I saw 2 different researchers do bit manipulation in Matlab by printing the binary data as hexadecimal string, doing string manipulation on it and convert it back to binary
This point was weird, since Fortran has never had bitwise operators, as such. (It has had bitwise intrinsic functions since the “mil-spec” extensions in the late 70’s.)