Programming

24191 readers
370 users here now

Welcome to the main community in programming.dev! Feel free to post anything relating to programming here!

Cross posting is strongly encouraged in the instance. If you feel your post or another person's post makes sense in another community cross post into it.

Hope you enjoy the instance!

Rules

Rules

  • Follow the programming.dev instance rules
  • Keep content related to programming in some way
  • If you're posting long videos try to add in some form of tldr for those who don't want to watch videos

Wormhole

Follow the wormhole through a path of communities !webdev@programming.dev



founded 2 years ago
MODERATORS
376
377
378
19
submitted 5 months ago* (last edited 5 months ago) by cm0002@lemmy.world to c/programming@programming.dev
379
 
 

If you were designing a standard library of a high level language (like Rust, C++, etc.) what would it do if while getting the current time of day (e.g. SystemTime::now()) it encountered a failed kernel system call (e.g. to clock_gettime) and why?

What do you think the existing implementations do?

  • Return error or raise exception
  • Return 0
  • Return undefined values (like stack garbage)
  • Panic/crash/segfault
380
 
 

I've been trying to make an RNG that outputs data in a way that has an entropy that approaches a user defined value as the output gets arbitrarily long. I've been struggling at a certain point that I'll detail later, but the main motivation for this project is just trying to practice on a problem like this. Here's my repo.

In this post, we'll be talking about Shannon entropy. Here's a good refresher for it. If you scroll down there's examples and the equation.

Looking at the equation, when developing this algorithm we have two different input values for it: the target entropy and the number of outcomes, n. From there, we can create a probability vector of length n whose entropy is equal to the target entropy, then we can map objects to elements of the probability vector and sample indices from the vector by using the alias sampling method. From there, we have a nice algorithm for creating sequences of any type that have the target entropy.

So where's the problem? It's in actually generating the probability vector. In order to get to a V0, I implemented two functions: helpers::compute_probabilities and helpers::find_lambda. compute_probabilities creates the probability vector that has the target entropy by sampling from the exponential distribution. find_lambda repeatedly calls compute_probabilities using binary search to converge on a lambda that produces a probability vector with the target entropy. The problem line is right here:

    pub fn compute_probabilities(num_outcomes: usize, lambda: f64) -> Vec<f64> {
        let unnormalized: Vec<f64> = (1..=num_outcomes)
            .map(|i| (-lambda * i as f64).exp())
            .collect();

When calculating the actual probability values, they get exponentially smaller as the probability vector gets bigger. This works. Technically. But in the worst way. When sampling using vectors generated using this function, they realistically only sample the first few elements. That's the problem. I want to more equally distribute the probability in such a way that doesn't make the tenth value arbitrarily small but the first value really large in comparison. For reference, using this function and lambda=1, the tenth element in the vector is 5x10^-5 but the first value .37.

I figured I'd post this before I start throwing a bunch of different distributions at this function to see if anyone sees any inherent flaws with my process.

381
 
 

@programming Unpopular opinion: 95% percent of all modern programming langueges are either bloated/proprietary/unneccesarily complex. pretty sure C & assembly can do it all (even for web development, just compile c to WebAssembly)

382
383
384
 
 

I want clean history, but that really means (a) clean and (b) history.

People can (and probably should) rebase their private trees (their own work). That's a cleanup. But never other peoples code. That's a "destroy history"

So the history part is fairly easy. There's only one major rule, and one minor clarification:

  • You must never EVER destroy other peoples history. You must not rebase commits other people did.

[...]

If you are working with git together with other people, it's worth a read.

385
 
 

I think it's very interesting, and something i've been looking for for a very long time. Finally a programming language focused on efficiency

386
 
 

However, there are some important features that WinSock just doesn’t expose. […]

Rust’s current async ecosystem is built atop a particularly cursed concept. It’s an unstable, undocumented Windows feature. It’s the lynchpin of not only the Rust ecosystem, but the JavaScript one as well. It’s controversial. It’s efficient. […] Without it, it’s unlikely that the async ecosystem would exist in its current form. It’s called \Device\Afd, and I’m tired of no one talking about it.

387
 
 

“Jujutsu (jj) is a version control system with a significantly simplified mental model and command-line interface compared to Git, without sacrificing expressibility or power (in fact, you could argue Jujutsu is more powerful). Stacked-diff workflows, seamless rebases, and ephemeral revisions are all natural with jj [...]”

Part 2 of the series is out and is here.

388
 
 

Well, I hope you don't have any important, sensitive personal information in the cloud?

389
390
391
 
 

prizes include 11 hours for the Smolhaj, 5 hours for a 128gb thumb drive, 3 hours for Geometry Dash, and 21 hours for 6 months of Mullvad. like i said it's just like a rewards program lol

392
393
394
395
 
 

Today I published an update to my remote-docker project.

The purpose of this project is to run Docker on a remote computer while providing container access to specific parts of your local filesystem with X11 support.

For example, you can use this to run your browser inside a container and only give it access to your ~/Downloads folder.

Access is over SSH (and SSHFS) and Docker is not installed on your workstation, just a few bash scripts.

Feedback (and patches .. Ha!) welcome.

Have fun!

O

396
397
 
 

I am a senior java developer in the cloud/distributed arch/ microservice area.

I've touched on golang in the past, but not learnt it in any formal/extensive way.

I see it cropping up in many java/microservice positions, and I'm curious if this is at some point going to overtake java in my area.

The current benchmarks seem to suggest that if autoscaling is key to your services, golang is the way to, well, go.

I looked at the job market and it doesn't yet seem to have taken over, but I'm curious how this is likely to play out over the next decade and if quakus for example is likely to become more competitive against golang. Interestingly, golang specific roles on average pay less than java ones in my area.

Let me know your thoughts or if you have any good articles / content on the subject.

398
 
 

Archive link: https://archive.ph/A7LI4

Marianne Belotti has worked at large institutions with modernizing decades-old code bases. She is author of the book "Kill it with Fire" [review].

From that book's author bio:

Marianne Bellotti has worked as a software engineer for over 15 years. She built data infrastructure for the United Nations to help humanitarian organizations share crisis data worldwide and tackled some of the oldest and most complicated computer systems in the world as part of United States Digital Service. At Auth0 she ran Platform Services, a portfolio that included shared services, untrusted code execution, and developer tools. Currently she runs Identity and Access Control at Rebellion Defense. She can be found on most social networks under the handle bellmar.

399
 
 

Cody, one of the first few decently good AI assistants that were well integrated into VSCode bit the dust just recently as the greedier and greedier Sourcegraph direction decided to switch to the completely Enterprise (read proprietary) "solution" Amp.

With this commit, another notable project by them goes down, first was their signature code search engine, now this, I just feel sorry for everybody who contributed and now will see pretty much all their efforts rendered meaningless, it was already apparent by how Sourcegraph approached Search sunsetting how much they care about open source, but I'd say this seals the deal even better if you needed insight into whether to trust them or not.

I think what's left by them that might be useful still is the zoekt library and a few other minor repos they have, but they're nothing compared to the impact of the other two.

Things like these make me question how we can just buy in to projects using non-copyleft licences, it's a time bomb, especially with corporate driven software and I see many developers fall into that trap, that in an endeavour for perceived simplicity, will choose Apache, MIT, Unlicense (pls not this one 🥲), or what have you and not care.
What people see as pragmatic in open source is really just a conclusion that comes from the point of view of the maker, rather than the community

400
view more: ‹ prev next ›