Category: Notes

Notes are mini-posts

Interesting notes on C

Interesting notes on C

Notes
Image by David Schwarzenberg from Pixabay

If you are learning C there are a number of points that may not be mentioned and possibly aren’t obvious. For instance with multidimension arrays. “The array size can be derived from its initialization but that’s applicable for first dimension only. For example, ‘int arr[][2] = {1,2,3,4}’ is valid but ‘int arr[2][] = {1,2,3,4}’ is not valid.” and “Unlike ‘long long int’, there’s nothing like ‘long long double’ in C. Besides, real data types (i.e. floatdoublelong double) can’t be unsigned.”

These and a whole lot more notes can be found here. It’s definitely worth a read. The only thought I had that was worthwhile is to do with the order of execution in a for statement.

The definition is in this order: for (initialisation, end test, alter loop variable ) statement;  but the actual order of execution is initialisation; statement; alter loop variable; end test.

A blog post worth reading

A blog post worth reading

Letter C
Image by Clker-Free-Vector-Images from Pixabay

A developer called Jakub “Jorengarenar” Łukasiewicz has posted a blog entry Best aspects of C language and I’m more than happy to link to it. It says much of what I think about C but expressed very nicely and its well worth the read.

In his post he refers to a document Rationale for International Standard Programming Languages C (PDF).  This is a 2003 document (C doesn’t change very often)  and not exactly a light read at a trifle over 200 pages long. It’s an insight and commentary into what C99 is about and also lists these five principles:

  • Trust the programmer.
  • Don’t prevent the programmer from doing what needs to be done.
  • Keep the language small and simple.
  • Provide only one way to do an operation.
  • Make it fast, even if it is not guaranteed to be portable.

If you are learning C this will provide you with explanations of why some things in C99 are what thy are. Like myself you will discover things that you didn’t know. For instance I didn’t know about long double. Or that in K & R C(Kernighan and Ritchie) that all floating point arithmetic was done at double precision but that was relaxed in C89.

 

Benchmarking my Raspberry Pi

Benchmarking my Raspberry Pi

hardinfo running on Raspberry PiI played with a couple of free packages today. I can recommend hardinfo. (sudo apt install hardinfo to install then hardinfo to run ) though less about the benchmarks than the information it gives on your system.

I’ve got both 32-bit Raspbian and 64-bit Raspberry Pi OS on two sd cards and intend to run both and compare benchmarks just to see the difference.

Another benchmark utility that looks interesting is sysbench (sudo apt install sysbench to install). It runs from the terminal and lets you run benchmarks against file io, cpu, memory threads, mutex and oltp.  Just type sysbench and you’ll get a list of commands.