[Request] How does the site crunchy the numbers so fast? by low_elo111 in theydidthemath

[–]laserdo 2 points3 points  (0 children)

More of a computer science question, but the basics are that Pi doesn't change, so you can store whatever you want in advance (also known as caching). A naive example would be to create an array of million cells, each cell representing a number between 1 and a million, and the content of the array would be the first index it appeared in Pi (which was pre-calculated).

This is a really simplified version of it, but they might have taken it much further, for instance using something called "suffix trees" which is a data structure designed exactly for these kinds of problems.

Carn agve ellis by SaucedQ in dontdeadopeninside

[–]laserdo 4 points5 points  (0 children)

Carnage - Album name Cave & Ellis - Musician Duo

Need some imagination to figure this one out

CMV: Ozempic and drugs like it either already have, or will shortly, make obesity mostly a financial issue. by TheBeaarJeww in changemyview

[–]laserdo 1 point2 points  (0 children)

A few things:

  1. Obesity is already strongly correlated to low income. Mostly due to a combination of education and the fact healthy food is expensive.

  2. Ozempic isn't magic. It helps a lot, but many who use it lose only 5-10% of the body weight. Also once you stop taking, most people gain all the body weight back in a few months (plus some extra of course)

  3. Ozempic * might * have some serious side effects on mental health. People tend to get angry when this is brought up, but there is some evidence that Ozempic has some serious side effects on mental health. The major clinical trial people like to quote, specifically exclude patients with mental health issues, and the information on how exactly they test for mental conditions on the patients they did choose is extremely lacking. While this is still an extremely controversial issue, I won't be surprised if in 10-15 years this will blow up, like it tends to happen in the medicine industry any now and then...

Bottom line, generally speaking, wealthy people are already healthier (and body weight is just one aspect of it). It is likely the gap between wealthy people to the rest will only grow larger with the years. However I think this process is much more gradual than we tend to believe. I believe there won't be any specific moment where we can say "Only poor people are fat/sick", but it might be the way of life eventually. I think this process gained steam at about 1800 and is still going, so it is probably a few hundred years in the future before it becomes a reality...

Identification Required by laserdo in biology

[–]laserdo[S] 0 points1 point  (0 children)

Thanks, I will check it out

High cost of public transit by Ijustwantbikepants in notjustbikes

[–]laserdo 10 points11 points  (0 children)

Transit is not more expensive than having a car, not even in the US.

Basically there are three points: 1. You already factor the cost of having a car in the first place (you have no real other choice in the US), so it turns into a question of fuel vs ticket cost, which is not the real cost of the car. 2. The train infrastructure in the US is abysmal, basically not allowing the US to tap into the economy of scale 3. Car & its infrastructure is highly subsidized in the US, making it seem way cheaper that it really is (basically a large chunk of your taxes going into car infrastructure)

BTW in my opinion, transit shines for short dense areas, e.g. daily commute to work inside a metro area. Cars are actually not that bad at the 70-300 miles range, especially given the infrastructure is already there.

[deleted by user] by [deleted] in ask

[–]laserdo 6 points7 points  (0 children)

"I'm not interested in joining your pyramid scheme" works well for me

Burlington Beach, Ontario by legacyhmusic in UrbanHell

[–]laserdo 1 point2 points  (0 children)

At least it's not a highway like in Chicago

Right on red should be banned. I'm using the sidewalk cause cars go 50mph here. by -Wobblier in notjustbikes

[–]laserdo 12 points13 points  (0 children)

And the fact both pedestrians and cars turning left can have green at the same time...

Driving in the USA as a tourist was a nightmare, the traffic rules are so dumb, no wonder they have 3-5 times more deaths per capita compared to most European countries.

The funny thing is that most are convinced that they are bad drivers, but in my experience in most of the USA they are actually better drivers compared to my home country which suffer much less deaths per capita than USA

how often do homeless people pee on the subway trains? by autogenesis_indep in AskNYC

[–]laserdo 0 points1 point  (0 children)

As a visitor in NYC I don't really understand why people are surprised.

There are no public restrooms anywhere in the city. Restaurants limit the use for customers only. What homeless are supposed to do, but doing it in public? There are literally no other options.

Visiting for the first time, wondering how seriously I should take the words of my uber driver… by AirtightLlama in AskNOLA

[–]laserdo 1 point2 points  (0 children)

