4 ms·
>The big question, which I ask whenever someone harps on about portability, is does it even make sense? For entire apps it doesn't always make sense but being
by simias 8y ago
>The big question, which I ask whenever someone harps on about portability, is does it even make sense?
For entire apps it doesn't always make sense but being able to port code fragments and small libraries is definitely nice. You can write a (non-optimized) portable memset or memcpy very easily (although one should be careful with how they're used if the arch has "weird" CHAR_BIT). Ditto for printf, a simple compression library, a function to strip whitespace and non printable characters from a string, code to handle the FAT filesystem etc... That's stuff that's useful potentially everywhere, from a 32core Xeon to an 8bit controller.
Look at kernels like Linux that are ported to a wide range of devices, there's still a significant amount of shared code.
These days it's also fairly common to have code that runs on both on amd64 on the desktop and ARM32/AARCH64 on smartphones and tablets. It's not as large a gap as going from some DSPs to general purpose CPUs but there are still enough pitfalls that being able to write portable C without too much difficulty is a good thing.
- deleted 8y ago[deleted]
- cozzyd 8y agoNot just tablets but many SBC's (RPi, BBB) are also ARM.
- fastaguy88 8y agoFor scientific software, the answer is clearly YES. I wrote a popular bioinformatics package -- FASTA -- originally on a VAX running Unix (in 1983) and a 8086/CPM system, next on an Intel 2086 and Mac/68000 later PPC, moving it on to Sun/Sparc, MIPS, HP (whatever it was), and DEC/Alpha. The original version was not threaded, so porting from one environment to the next was mostly about declaring character types. The threaded version was a bit harder, but pthreads has served me well for more than 20 years. The programs also run fine on a Raspberry Pi. And there are Fortran based scientific packages that are much older.