The contract programming in D is pretty much syntactic sugar for placing asserts at different parts of your program.
Refinement types can be used as compile time checks for preconditions and postconditions, while this contract programming is inserting runtime checks.
Here's a good post on the type state pattern in Rust (we don't actually have refinement types in something like Rust but the type state pattern is somewhere closer to refinement types on this spectrum): https://cliffle.com/blog/rust-typestate/
Poor man's runtime "dynamic" version. AKA: A much worse version.
In advanced cases, you'd need dependent types, but the only place where that almost shows up is in the "amount <= balance" assertions. That's also silly because if you typed "amount" and "balance" correctly, then "balance -= amount" has to produce a runtime error because the resulting balance would be negative and not a valid value for the type. So, it's a very natural place anyway to force the programmer to properly handle errors anyways.
"Contracts" has been around a long time and has not caught on. That's usually a good sign that better approaches are prevailing.
In other words: refinement types are a better solution.
> Poor man's runtime "dynamic" version. AKA: A much worse version.
Contracts don't have to be evaluated dynamically, that's just one way they're implemented. See SPARK/Ada for an example of contracts being used to prove programs statically, not just test them dynamically.
contract is way wider than simple refinement types. Refinement types are just a very specific group of invariants.
Contracts are an attempt to include formal specification languages into the implementation languages. You can enforce valid and invalid state changes, enforce relationships across the program state, or even enforce some level of correctness in behaviour.
> around a long time and has not caught on. That's usually a good sign that better approaches are prevailing.
That is completely not true. Plenty of dumb things prevail for faar too long for no other reason than momentum. Plenty of great things remain academic forever. It took decades to get algebraic types or basic functional programming somewhat accepted.
Design by contract is in theory a good idea but suffers from being a pain to use effectively. (making actually useful invariants that help the program more than an assert already would have)
Adding them to languages not built around them also results in quite nasty boilerplate or runtime overhead which further discourage their usage.
The various contract proposals for Rust are used as input to both formal verification tools as well as input to the optimizer. A good example of one such tool that could utilize contracts is cargo-anneal (https://crates.io/crates/cargo-anneal)
> Is this the CIA that overthrew the democratically elected prime minister of Iran
Mosaddegh Was not democratically elected, he was appointed by the Shah after the recommendation by the Majlis which itself was largely appointed. Later Mosaddegh rigged a real election and tried to give himself emergency power to dictate law. The Shah and his generals with the help of the US and Britain removed Mosaddegh. Yes the British wanted to get involved because of oil nationalization but Mosaddegh was trying to become a dictator, and alienated a lot of the population.
Majlis means parliament, and with the monarch Shah in control, that makes it a constitutional monarchy. To place a putschist general on par with that is disingenuous; it is a democratic retreat.
To be fair Iran back then wasn't a system like the UK or Sweden where the king's power is limited to signing laws. It worked more like Gulf states today with a much more personal form of government, the Shah could freely appoint ministers and dissolve parliament when he wanted. And his secret police was trained by the CIA.
It wasn’t a constitutional monarchy at the time, there were reformers pushing in that direction but the constitution put very few limits on the Shah. The Majlis wasn’t popularly elected then either.
No country will ever vote for degrowth so it either has to be done secretively which will cause a populist backlash like in the UK or at gun point. Degrowthers are IMO all basically eco fascists.
The reality of the situation is if you don’t embrace degrowth principles, the planet will probably do it for you. Think mega-wildfores that cause so much devastation that hundreds of thousands of people die from air pollution, or collapse of entire crops and food supply chains due to drought, or mega-heatwaves that wipe out millions.
Degrowth is coming. And you don’t have a say in the matter.
Most of these large wildfires are started by people and a result of bad land management in the form of stopping small fires in fire adapted landscapes. Moreover meddling in insurance markets and NIMBYism causes people to build in burn zones.
There just aren’t mega heatwaves causing famines and there won’t be at 1.5c of warming either.
None of that changes that we now have substantially larger and less controllable fires than we used to. Are you really denying that extreme weather and droughts don’t play a part in dramatically increasing combustibility?
> There just aren’t mega heatwaves causing famines and there won’t be at 1.5c of warming either.
Clearly heat and droughts are an issue and contributing factor, but land use is easily controllable relative to atmospheric CO2.
> Oh we’re going way past 1.5C.
Are we? The IPCC projects that no change in public policy or tecchnological advancement globally has us on track fro 2.6C rise by 2100, but there's a straightforward path to 1.8C. Experts no longer think the old worst case scenarios are plausible. Yes, 2.6C is nothing to scoff at, but it's in the realm of adaptable.
Especially with Sanders who has sponsored or co-authored 2 laws[1][2] that have passed and were signed into law, and a few pieces of minor legislation renaming post offices.
[1] Veterans' Compensation Cost-of-Living Adjustment Act of 2013
Organic vegetables are still monocrops grown by large companies, which I don’t think is a bad thing. Large scale agriculture has made food plentiful and cheap, that’s a good thing. We’ve eliminated famines in every nation with a stable government and market access outside or war zones.
I think their use of that paper is a bit sloppy, but you're sort of doing a similar thing by making a strong rhetorical claim "This author does what other pro-industry mouthpieces do" while ignoring the point of the paragraph, "Richer countries have near-universal refuse collection and almost none of their waste winds up in the ocean", which is broadly true[1]. North America and Europe account for 5.1% or ocean plastic. India alone accounts for nearly 13%, and the Philippines nearly 37%.
Worth noting that according to the data in that article, India is below the world average on a per capita basis, roughly 0.7x the world average. The Philippines is 25x the world average per capita.
I almost think the per-capita lens is less useful here, because the issue isn't consumption/use per se but the state capacity to collect trash and dispose of it properly. I also suspect that within India the majority of people produce little to no plastic trash that enters the ocean.
Not only that, but I know from my parents generation that small hold farm work is brutal an naturally leads to certain dynamics that contemporary Americans would find quite objectionable. When a bad harvest could starve your family directions are never polite requests and norms are very strictly enforced.
I'd say it depends. Amager Bakke in Denmark is a combined heat and power plant that burns waste and emits 687 grams of CO2 per kWh vs natural gas at 290 to 930 grams per kwh and coal at 900 to 1,050 grams per kwh. This makes burning trash CO2 competitive with Natural Gas. Using it for district heating probably improves the picture here because resistive electrical heating on a standard grid emits more CO2 than natural gas heat or pumped district heating.
It plausible that in cold climates burning trash has significant advantages.
reply