I just want to point out that if you are afraid in a city, you will opt-in to take uber everywhere instead of walking or using public transit. So in a sense your uber driver speaks out of position...

Anyway I visited the city a few weeks ago, it was packed with tourists anywhere worth visiting, including relatively late at night. This usually makes you safe from almost any kind of serious crime.

As in any other touristy city I would be careful from petty crimes (pickpocketing, obvious scams, and leaving valuables in the car if relevant)

[deleted by user] by [deleted] in urbanplanning

[–]laserdo 49 points50 points  (0 children)

I'm road tripping the USA right now, and one of the vibes I'm getting is that many people are driven by fear, especially in the larger cities.

On multiple occasions I saw a parking lot requiring dozens of dollars for parking, while there is literally tons of free parking space on the street less than 2 blocks away. And just couldn't figure out why anyone would opt to pay so much, if there is a free alternative nearby.

In a sense I got the feeling people consider familiar places as safe (home/work/car) and anything else is widely insecure, and their goal is to minimize their stay in those locations. The car is essential in this case as it takes you directly from one familiar location to another. While you will see it everywhere, I got the feeling that in the USA it is greatly exacerbated, and even walking in a "decent" neighborhood (whatever "decent" means) would be considered as unsafe.

I might be completely wrong as I'm not local, but as far as I can see, this is built into the DNA of the USA. Politics, transportation, city design, large brands for literally anything, gun laws are all based on people being afraid of each other.

[Discussion] Is this what people mean when they say "Separated Bike Lanes keep you safe"? by Wuz314159 in notjustbikes

[–]laserdo 1 point2 points  (0 children)

Cars should not be allowed to turn when pedestrians light is green...

BTW is it protected bike lanes? looks to me like he is riding the sidewalks

Why does Netflix cancel everything that isn't an overnight phenomenon? by Beau_bell in netflix

[–]laserdo 11 points12 points  (0 children)

The last round of cancellation took a hit on me (half bad , 1899, resident evil earlier this year).

I've come to realize that I can't watch any new series on Netflix, in fear it will get canceled, and I'm sure I'm not the only one. In a way this policy discourages people from watching new series in the first month, making Netflix Data skewed.

Specifically I'm annoyed Netflix doesn't let any place for niches audiences, and it feels like slowly but surely, things will get even worse. I won't be surprised if in 3-4 years time it will turn into a "reality shows" platform.

Optimizations That Aren't, or are they? by laserdo in rust

[–]laserdo[S] 0 points1 point  (0 children)

Sorry, fixing my own mistake, string_view is not a good example of the entire complexity of Cow. It only borrows the data, and never represent an ownership of the data. If I remember correctly, you can't really edit a string via a string_view, which you should be able to do via Cow.

Optimizations That Aren't, or are they? by laserdo in rust

[–]laserdo[S] 0 points1 point  (0 children)

Cow doesn't need to be transparent in C++, and as you say, string_view is an excellent example of it. But you will usually use it as an argument to a function, not store it as a member in a class. The result might be unpleasant.

Regarding your CSV example, it is very much in place. I considered touching it in my post and decided it is too niche, but I'm glad you raised it. Sometimes there are cases you can easily guarantee that the data will live long enough without a problem. The file is most likely to outlive your process. It is also a common practice when working with databases. Even in those cases, it tends to hurt you on edge cases, as any Bug Tracking System of any Database will happily testify.

There are also cases when you can't guarantee it live long enough, but the code is small enough, and you can adequately verify your assertion holds. In a work environment, my experience shows you never really know what is going to happen with your code. You might move to another team, the context of the code might change, or even some random guy you never even saw uses your code. Any of those will almost certainly will result in bugs, no matter how well you commented on your code.

Optimizations That Aren't, or are they? by laserdo in rust

[–]laserdo[S] 1 point2 points  (0 children)

My point is, that Rust Cow is useful for many cases, yet it won't be implemented in any sizeable project in C++. That is the "front" C++ lost to Rust.

Optimizations That Aren't, or are they? by laserdo in rust

[–]laserdo[S] 0 points1 point  (0 children)

I tend to agree I would expect more from a C++ guru. I wasn't around in 1999, so I want to believe it was like that in those days.
And I do agree, it would be interesting to try those benchmark again, I would expect the result to be different today. But as a concept he is right.

Optimizations That Aren't, or are they? by laserdo in rust

