• 0 Posts
  • 100 Comments
Joined 2 years ago
cake
Cake day: September 2nd, 2023

help-circle
  • I know this thread is old. But I disagree with you.

    I agree that depending on how you use a debugger, some race conditions might not happen.

    However, I don’t agree that debuggers are useless to fix race conditions.

    I have a great example that happened to me to prove my point:

    As I was using a debugger to fix a normal bug, another quite strange unknown bug happened. That other bug was indeed a race condition. I just never encountered it.

    The issue was basically:

    1. A request to initiate a session arrives
    2. That request takes so long that the endpoint decides to shut down the session
    3. A request to end the session arrives

    And so handling the session start and session end at the same time resulted in a bug. It was more complicated than this (we do use mutexes) but it was along those lines.

    We develop in a lab-like condition with fast networking and computers, so this issue cannot happen on its own. But due to the breakpoint I put in the session initiation function, I was able to observe it. But in a real world scenario it is something that may happen.

    Not only that, I could reproduce the “incredibly rare” race condition 100% of the time. I just needed to place a breakpoint in the correct place and wait for some amount of time.

    Could this be done without a debugger? Most of the time yes, just put a sleep call in there. Would I have found this issue without a debugger? Not at all.

    An even better example:

    Deadlocks.

    How do you fix a deadlock? You run the program under a debugger and make the deadlock happen. You then look at which threads are waiting at a lock call and there’s your answer. It’s as simple as that.

    How do you print-debug a deadlock? Put a log before and after each lock in the program and look at unpaired logs? Sounds like a terrible experience. Some programs have thousands of lock calls. And some do them at tens of times per second. Additionally, the time needed to print those logs changes the behaviour of the program itself and may make the deadlock harder to reproduce.






  • Metric is a relatively recent invention. Every single country has had to ditch their measuring equipment in order to convert to metric.

    The reason it’s so expensive in the US is because they refused to change for so long. As the economy grows, the amount of equipment grows, so the more time you take to switch systems, the more expensive it will be.

    If the US wanted to switch relatively painlessly, they’d just gradually make some measurements officially in metric. You can produce products labeled in metric with imperial tools. If those tools are precise enough, or the error margins big enough, you would not notice the difference between imperial tools and metric ones. In fact, there’s probably many tools out there that can produce in both systems.

    It’s not a simple problem. But if it never starts to get solved, it will never be solved.

    The main obstacle is not economic, it’s cultural. People in the US are used to using imperial, many only used metric at school. They advocate online that their system is better, and keep using it.

    If USAians used metric in day-to-day life, they would prefer consuming products with metric info on them, so companies would produce more metric products, so they would have more incentives to adapt their tools to metric.

    How do you change culture? Simple. The first step is to make something “official”. Making metric official and “deprecating” imperial would mean that communication with the government would be in metric. Laws would have metric measurements, technical documents provided by the government would have metric measurements.

    If someone wanted to use imperial, they would have to constantly convert the numbers of the government, and you can’t ignore the government. So you either stubbornly convert each time, or you give up and start using metric yourselves.

    Of course in the early stages, the government could provide imperial measurements too, as a sidenote, a footnote or an appendix. But the main content would be in metric.

    But the US has decided it doesn’t want to do that. I don’t want to get too geopolitical, but that only works while the US is an economic superpower. We’ll see what happens once that is no longer the case.

    In the meantime, all I can do from the outside is try to convince random people from the internet. If they don’t switch to metric, they might at least stop advocating for imperial, and that would be a win.


  • That is in fact incorrect. And the reason is in that other comment. To make a summary of that other comment:

    If an only-metric guy wanted to communicate with an only-imperial one, each would need a table of conversions. For a basic use case, the metric cheat sheet would only need 8 entries, while the imperial one 10. That is, you need to memorize less "magic number"s for metric than for imperial. Furthermore, 5 of those entries in the metric cheat sheet are: 1000, 1000, 1/10, 1/100, 1/1000, which are obviously easy. So the real difference would be more like 3 entries to 10.

    Of course, any kind of real measurement you will need a calculator. But that is reality for any unit conversion across systems. The difference is that you only need to remember 3 numbers to convert to/from metric, but you need 10 to convert to/from imperial.



  • As I said. You can use whatever units you want for yourself. I don’t care about that.

    The problem is when we are communicating with each other. When communicating, it’s more than one party involved. And our goal should be to communicate clearly and easily so both the talker and the listener have an easy time transferring information.

    This is not like language. Conversion between one unit and another is as simple as a multiplication. We can both speak in imperial and metric if we have a conversion table and a calculator.

    Now, let’s say you communicate in imperial. And I communicate in metric. We are allowed to have a conversion table and a calculator. Here is my cheatsheet:

    Inch = 2.5cm
    Foot = 12inch
    Yard = 3 feet
    Mile = 1760 yards
    Fl oz = 28ml
    Gallon = 4.5l
    Oz = 28g
    Pound = 16 oz
    Stone = 14 lb
    Ton = 2240 lb
    

    Here is yours:

    cm = 1/2.5 inch
    ml = 1/28 fl oz
    g = 1/28 oz
    metric ton = 1000kg
    
    k (kilo) = 1000
    d (deci) = 1/10
    c (centi) = 1/100
    m (milli) = 1/1000
    

    I only included the most common usages. The full cheatsheets are much larger but I believe we can agree this is a fair representation of common usage.

    Your cheatsheet contains 8 entries. Meanwhile mine contains 10. Therefore, metric is objectively easier to convert in a ratio of 8/10. Furthermore, subjectively, the case is worse. Since metric ton, kilo, deci, centi and milli have an obvious pattern that is easy to remember and use. Meanwhile the only subjective “advantage” of imperial is that fl oz and oz is the same, but that goes both ways, since g is also the same as ml, so it would be 7/9, which is better for metric than 8/10. So i don’t think there’s any subjective advantage for imperial.

    So yes, using a less efficient method of communication because “I’m more used to it” is dickish. Especially if the entire rest of the world uses the more efficient one. Especially if you already know the more efficient method. As you said, it is taught in American schools.

    Do you know what is even more dickish? Defending its usage for communication.

    If we go back to the language analogy: If 95% percent of the world understands only English, and English is objectively easier than Spanish and you also speak English, and you approach someone in spanish, and you keep speaking Spanish even though they are speaking in English, you are a dick.

    Of course this analogy is not perfect. Since English is not objectively easier than Spanish (in fact, I subjectively believe Spanish is easier).


  • I put this as part of a response to another user. But since it also answers the main question of this post I’ll repeat it here:

    Because it’s not only better for me, but it’s also better for you.

    It doesn’t matter if I tell you a distance in meters or kilometers, you only have to remember what that means in feet so you can convert it to whatever imperial distance you want. Just multiply/divide by 1000 afterwards by moving the decimal point. If 53 meters is 863 yards, 53 kilometers is 863000 yards.

    However, it does matter what unit you choose to communicate with me. I know that 1 inch is about 25.4mm/2.5cm, but if I’m unlucky and you decide to say it in feet, I’m going to need to Google the conversion.

    I don’t care what units you used for yourself, as you shouldn’t care what units I use for myself. However, if we have to communicate, we should both be as helpful as we can so we can communicate as easily and effectively as possible. Communicating with someone using imperial is a pain in the ass, while communicating with someone using metric is as easy as it gets. The only thing easier than metric is scientific notation, since with that you don’t even need to remember what the metric prefixes mean. However scientific notation is only easily written, not spoken. Speaking in scientific notation is a pain in the ass.



  • Tbh I have never had to think about the pressure of my tires that way. I pump the bike tires until I feel they are hard enough, and cars come with stickers in it that display the recommended tire pressure for them. 0 calculations needed.

    But if I had to calculate pressures:

    The lb<->psi conversion only works on 1G environments.

    Yes, most pressure calculations occur on 1G environments, but in that case 1kg=9.8N. which is basically 10N.

    If my car has 3000kg of mass, it weighs 30kN. Now the math is just as easy as lb<->psi. With the bonus addition that I can easily differentiate “kg of mass” from “N of force” instead of “pounds of mass” from “pounds of force”.


  • Not only kilometers and meters. You can also convert easily the following units to meters: gigameter, megameter, hectometer, decameter, decimeter, centimeter, millimeter, micrometer, nanometer, picometer.

    Additionally, you can easily convert these units to grams: gigagram, megagram, kilogram, hectogram, decagram, decigram, centigram, milligram, microgram, nanogram, picogram.

    Additionally, you can easily convert these units to liters: gigaliter, megaliter, kiloliter, hectoliter, decaliter, deciliter, centiliter, milliliter, microliter, nanoliter, picoliter.

    Additionally, you can easily convert these units to areas: gigaarea, megaarea, kiloarea, hectarea, decarea, deciarea, centiarea, milliarea, microarea, nanoarea, picoarea.

    Additionally, you can easily convert these units to newtons: Giganewton, meganewton, kilonewton, hectonewton, decanewton, decinewton, centinewton, millinewton, micronewton, nanonewton, piconewton.

    Additionally, you can easily convert these units to seconds: Gigasecond, Megasecond, kilosecond, hectosecond, decasecond, decisecond, centisecond, millisecond, microsecond, nanosecond, picosecond.

    Additionally you can easily convert these units to hertz: gigahertz, megahertz, kilohertz, hectohertz, decihertz, centihertz, millihertz, microhertz, nanohertz, picohertz.

    Additionally you can easily convert these units to joules: gigajoule, megajoule, hectojoule, decajoule, decijoule, centijoile, millijoule, microjoule, nanojoule, picojoule.

    Additionally, you can easily convert these units to watts: gigawatt, megawatt, hectowatt, decawath, deciwatt, centiwatt, milliwatt, microwatt, nanowatt, picowatt.

    Note that those lists are incomplete. You can expand them by “inventing” new ones by adding other prefixed. Like I did because when writing all of those manually on my phone angered the autocorrect. There are also many other units.

    And of course, the fun doesn’t end there. You can easily do the same for powers of those units. Like m2, m3, s-1.

    And let’s not forget that you can also easily convert between those “base” units and “compound” ones:

    (Kilo)gram meter to newton.

    1/second to hertz.

    square meter to area.

    Cubic meter to liter.

    (kilo)gram to liter (of water).

    Joule second to watt.

    If you want to convert 74962 feet to 95 yards or whatever, you do you. I’m going to keep using metric, because it’s not only better for me, but it’s also better for you.

    It doesn’t matter if I tell you a distance in meters or kilometers, you only have to remember what that means in feet so you can convert it to whatever imperial distance you want. Just multiply/divide by 1000 afterwards by moving the decimal point. If 53 meters is 863 yards, 53 kilometers is 863000 yards.

    However, it does matter what unit you choose to communicate with me. I know that 1 inch is about 25.4mm/2.5cm, but if I’m unlucky and you decide to say it in feet, I’m going to need to Google the conversion.

    Read those last 2 paragraphs again, and tell me what is more “dickish” (to use the same word you used).




  • I just don’t believe you at all.

    There are 12 inches in a foot. So the scale of a foot is 12x that of an inch.

    There are 100cm in 1m. That is 100x.

    Europeans convert cm to m very frequently, and it’s a scale shift 10x larger than the one of inch-foot.

    We also convert km to m frequently, which is a 1000x scale shift. It’s more than half that of yard-mile.

    The reason you don’t convert often is because it is a pain in the ass to do so. Not the other way around.

    The reason you say “an eight of a foot” has meaning, while “0.125 feet” does not. However, saying “125 meters” is way easier for both the listener and the talker than “an eighth of a kilometer”. If it weren’t, we’d say 1/8km, since nothing in metric prevents you from doing that.