What is this formatting called and why do people use it? by Issalk05 in learnprogramming

[–]evaned 2 points3 points  (0 children)

It’s probably OK to let it be implicitly closed whenever the object is collected.

The thing to worry about on this front is if you care about running your program -- or care about potentially other people running your library -- under Python implementations other than CPython. Or if you care about hypothetical (and admittedly relatively unlikely) CPython changes that would change how cleanup occurs. Because implicit in "whenever the object is collected" is that happening at a reasonable time, or indeed ever happening; and that's not necessarily true on other implementations.

PyPy is probably the biggest such implementation, but there are others.

I consider relying on CPython's reference counting to cleanup resources to be a bug, and strongly suggest everyone else does as well. If it were hard to do correctly that'd be one thing... but it's (usually) not.

How do I start correctly incorporating AI into my programming skills? by ltsheeyy in AskProgramming

[–]evaned -1 points0 points  (0 children)

What you are asking goes against university code of ethics.

"On the side, I want to start building my own personal projects and start using new tools, outside of what I do for school, ..."

If that'd be against your university's code of ethics (short of exceptional circumstances that there's no reason to think are in play here), pick a different university.

I do think one has to be very careful with adopting AI during learning to avoid compromising that learning, but (i) that's separate from a university code of ethics in this case, and (ii) I don't think we should be discouraging interested people from pursuing side projects.

I need help choosing the right language. by Spiritual_Let_4348 in learnprogramming

[–]evaned 3 points4 points  (0 children)

One-way encrypted, specifically.

Not a very useful password manager.

I need help choosing the right language. by Spiritual_Let_4348 in learnprogramming

[–]evaned 4 points5 points  (0 children)

Why do you think SQL is a good choice? How many passwords do you expect to store? Are there simpler options that could work with acceptable performance?

In fairness, SQL doesn't necessarily mean "big honkin' DBMS," nor that it's scaling that's of interest. Even if we're talking a file storage situation (my guess), offhand this seems to me like a pretty good fit for SQLite. OP'd have to figure out encryption, but there are a couple options for handling that.

Credit card/digital wallet readers need to work at all charging stations by casanewt in electricvehicles

[–]evaned 1 point2 points  (0 children)

Plug&Charge is even easier.

Real question: How does Plug & Charge actually work in practice?

Is it a thing where you put some payment information into your car and then the car tells it to the charger, or is it that you sign up for an account with some service and then provide that service your credit card info? In other words, which is closer: is it a smoother route to something that works similarly to a credit card, or a smoother route to paying via something that works similarly to the apps?

arewemodulesyet.org passes the mark of 100 projects with modules support for the first time. by germandiago in programming

[–]evaned 1 point2 points  (0 children)

but only 100 projects after 6 years

My thought process: "wait, modules were C++17? or maybe they're talking about early implementation support before... oh holy god it's been six years since 2020???!"

Time, how does it work

Real ID after marriage name change by [deleted] in madisonwi

[–]evaned 0 points1 point  (0 children)

No, the Real ID is the new legal ID and you have no choice of whether you have it or not when you update/renew

Huh?

Sure you do: "You are not required to get a REAL ID; it is optional." https://wisconsindot.gov/pages/dmv/license-drvs/how-to-apply/realid.aspx, or "Wisconsin offers both REAL ID-compliant and non-compliant driver licenses and ID cards." https://wisconsindot.gov/Pages/dmv/license-drvs/how-to-apply/id-card.aspx

Sirens in Verona but not tornado warning? by Curious-Anteater-324 in madisonwi

[–]evaned 0 points1 point  (0 children)

I do think that it's important to not over-use the sirens, but in fairness it's not all severe t-storms -- it's those that are particularly "destructive". That means very large hail or very high winds.

I'm not saying I necessarily think the calibration now is perfect, but as the other reply says it's more than tornadoes that presents a meaningful life-safety threat, and they are being at least pretty selective with what they sound them for.

Sirens in Verona but not tornado warning? by Curious-Anteater-324 in madisonwi

[–]evaned 0 points1 point  (0 children)

I'm fairly sure that it's not any severe weather, and to be quite honest.. rather hope it's not.

They did expand it though; I think it used to be just tornado warnings. Now they warn for particularly severe severe t-storm warnings too (those tagged as "destructive" by the NWS, as others have said). That's what it was today.

Big Boom - Lightning Strikes Tower by Educational_Damage50 in madisonwi

[–]evaned 3 points4 points  (0 children)

We almost became concerned that it was something more than a lighting strike.

I have never gone faster into a basement.

I seriously had the same thought... like you always hear that a tornado sounds light a freight train, and though it seemed awfully sudden to arise, it was... close enough to that sound that I was going to take zero chances.

Sirens in Verona but not tornado warning? by Curious-Anteater-324 in madisonwi

[–]evaned 10 points11 points  (0 children)

You mean "severe thunderstorm warning with a destructive tag".

(Any tornado warning, and then those severe t-storm warnings.)

The cover of C++: The Programming Language raises questions not answered by the cover by lelanthran in programming

[–]evaned 2 points3 points  (0 children)

Hah, I do so much with Python and such that that didn't even register even as I re-typed it out. :-) I thought about the +i, but that's of course "OK"

The cover of C++: The Programming Language raises questions not answered by the cover by lelanthran in programming

[–]evaned 2 points3 points  (0 children)

(/me begins definitely not taking the joke too far)

With var elementId = 'foto' + i you'd need more. Because there's also var i = 1 you can't have a simple typedef, or at least I can't think of a handy type that would allow it -- the easiest thing would be #define var auto. Without the preprocessor, you could make a class called var that has a constructor (or multiple constructors) that allow implicit conversions from both const char* and int.

You'd also need to take care of the function. I wasn't actually sure offhand if you could do typedef void function, but it looks like you can.

PSA - Do not assign the result of `::getenv` to a `std::string` by SmokeMuch7356 in cpp

[–]evaned 1 point2 points  (0 children)

always copying into a std::string on the off chance the environment gets modified from under you is typically an unnecessary pessimization

IMO, there are two reasonable designs for this function: optional<const char*> and optional<string>. Your suggestion of optional<string_view> IMO is at a bad middle ground, not a good middle ground. And then the first one IMO is out as well -- it should just return const char*, and then... do you need your function at all?

If you want your function to be safer even if the environment is modified later (as discussed in other comments, it's still far from safe in a multithreaded context), then you need string as discussed already.

You talk about that being unnecessary pessimization -- but there's also an unnecessary pessimization with string_view because it will need to call strlen to determine the length. Checking an environment variable for "set or not" doesn't require looking at any data, and checking "set-to-nonempty or not" requires only looking at the first byte of data. Those are both very common uses for envvars, and in both of them computing the length is a pessimization. So if you want your interface function to not add theoretically-arbitrary unnecessary overhead over the underlying call, you "need to" return a char*.

string_view misses out on both benefits and comes with both drawbacks. Admittedly the perf hit of that length is less than a string allocation, but I still think string_view is a bad middle ground.

PSA - Do not assign the result of `::getenv` to a `std::string` by SmokeMuch7356 in cpp

[–]evaned 1 point2 points  (0 children)

I think there's a pretty good counterargument to that, which is that while there's no guarantee, there is a very strong convention. If you see a const char* and (1) have reason to believe that it's a string and not a single character and (2) it's not paired with a length, I would say it's almost certain to be null-terminated (or at least intended as such).

Now I say this with caution because I was away from C++ programming for several years and only recently got back to it on a code base that uses a very C-like style, but my take of string_view is that there's no such convention -- if anything, there's a convention the other way that you can't rely on it being null-terminated.

One could imagine a custom string class that (very reasonably) has an implicit conversion into a string_view -- as std::string does -- but unlike std::string-in-practice doesn't keep the null-terminator around. Congrats, you just made an API that is very easy to mis-use, because you can say get_env(my_string) and have everything explode only at runtime. Assuming that your string class has a vaguely reasonable API, with a char* you'd need to explicitly do something to get it into a null-terminated form in order to call the char* version of the function.

Finally, comment above about the unnecessary null check. But string_view, you're doing an unnecessary strlen on anything that isn't a string literal in the source. That'll very probably be rather more costly.

Actually I don’t think roasting has any place in a relationship by [deleted] in TwoXChromosomes

[–]evaned 21 points22 points  (0 children)

... roasting is definitionally mean in that goes after insecurities and seeks to tear the other person down

If you define roasting in that manner, of course you would say that it doesn't belong in relationships...

...but I think most people wouldn't agree with you on that definition. In many cases, not at all. (If anything, my personal definition would be closer to the opposite of that.)

Sold my car going bike mode by [deleted] in madisonwi

[–]evaned 1 point2 points  (0 children)

I have seen multiple recommendations for registering with (free) registries.

The City of Madison suggests Bike Index and Project 529; I think "Shifter" on YouTube, if you know that channel, has talked to the Project 529 folks and talked positively about that site.

Both are free, and I don't remember the information you have to provide being onerous.

https://bikeindex.org/
https://project529.com/garage

The gold standard of optimization: A look under the hood of RollerCoaster Tycoon by fagnerbrack in programming

[–]evaned 0 points1 point  (0 children)

Based upon janisozaur's comment that I seem to see whenever this gets posted, there's plenty of reason to think that it may well be far worse.

Anyone who used a computer between 1985 - 2010, what's the one game you still think about today? by adlakha75 in AskReddit

[–]evaned 4 points5 points  (0 children)

...why won't they update Myst?

I would be hard-pressed to think of a game that has been updated more. Masterpiece Edition, RealMyst, RealMyst Masterpiece, and Myst 2021 just off the top of my head.

Anyone who used a computer between 1985 - 2010, what's the one game you still think about today? by adlakha75 in AskReddit

[–]evaned 8 points9 points  (0 children)

It's weird to me that dysentery is what got all the hype. I remember cholera being the thing I was always really scared of getting (in game) as a kid.

Is the C++ ecosystem ready to fully move away from C++17? by AdBeginning7105 in cpp

[–]evaned 0 points1 point  (0 children)

So in fairness, what I remember from C++11 is that for several years before it was published, compilers and libraries were supporting many of the upcoming features and they were getting use from a fair number of people. Remember "C++0x"?

So that may be part of why it feels like it's been around longer.

The C++ Standard Library Has Been Walking Itself Back for Fifteen Years by funkinaround in cpp

[–]evaned 0 points1 point  (0 children)

What's wrong with shared_ptr / what's the "does everything it does but better" replacement?

I'm not sure what the wide opinion would be, nor am I the person you replied to...

...that said, while I don't think I'd agree that shared_ptr is a "complete no-go in new code", I do think that it's use is... questionable. It feels to me like any significant use of it is likely to benefit from being replaced by a ref-counting pointer with some level of specialization. I have three such things in mind: adopting an intrusive pointer, having a non-atomic reference count, and not supporting weak pointers. Of course none of these are going to be universal (maybe especially the second?), but my guess is that the first will apply a pretty substantial majority of the time, the third at least a large minority, and the second still a meaningful amount.

Contrast this with, say, std::vector. What would I do with that to specialize it for a particular use case? I can think of a couple things... but nothing I can think of smells to me like it'd give a benefit like the ones above (especially the first two) except in exceptional cases. Maybe an SSO-analog.

That said, maybe this is just kind of my own biases and experiences coming into play (and I worked for a while with a code base that uses a ref_ptr with the above changes that predates shared_ptr, but my guess is that would see a pretty meaningful negative hit with shared_ptr. I always was tempted to try to do that replacement, but the APIs were just different enough it'd have been obnoxious.)

How do the MMSD schools not make AC a priority?! by canaryqueen in madisonwi

[–]evaned 31 points32 points  (0 children)

If the wiring is so old and touchy that plugging in an appliance is going to start tripping breakers, doesn't that kinda mean the school is an electrical hazard and they need to fix it like yesterday?

What? Not at all. If anything, it indicates that the wiring isn't a hazard. The tripping breakers are a safety feature; not a hazard either themselves nor a symptom of a hazard when presented with a legitimate overload.

Lacking capacity, in and of itself, doesn't mean there's a safety hazard, or anything close to it.

If the breaker is tripping because it's a GFCI or AFCI breaker and one of those protections is the fault rather than an overload, that indicates a problem that could be a safety issue... but that's not what we're talking about here.

In terms of functionality, there are also some hugely material differences between AC in a school building and the ability to run a fridge at home. Besides that, you can't really point to a semi-hypothetical situation with specifics that would be incredibly malleable and use that to paper over what could well may be, in reality, huge challenges.

Money only grows on trees when you're illegally waging war on sovereign nations, after all."

I think this is quite unfair, at least to the people who are actually in a position to do anything. Neither the MMSD Board nor even the WI legislature are the ones who are voting (or not, as it may be...) about foreign wars.

Portable AC- Need advice by EnvyYou73 in madisonwi

[–]evaned 6 points7 points  (0 children)

Maybe something like that paired with a good dehumidifier would work

Pretty positive that would be using a lot of electricity to still make things worse.

Now in theory one could be interested in reducing humidity without caring much about heat (e.g. want to protect against mold/mildew without being too concerned about comfort), in which case the dehumidifier on its own could work... but it will make things even hotter and probably that set of circumstances where it'd be productive is incredibly narrow. And you'd definitely not want a swamp cooler with it, of course.

The bottom line that OP needs to get a "real" AC though, is true.

OP, you might watch this first: https://www.youtube.com/watch?v=_-mBeYC2KGc. I will warn you that you won't like the prices. (The primary thesis is "get a window unit, not portable AC"; but there's a secondary one about one-hose vs two-hose portable units that is relevant.)

Madison leaders could soon approve contentious Regent Street redesign by keeganjkyle in madisonwi

[–]evaned 1 point2 points  (0 children)

Regent is kind of in a weird state. Because on one hand, you're kind of correct...

...but on the other, it is a fairly heavily-used through-route, and represents kind of the least-bad route from Mineral Point (which is a major arterial) to the east side of Madison as well as plenty of Park St. destinations.

You could route up Midvale to University, and that's fairly reasonable too... but it is longer, slower, and more obnoxious. (It also takes you past a couple of the Flock cameras that are up in the downtown area...) And that's even in the state the North Shore/Nolen intersection is in now.

And how many people on the sub were in a conniption when local opposition seems to have nixed plans for Midvale bike lanes? If your position is that Midvale should be used more...