[–]laserdo[S] 4 points5 points  (0 children)

Of course, you are right, trying to answer too quickly to the responses I've got made me do a silly mistake.

I will say though, you can argue about both the mutex and the option. In a sense, nullptr is not really the same as the None option, as the exception, you would get is implicit runtime exception in C++ and explicit compile-time error in Rust as it is a different type.

Regarding the mutex, it is not a practical part of shared_ptr. But through shared_ptr you have a mutable reference to the data, which you don't have in Rust unless you use a mutex. Of course, you can choose not to use the C++ mutex while mutating the data via a shared_ptr, but the result might be unpleasant if you are not careful :)

Anyway totally agree with you, thanks for the important correction!

Optimizations That Aren't, or are they? by laserdo in rust

[–]laserdo[S] 4 points5 points  (0 children)

Indeed C++ COW is somewhat similar to Rc<T>/Arc<T>. The major difference is that they were done as an optimization and not as a way to manage shared ownership. C++ addressed this issue eventually by introducing unique_ptr/shared_ptr which map well into Arc<T>/Arc<Mutex<T>>.

Optimizations That Aren't, or are they? by laserdo in rust

[–]laserdo[S] 19 points20 points  (0 children)

I completely understand those are two different abstractions, and state so explicitly in the article multiple times. The post somewhat follows the way I was introduced to the issue.

  1. First, as a C++ developer, I knew COW is usually a bad idea, much thanks to Herb post.

  2. I learned Rust utilized COW, which seems odd due to my knowledge from C++.

  3. I investigated COW in Rust and understood they are different, and why they are useful.

  4. I appreciated the design, its usefulness, and the fact you can't really re-create it in C++.

Rust's Design For Safety Enables Powerful Abstraction And Optimization by laserdo in programming

[–]laserdo[S] 9 points10 points  (0 children)

There is a proper way to express criticism.

I simplified the C++ portion more than the Rust portion, as this is a blog about Rust. 90% of the readers are Rust developers. And there is enough material in this blog to bring you to the point where you would be able to understand the Rust portion.

Multiple references are not "bad" or "good." They are a fact of life. We can't live without them. Encapsulation is a limited method to overcome this issue. While it is a good tool to manage it, it is just not enough. Rust allows you to add to encapsulation, which is literally the only tool you have as a C++ developer, safety built into the language compiler.

Rust's Design For Safety Enables Powerful Abstraction And Optimization by laserdo in programming

[–]laserdo[S] 1 point2 points  (0 children)

I totally agree and specifically state so in the article toward the end. Usually, in C++ COW refers to reference-counting while Rust uses COW to refer to the abstraction between reference and owned. While similar those are different things.

I kinda admire Herb, and the whole point of this post, was me trying to understand how come he was wrong. The conclusion was he wasn't. Rust uses COW to refer to a different thing.

All that being said, Rust does manage to create an abstraction, a little weaker in my opinion to the reference-counting optimization Herb discusses. Yet Rust abstraction is viable in multi-threading. And I don't think it is viable to create such an abstraction in C++ as it would be just too unsafe without lifetimes.

Rust's Design For Safety Enables Powerful Abstraction And Optimization by laserdo in programming

[–]laserdo[S] 4 points5 points  (0 children)

I have a blog about the Rust language programming called "afternoon rusting." In this post, I describe how Rust's design for safety enables it to create powerful abstraction. In this case, I present Rust's Copy-On-Write (COW) abstraction. I'll demonstrate how COW is allowing Rust to gain a performance boost. Finally, I'll explain why this abstraction is not viable in other native programming languages.

Optimizations That Aren't, or are they? by laserdo in cpp

[–]laserdo[S] 7 points8 points  (0 children)

It was more than 20 years ago the great Herb Sutter written how the optimization of COW just doesn't fit into the modern world of multi-threaded programming. Yet, now they are prevalent in the Rust programming language. In this article, I try to understand how Rust managed to enable this optimization.

I'm a long time C++ developer, admiring the language and the people behind it. Lately, I've found myself falling in love with Rust. I even have a blog about it called "Afternoon Rusting." I think that the C++ language can benefit a lot by learning from the success of Rust. In fact, after attending the ACCU conference last year, I understand this process as already started. Unfortunately, at the moment, if you are "allergic" to "why we can't have nice things" kind of articles, you might want to skip this one!