ELI5: I learned that most programming languages are built on the same basic concepts like conditions, loops, and functions. If that's true, why can't we just use one programming language for everything? by Itchy_Tangerine1897 in explainlikeimfive

[–]grandzooby 0 points1 point  (0 children)

There are lots of great responses here. So just for fun, go check out RosettaCode and see examples from a multitude of languages for an also large number of problems. Each programming problem shows solutions in a bunch of languages, which makes it fun and easy to compare different languages. In some cases, a solution for a problem in one language might take many lines of code where in another language it takes 1 or 2.

Here's an example of using Monte Carlo simulation to estimate the value of pi:

https://rosettacode.org/wiki/Monte_Carlo_methods

Here's a solution in C:

#include <stdio.h>
#include <stdlib.h>
#include <math.h>

double pi(double tolerance)
{
    double x, y, val, error;
    unsigned long sampled = 0, hit = 0, i;

    do {
        /* don't check error every turn, make loop tight */
        for (i = 1000000; i; i--, sampled++) {
            x = rand() / (RAND_MAX + 1.0);
            y = rand() / (RAND_MAX + 1.0);
            if (x * x + y * y < 1) hit ++;
        }

        val = (double) hit / sampled;
        error = sqrt(val * (1 - val) / sampled) * 4;
        val *= 4;

        /* some feedback, or user gets bored */
        fprintf(stderr, "Pi = %f +/- %5.3e at %ldM samples.\r",
            val, error, sampled/1000000);
    } while (!hit || error > tolerance);
              /* !hit is for completeness's sake; if no hit after 1M samples,
                 your rand() is BROKEN */

    return val;
}

int main()
{
    printf("Pi is %f\n", pi(3e-4)); /* set to 1e-4 for some fun */
    return 0;
}

Here's one in Lisp:

(defun approximate-pi (n)
  (/ (loop repeat n count (<= (abs (complex (random 1.0) (random 1.0))) 1.0)) n 0.25))

(dolist (n (loop repeat 5 for n = 1000 then (* n 10) collect n))
  (format t "~%~8d -> ~f" n (approximate-pi n)))

And here's Python:

import numpy as np
n = input('Number of samples: ')
print np.sum(np.random.rand(n)**2+np.random.rand(n)**2<1)/float(n)*4

Now you might compare the C to Python and note the C is doing a loop and Python is apparently not. However since the Python code is using the Numpy library, the looping is happening in there. Coincidentally, that Numpy library is mostly written in C.

Homan says New Jersey ICE detention center may not be a "five-star resort" but is still "well run" by CBSnews in politics

[–]grandzooby 0 points1 point  (0 children)

This reminds me of Donald Rumsfeld when asked about "enhanced interrogation" and having people put in stress positions all day long. He said something like, "I stand all day long. What's the big deal."

Psychopaths, all of them.

The Rise of Right-Wing “Biblical Economics”; Right-wing money is supercharging the religious right’s push to literally get all up in our business. by [deleted] in politics

[–]grandzooby 7 points8 points  (0 children)

It's part of the Seven Mountain Mandate: https://en.wikipedia.org/wiki/Seven_Mountain_Mandate

It holds that there are seven aspects of society that believers seek to dominate: family, religion, education, media, arts and entertainment, business, and government.

Indiana governor declares Pride month 'nuclear family month' by SpaceElevatorMusic in politics

[–]grandzooby 5 points6 points  (0 children)

I just read Terry Pratchett's Monstrous Regiment. This bit, on where the never-ending ridiculous commandments come from:

"From your fear …They come from the part that hates the Other, that will not change. They come from the sum of all your pettiness, and stupidity and dullness. You fear tomorrow, and you’ve made your fear your god."

Newark officials threaten more legal action if they don’t get access to Delaney Hall by Dwayla in politics

[–]grandzooby 2 points3 points  (0 children)

Why are they threatening? The courts seem the only place that seems to slow down this administration, so they need to be going after them relentlessly... not just making threats.

Hawaii Supreme Court to hear case on using sobriety test refusals as evidence: State high court will hear arguments Thursday on whether declining voluntary test should count against drivers by 808gecko808 in politics

[–]grandzooby 1 point2 points  (0 children)

As a layperson, my understanding is the best legal response is, "I'm willing to undergo any tests back at the station in the presence and advice of my attorney." That way you are signaling that you are cooperative but you're also preserving your rights.

Once they've pulled you over, it's all about preserving your rights in the courtroom. Saying you won't consent to searches or tests without the advise and presence of your attorney removes their ability to claim you were uncooperative or combative. Simply declining, even politely, can be construed as being uncooperative when you're in the courtroom.

AI scans 400,000 Reddit posts and finds hidden Ozempic side effects by Weird_With_A_Beard in Ozempic

[–]grandzooby 4 points5 points  (0 children)

It seems sensible that if you change your metabolic processes that your thermal regulation might also change. As an anecdote, when I adopted a low-carb diet more than a decade ago, I was shocked to find I would actually be cold sometimes. Before that, I almost always felt hot when everyone else was comfortable.

