• 5 Posts
  • 799 Comments
Joined 1 year ago
cake
Cake day: June 20th, 2023

help-circle

  • I’ll look at the wiki article again but I can pretty much promise that Ada doesn’t have dependent types. They are very much a bleeding edge language feature (Haskell will get them soon, so I will try using them then) and Ada is quite an old fashioned language, derived from Pascal. SPARK is basically an extra-safe subset of Ada with various features disabled, that is also designed to work with some verification tools to prove properties of programs. My understanding is that the proof methods don’t involve dependent types, but maybe in some sense they do.

    Dependent types require the type system to literally be Turing-complete, so you can have a type like “prime number” and prove number-theoretic properties of functions that operate on them. Apparently that is unintentionally possible to do with C++ template metaprogramming, so C++ is listed in the article, but actually trying to use C++ that way is totally insane and impractical.

    I remember looking at the wiki article on dependent types a few years ago and finding it pretty bad. I’ve been wanting to read “The Little Typer” (thelittletyper.com) which is supposed to be a good intro. I’ve also played with Agda a little bit, but not used it for real.



  • solrize@lemmy.worldtoProgramming@programming.devSafe C++
    link
    fedilink
    arrow-up
    1
    ·
    edit-2
    3 days ago

    Dependent types only make sense in the context of static typing, i.e. compile time. In a dependently typed language, if you have a term with type {1,2,3,4,5,6,7} and the program typechecks at compile time, you are guaranteed that there is no execution path through which that term takes on a value outside that set. You may need to supply a complicated proof to help the compiler.

    In Ada you can define an integer type of range 1…7 and it is no big deal. There is no static guarantee like dependent types would give you. Instead, the runtime throws an exception if an out-of-range number gets sent there. It’s simply a matter of the compiler generating extra code to do these checks.

    There is a separate Ada-related tool called SPARK that can let you statically guarantee that the value stays in range. The verification method doesn’t involve dependent types and you’d use the tool somewhat differently, but the end result is similar.


  • I’ve never owned a home but what people have told me is that you will spend 13 or 14 monthly payments per year, 12 of them on the loan, and the other 1 or 2 on the related expenses. Insurance has gone up a lot around here since then though.

    I know you can rent a tiny home plot with water and sewer in the (expensive) SF Bay Area for $800/month including some amenities (deltabay.org) so that is sort of an upper bound. This includes an electric hookup but you have to pay by the KWH for power. You can order a 400 sq foot tiny house (container home) on Amazon for about $20K (https://www.amazon.com/dp/B0D9Q3391S) though that’s just for illustration purposes. I don’t know enough about them to actually recommend that approach, plus I hate Amazon. So I would try to buy direct if I pursued that.

    Mobile internet coverage is pretty good now, unless you’re waaay out in the boonies to the point where you have to ask whether there are even roads to get there with. So if you don’t use a lot of data, that gets you online fairly inexpensively. The next thing after that is Starlink, which is way less expensive than I thought, $300 for the dish tranceiver plus around $150/month for “unlimited” service.

    The deal with well water depends a lot on the location. In the western states there are often legal restrictions. In drier places you have to drill very deep, which is expensive. If there is surface water, it’s less bad. In the desert (Joshua tree), a 1000 gallon truck delivery is around $100 (10 cents a gallon) iirc. I looked into this because a friend was interested in building a biodome there. So you are ok for careful usage but typical suburban use with frequent laundry and toilet flushing could get expensive. If you use a well, you might have to process the water to get rid of dissolved metals and solids, some of which can be toxic.

    Propane, again, some company delivers a 400 pound tank every few months, which means there has to be a road that can get it there, or you need some other way (ATV) to move it. I guess you can use smaller tanks if that’s easier. A friend of mine had this and I think they swapped the tanks around, as opposed to refilling stationary tanks from a truck, but I can ask her. It’s possible that I’m confused.

    Solar electricity and solar hot water are very doable now. You can buy a pretty good ready-made battery bank from Home Depot or similar, almost as cheaply as you can DIY without serious scrounging. Again I know a guy with around 10KW of solar panels and 10KWH of batteries iirc. He may have spent around $15K on this though he DIY’d. There is a substantial tax credit against solar expenditures here in CA, plus he gets paid when he feeds surplus power back to the utility (net metering), so he is doing pretty well with it. I think that setup is enough to run all normal household stuff most of the time. Maybe you want a backup generator around.

    There is a really good old reddit post about solar hot water. I think it is here: https://old.reddit.com/r/diySolar/comments/b5leqm . The person made a huge coil of black PVC tubing exposed to the sun, with the water circulating through a big tank, and this was enough to give him plenty of hot water year-around with a few K$ worth of stuff, plus electricity to run the pumps.

    Lately there are developments in ways to extract water directly from atmospheric humidity, even in the desert. I like to say that this is just like the moisture farming I used to do back on Tattooine ;). Web search: “atmospheric water harvesting”. Maybe this will become practical soon.

    There are a lot of homesteading forums that might be better places to discuss this stuff.

    Is there a location you are thinking about? For now, my own interest is sort of academic, but I have been following stuff a little bit.

    All told though, I always hear that city and suburban nerds like me often think this lifestyle sounds great, but they get sick of it quickly when they actually attempt it.


  • In Ada? No dependent types, you just declare how to handle overflow, like declaring int16 vs int32 or similar. Dependent types means something entirely different and they are checked at compile time. SPARK uses something more like Hoare logic. Regular Ada uses runtime checks.


  • Nobody intentionally creates vulnerabilities, but more complicated software is more error prone and therefore more likely to be vulnerable. Fast release cycles also get in the way of good testing. The most complicated piece of software on most phones is the web browser, and its complexity is imposed by the web and its advertisements, rather than by what the user wants or needs.

    IOS and Android face pretty much the same issues on the OS developer and phone manufacturer sides. Therefore, the IOS and Android worlds could both clean up their acts in about the same way if the incentives were right. That they don’t do so might be a bad situation that we have to cope with, but we shouldn’t pretend that it is a good situation.

    I wonder what apps require IOS 16 in some meaningful way. I know there is a situation with Android apps requiring OS upgrades unnecessarily.

    Why do companies like McDonalds want you to run an app anyway, instead of e.g. using a web page? There are a few sites or products where I currently give up the equivalent of a french-fry discount rather than run their stupid app. It’s just a minor annoyance so far, but it doesn’t make sense to me. Do those apps usuallly keep running the background so they can track you, or what?


  • Those security vulnerabililties are because of buggy old software, and updating the software in the old devices does as good a job of fixing the vulnerabilities as selling you a new device does. A significant e-waste tax on every new device, accompanied by credits for keeping old devices working, might help with that. Anyway, if it’s an app (rather than OS) vulnerability and you can’t fix it with an update because the new version of the app requires a new OS, that’s mostly likely an app that you don’t need to use. I’m getting by ok with F-droid apps instead of Play Store apps, for example.

    Best still would be to debug the software before shipping it, so it wouldn’t have those vulnerabilities in the first place. There are various forces that get in the way of that, but a significant one is that web development is now driven by delivering more advertising rather than useful information to the user.





  • In Ada, the overflow behaviour is determined by the type signature. You can also sometimes use SPARK to statically guarantee the absence of overflow in a program. In Rust, as I understand it, you can control the overflow behaviour of a particular arithmetic operation by wrapping a function or macro call around it, but that is ugly and too easy to omit.

    For ordinary integers, an arithmetic overflow is similar to an OOB array reference and should be trapped, though you might sometimes choose to disable the trap for better performance, similar to how you might disable an array subscript OOB check. Wraparound for ordinary integers is simply incorrect. You might want it for modular arithmetic and that is fine, but in Ada you get that by specifying it in the type declaration. Also in Ada, you can specify the min and max bounds, or the modulus in the case of modular arithmetic. For example, you could have a “day of week as integer” ranging from 1 to 7, that traps on overflow.

    GNAT imho made an error of judgment by disabling the overflow check by default, but at least you can turn it back on.

    The RISC-V architecture designers made a harder to fix error by making everything wraparound, with no flags or traps to catch unintentional overflow, so you have to generate extra code for every arithmetic op.







  • I was young then too, but it seemed to me that while Reagan was popular among Republicans during his Presidency, he didn’t get an actual personality cult til after he left office. His popularity came from evoking nostalgia, so afterwards, he himself became an object of nostalgia. He died in 2004 and his funeral was turned into a tremendous media event glorifying him. It was sometimes called the “Reagasm”.

    It seemed to me that Barack Obama had a personality cult of his own, at least during his campaign and early time in office. I think that his followers got disillusioned after that, but he retained some popularity and got re-elected despite intense opposition from the other side.