• 3 Posts
  • 353 Comments
Joined 2 years ago
cake
Cake day: July 24th, 2023

help-circle
  • Memory-safe since decades.

    It’s just reference counting with some common sense optimisations. From the website I can’t quite make out wether they disallow cyclic data structures or just leek them, but I’m guessing it’s the latter.

    Also the only thing worse than one-indexed arrays (the default) is allowing user defined array start.

    I feel embarrased to admit that I had been totally unaware of Seed7 until mere two months ago.

    Don’t be, there are so many out there, no need to be embarrassed for not knowing a language that prides itself on lot having fortran style line length limit.
    After slogging through vhdl, I personally will not voluntarily use a language that forces me to write out stuff like

          end if;
        end for;
      end func;
    

    when three } would work just as well.
    Similar deal with

    const proc: main is func
      local
        # local variables go here 
      begin
        # finally, the actual code can begin
    

    where proc means func void so essentially const func void main is func begin. Just default to const, remove the redundant funcs and allow locals to go where they are used, not all up front, even when they are only used in one branch.



  • I came up with a kind of clever data type for storing short strings in a fixed size struct so they can be stored on the stack or inline without any allocations.

    C++ already does that for short strings while seamlessly switching to allocation for long strings.

    It’s always null-terminated so it can be passed directly as a C-style string, but it also stores the string length without using any additional data (Getting the length would normally have to iterate to find the end).

    Also the case in the standard library

    The trick is to store the number of unused bytes in the last character of the buffer. When the string is full, there are 0 unused bytes and the size byte overlaps the null terminator.

    Iirc, that trick was used in one implementation but discontinued because it was against the standard.

    (Only works for strings < 256 chars excluding null byte)

    If you need a niche for allocated string you can get to 254 but the typical choice seem to be around 16.


  • I don’t believe you could save the emissions from animal agriculture.

    The easiest is to stop converting more land to animals use.

    Most animal ag is on land that isn’t suitable for growing crops,

    But 6% of global emissions are from feeding crops to animals.

    if it was ended, the land would become useless

    Aside from reducing our emissions by 16%, meaning it would be about as useful as removing all emissions from the transport sector.

    and left to go wild where it would support just as many just as polluting animals,

    Laughable, but if if it where true it could easily be solved with reintroducing predators and rewilding the artificial grass lands.

    but with no possibility of treating the pollution problem as no one would be managing the wild animals

    What is more polluting? Animals shiting in the forrest every day at a different place or month worth of stored manure deposited on one field in a day, with barely any plant at the moment? Which of those will naturally break down and which will be washed into the ground water?

    Where are the huge amounts of biomass fermenting into methane? Some swamps and every farm.




  • I had the same question a few hours ago, but I found some science.
    Tldr: 30% of energy use is in diesel, and about half of that is for tilling fields.

    Rant:
    Note that this is energy use, so only CO2 emissions are counted, while methan is ignored. If we stopped farming animals, the effective emissions of the sector would be cut in half. Even if we are unwilling to change out diet, maybe we should look at reducing the amount of fertilizer instead.


  • anton@lemmy.blahaj.zonetoScience Memes@mander.xyzOn Ploughing
    link
    fedilink
    English
    arrow-up
    32
    arrow-down
    1
    ·
    28 days ago

    The main problem is that, not ploughing increases the need for pesticides, currently around 8% of energy used and reduces yield. While not ploughing increasing requiring 3x the pesticides might not be the case, a 20% reduction in yield seems plausible.

    The main energy consumption in farming is fertilizer at around 50%, but more importantly half the emissions are related to animal agriculture. Cutting back on that would actually make a difference.