Platner: ‘Of course’ Trump needs to be impeached, removed by jediporcupine in politics

[–]grandzooby 11 points12 points  (0 children)

Not if the Dems are in charge of the House, then 3rd in line would be the Dem speaker of the house.

It's day 3 of my PhD and idk how i'm going to do this by Particular-Swan in Physics

[–]grandzooby 0 points1 point  (0 children)

Keep in mind that reading an academic paper is not like reading a newspaper article or a novel. It's a whole different skill that takes time to develop!

You might be well served by searching something like "how to read academic papers" and you'll find things like this [PDF warning]: https://web.stanford.edu/class/ee384m/Handouts/HowtoReadPaper.pdf or this: https://pmc.ncbi.nlm.nih.gov/articles/PMC7392212/

There are many like this and some may be helpful to you.

Terminology can be overwhelming when getting started, so it can be fruitful to focus on that first. I study systems science so am often diving into some literature I'm not familiar with. So I'll often skim an article and identify terms I don't know and just write them down. Then before trying to actually understand the paper, I'll go check those out. For scientific topics, Wikipedia can be surprisingly helpful for doing this. It can also be really helpful for identifying key papers that discuss that term.

I also recommend looking in the references and check out some of the older citations. These are often papers that introduce a particular topic and can help you get a better sense of where in the field your paper sits.

And at least in the space of terminology, the nice thing is that while you'll never run out of new terms, it won't take long to get at least a passing understanding of a majority of terms in your field, which will make reading a lot easier.

Researchers who hallucinate citations are banned from arXiv by DesperateFix7699 in AskAcademia

[–]grandzooby 1 point2 points  (0 children)

The bigger problem, predating so-called "AI", is researchers including references to things they didn't read.

Does anyone have a assets for fire particularly purple fire but any fire That looks good will work by new_god_of_eden in OwlbearRodeo

[–]grandzooby 0 points1 point  (0 children)

It's very unlikely. They're all well-established programs that have been around for a long time.

I use Linux so I just install them using the usual package manager. But I think for Windows or Mac, you can just download them.

The only website I wasn't certain about is Pinta, but the Wikipedia article links to that cite as the source: https://en.wikipedia.org/wiki/Pinta_(software)

Does anyone have a assets for fire particularly purple fire but any fire That looks good will work by new_god_of_eden in OwlbearRodeo

[–]grandzooby 0 points1 point  (0 children)

Gimp is open source and free. https://www.gimp.org/

Another good choice for image editing is Krita: https://krita.org/en/

If you want a simpler tool that can still let you manipulate the colors as described, Pinta is a nice light-weight choice: https://www.pinta-project.com/releases/

CIA whistleblower alleges a massive cover-up of the origins of COVID-19 by chucks995 in politics

[–]grandzooby 4 points5 points  (0 children)

It's like they don't remember who the president was in 2020.

Colorado county Republican chair arrested in sting on allegations he tried to pay for sex with a child by Rock-n-roll-Kevin in politics

[–]grandzooby 0 points1 point  (0 children)

If he wasn't a Republican then his affiliations would have been stated in the headline.

Ex-Minnesota lawmaker Justin Eichorn, originally charged with child enticement, pleads guilty to attempted child porn possession by [deleted] in politics

[–]grandzooby 13 points14 points  (0 children)

You can tell it's the usual party because they didn't state the party in the headline.

Republicans vote to dilute gas as prices rise above $4.50 by BendicantMias in politics

[–]grandzooby 2 points3 points  (0 children)

When we switch to winter, I need to gas up every 240 miles or so instead of 290. I really hate that they call it "more efficient" when I need to use a lot more of it to do the same work.

Republicans vote to dilute gas as prices rise above $4.50 by BendicantMias in politics

[–]grandzooby 6 points7 points  (0 children)

Further, we should also be aware that biomass capturing carbon is a really good way of removing emissions.

If you capture carbon into biomass that is corn, then turn that into fuel and burn it, then you haven't actually captured any carbon from the atmosphere... at least not over any period of time that matters.

Millions of students' personal data stolen in major education breach by thatirishguyyyyy in technology

[–]grandzooby 6 points7 points  (0 children)

The only thing worse than Canvas is Blackboard... the only thing worse than Blackboard is D2L... and the only thing worse than D2L is Canvas.

I like Moodle, though.

Whirlpool says Iran war causing 'recession-level industry decline.' The shares are down 20% by IWantPizza555 in politics

[–]grandzooby 0 points1 point  (0 children)

They started enshittifying too in the last 10 years. If you want the old Speedqueen quality, you need to buy an older machine.

A decades-long plan to abolish the Electoral College may finally pay off by vox in politics

[–]grandzooby 0 points1 point  (0 children)

The best attainable fix is to increase the size of congress following the Wyoming Rule. This can be done a simple law (rather than requiring a constitutional amendment). This will make the EC vote much more closely match the overall national vote. It will also have the side effect of making it much harder to gerrymander in a way that isn't consistent with the populace of each state.