Mandelbrot

In Python

Godbolt does Python! (And lots of other languages…) import cmath # Set how far to zoom into the set, you can tweak this value scale = 25 # Calculate if each point in an x-y plane "escapes" the shape for y in range(-12, 12): for x in range(-55, 45): # Create a complex number based on current coordinates # Note the fudge factor of 2 because characters are taller than high c = complex(x / scale, y / scale * 2) # Initialise the calculation z = 0 # Check if calculation remains bounded (stays on the page) for _ in range(20): # THE IMPORTANT BIT! [Read More]

Debuggers

Call frames

  • Parameters passed to the function
  • Local variables of the function
  • A snapshot of registers to use and restore
  • A return address
  • A frame pointer (for debugging)

Qt

Versions

4

  • Not supported since 2015

5

  • 5.12.1 LTS
  • 5.15 LTS

6

  • Released 8 December 2020

Brighton restaurants 2021

Recently visited £ Goemon (ramen) ££ The Vital Ingredient (Carribean) – 24/09/21 Sushi Garden Aji Sushi – 27/09/21 £££ Halisco (Mexican) – 21/09/21 ££££ atTEN (small plates) – 22/09/21 £££££ Terre à Terre (long-running vegetarian restaurant) – 23/09/21 Burnt Orange (small plates) – 27/08/21 Coalshed (steaks) – 02/09/21 Would like to revisit Naninella (Neapolitan Pizzeria) Etch (fine dining by Masterchef winner) Bincho (Japanese Yakitori skewers) The Market Little Fish Market Saltroom Block The Ivy 64 Degrees (fine dining by acclaimed chef Michael Bremner) Murmur (seafront fine dining, 64 Degrees sister restaurant) Lucky Khao (Thai) Shelter Hall Kujira (Japanese) Haven’t been but would like to! [Read More]

std::format

Examples and observations

#include <numeric>
#include <vector>
#include <fmt/core.h>
#include <fmt/ranges.h>

void align() {

    struct S {
        uint8_t : 8;
        uint32_t x;
    } __attribute__((packed));

    fmt::print("alignof {} sizeof {}\n", alignof(S::x), sizeof(S::x));
    fmt::print("alignof {} sizeof {}\n", alignof(S), sizeof(S));
}

void print_container() {

    std::vector<uint32_t> v(10);
    std::iota(begin(v), end(v), 3);

    fmt::print("{}\n", v);
}

int main() {
    align();
    print_container();
}

Output:

alignof 1 sizeof 4
alignof 1 sizeof 5
[3, 4, 5, 6, 7, 8, 9, 10, 11, 12]

https://godbolt.org/z/7c8b68s3h

What I'd like to see on a job spec

Keywords Initially I scan for keywords that pique my interest: C++20 Linux ARM Networking git unit testing cloud Agile C++ history Using the latest tech obviously stands out. For C++ the big shake up was C++11 – so anything this modern is of interest – but really we need to be talking at least ‘17. However, very few companies seem to use ‘20 in production but a good example is Maven Securities. [Read More]

C++ memory alignment

#include <fmt/core.h>

int main() {

    struct S {
        uint8_t : 8;
        uint32_t x;
    } __attribute__((packed));

    fmt::print("alignof {} sizeof {}\n", alignof(S::x), sizeof(S::x));
    fmt::print("alignof {} sizeof {}\n", alignof(S), sizeof(S));
}

https://godbolt.org/z/oPK4s15xv

Returns:

alignof 1 sizeof 4
alignof 1 sizeof 5

Caches

Small amounts of unusually fast memory (Data D$, Instruction I$, Translation Lookaside Buffer TLB), cache misses, speculatively prefetch, does it fit in cache (small is fast), no time/space tradeoff at hardware level, locality counts (stay in the cache), predictability helps. A modern multi-core machine will have a multi-level cache hierarchy, where the faster and smaller caches belong to individual processors. When one processor modifies a value in its cache, other processors cannot use the old value any more. [Read More]

Complexity

Complicated versus complex

Complexity projects Game of Life Social distancing Crowd simulation Building evacuation SIR (epidemiology) A complex system has __A__daptation and learning __C__onnectedness __I__nterdependence __D__iversity Wolfram behaviours Stables Periodic Chaotic Complex (high info content) Misc Exploration versus exploitation Highest peak On a dancing landscape you can never stop exploring Black swan Emergence Complexity is an emergent property Stasis encourages exploration and vice versa Slime mold breaking symmetry Bottom-up and top-down emergence Power law distribution Long tail Weekly emerging, strongly emerging (never figure out) Preferential attachment model Agent-based models Fires in crowded buildings Epidemics Netlogo Good science and agent based models must simplify (abstract) Feedback and externality Feedback is affecting the same action. [Read More]