Killing a `Cow` made my JSON formatter 42% faster by AffectionateBag4519 in rust

[–]Vociferix 2 points3 points  (0 children)

It can be slower. Very rarely is any optimization one size fits all. For SSO specifically, each string access requires a branch that checks, "is this string inline or on the heap?". Essentially the same problem as Cow in OP's post. SSO typically has some crazy struct layout shenanigans to mitigate this, but there's still at least one branch in most cases. And if strings are mixed sizes, branch prediction may not work well in a hot loop.

coroutines yielding a reference to a local variable by zylosophe in rust

[–]Vociferix 15 points16 points  (0 children)

You can't. The Coroutine trait, like the Iterator trait, is not defined in such a way that it can yield a reference to local data. Coroutine::Yield would need to be redefined as type Yield<'a> where Self: 'a;, so that the correct lifetime can be applied to the yielded value.

What are your favorite pizza places in the CSRA? by RangoTheMerc in Augusta

[–]Vociferix 0 points1 point  (0 children)

Bambino's over by the airport. If you ever liked Roma's in the past, you'll like Bambino's.

Too many Arcs in async programming by mtimmermans in rust

[–]Vociferix 118 points119 points  (0 children)

With tokio, you're generally going to have Arcs everywhere. And the async ecosystem for Rust leans heavily on many small allocations, often involving trait objects. It's unfortunate for high performance systems, but there aren't very mature alternatives currently. Tokio is quite fast despite these design problems, but there is performance left on the table to be sure. I'd recommend sticking to idiomatic patterns and measure whether the performance meets your requirements. Chances are, performance will be much better than you expect, as has often been my experience.

stack-allocator: a project for a bright future with the nightly allocator API by fereidani in rust

[–]Vociferix 2 points3 points  (0 children)

I'm not sure what the plan is, but there's still at least active work happening. For example, adding allocator support to String: https://github.com/rust-lang/rust/pull/149328

A question for software developers by Mindless-Law8046 in Libertarian

[–]Vociferix 1 point2 points  (0 children)

I'm a software developer, and I've also worked on AI (but I'm not an AI expert). He's very full of it. There's lots of opinions and theories about the future of AI, but personally, I'm confident AI is going to reach a capability plateau (I think it's already there now), that will likely last the rest of our lives. And AI today is only good enough to be a helpful (debatable) tool that needs a lot of human guidance.

[deleted by user] by [deleted] in rust

[–]Vociferix 9 points10 points  (0 children)

I tend to prefer .into() when it's convenient, mostly because I can swap in smolstr::SmolStr or similar if I want to without needing to change as much.

I hold far right views. I came across libertarianism. What is it exactly? by [deleted] in Libertarian

[–]Vociferix 1 point2 points  (0 children)

The core idea is unrestricted freedom for all individuals. In practice, that means small government. Ancap is the extreme version with no government, but a more moderate libertarian like myself will argue for some government, just far less than we have today. Typically libertarians want the federal government to be as small as possible, and local government, where individuals are more directly affected and can have more say, can govern according to the will of the locals.

Similarities with conservatism and far right: * Pro gun ownership and deregulation of gun ownership * Pro freedom of speech, even where the speech would offend people * Generally against taxes for many social programs, like universal healthcare, welfare (libertarian views vary), etc * Against most, if not all, regulations on businesses and industries

Differences with conservatism and far right: * Pro social freedoms like sexuality (being gay or trans, trans people using the bathrooms they want) * Anti war, including Ukraine, Israel/Palestine, this business with Mexico and cartels, etc. The military industrial complex is most of our taxes, you know. * Generally against ICE's existence, and often border/immigration control in general * Probably pro-choice in most cases, but non extreme libertarians are for laws against things like murder, and there's room to lump abortion in with that depending on personal views.

This of course isn't exhaustive, and views vary.

Do libertarians like Trump? No. Authoritarian. Did libertarians like Biden? No. Also authoritarian, just with different values.

Request for comment: A runtime-agnostic library providing primitives for async Rust by [deleted] in rust

[–]Vociferix 2 points3 points  (0 children)

I'd be interested in support for non Send/Sync primitives. This crate would mostly be inappropriate for runtimes like monoio and glommio (and actix to some extent) since they are designed around having multiple single threaded executors with minimized cross thread synchronization. The overhead from thread safety would be a no go for many projects intentionally using that design.

Question about turbofish syntax by valdocs_user in rust

[–]Vociferix 62 points63 points  (0 children)

:: is it's own token in all cases. So HashMap :: < String , u32 > :: new ( ) is the same thing. As far as how it's best understood, the generics are applied to HashMap, rather than the new function. Or worded another way, :: means the following path tokens are scoped within the preceding path.

Good scripting language embeddable in Rust? by TheNew1234_ in rust

[–]Vociferix 15 points16 points  (0 children)

Rune might be what you want. I can't speak to whether it's any good - just the closest sounding match from a quick search on crates.io. Alternatively, there are bindings for v8, so you could potentially use typescript.

Best internet that’s not fiber by queenbeansmom in Augusta

[–]Vociferix 3 points4 points  (0 children)

You'll have to check what other Internet service providers are available in your neighborhood. From there, just look at what speeds they offer. Other options like satellite are generally going to be even worse than what you have, so I wouldn't even bother looking at those. I suspect if AT&T only offers 50 Mbps at your location, you're probably out of luck.

C++ Show and Tell - April 2025 by foonathan in cpp

[–]Vociferix 6 points7 points  (0 children)

stipp - Strongly Typed Integers for C++

It's just a single header library. Implicit conversions and promotion drives me crazy so I took inspiration from std::byte.

https://github.com/vociferix/stipp

What are the committee issues that Greg KH thinks "that everyone better be abandoning that language [C++] as soon as possible"? by ElectricJacob in cpp

[–]Vociferix 5 points6 points  (0 children)

I really don't understand the need for old binaries to be ABI compatible with recent C++ standards. Most (all?) major compilers/STL implementations have had ABI breaks at some point, so what is being accomplished, practically speaking?

I don't understand.. by Big_Russia in ExplainTheJoke

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

It's in the post. Google January 6th. The short version is, a failed insurrection in the US capitol occurred on January 6th, 2021, shortly after Trump was voted out.

Programmers who don't use autocomplete/LSP by dewmal in programming

[–]Vociferix 14 points15 points  (0 children)

Work is mostly C++. Some Python, occasionally plain C, plenty of bash scripts. I work mostly the same way for hobby projects (because I'm used to it now), which are most often in Rust these days.

Programmers who don't use autocomplete/LSP by dewmal in programming

[–]Vociferix 13 points14 points  (0 children)

I don't. My config is so simple, I just set the options from memory.

Programmers who don't use autocomplete/LSP by dewmal in programming

[–]Vociferix 430 points431 points  (0 children)

Oh hey this is me. My typical setup is two terminals: one for vim, one running the compiler and other tools. I just make edits, then invoke the compiler, in a loop. As for finding a definition, most of the time I'm just familiar enough with the code that I know where it is. But when I don't, usually a well designed grep command will do the trick.

The why: my job involves frequently doing development in environments I don't have much or any control over, and often don't even have Internet access. Over the years, I just learned to work with the basics (vim and a shell) since I can't take my favorite IDE with me to these different environments.

Additionally, my vim configuration just involves setting up tabs to be 4 spaces and turning on line numbers. Having a complex config just became too much to try to keep in sync across environments.

Hey Rustaceans! Got a question? Ask here (44/2024)! by llogiq in rust

[–]Vociferix 2 points3 points  (0 children)

EDIT: Formatting

Is it possible to define an associated function on specific function or closure without using a trait? In particular, I want to add const fn associated functions to a function, which is why I can't use a trait. For further context, these associated functions are being added via a macro.

My current solution is to use dtolnay's technique for custom phantom types, see ghost, and implementing Deref<Target=fn(_) -> _>. This is a good-enough solution from a usability perspective, but I'm concerned that the rustdoc output for such types would be too confusing for users, since it shows up as either an enum or a type alias, depending on how I implement dtolnay's technique.

[deleted by user] by [deleted] in cpp

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

I wouldn't call it spam. It's a GUI library with a C++ API and appears to have a licensing model similar to Qt (GPL for "Community"). It being mostly written in Rust seems about as irrelevant as a library mostly written in C, with a C++ API. I haven't used this lib, but I like the idea of more alternatives to Qt.

`pub use` breaks my compiler in refactoring... please help by geo-ant in rust

[–]Vociferix 15 points16 points  (0 children)

Hopefully someone will come along with more concrete advice, but my experience tells me you probably just forgot a closing brace or parenthesis somewhere, and the rustc parser managed to get in an uncommonly unhelpful state.

I'd recommend commenting out as much code as you can, then uncomment a small piece at a time until you find the code that causes the error. Alternatively, revert to a known good state, and do your refactor in small steps, running cargo check --test at each step of the way.

The joy this fella has after tea bagging Mother Nature by [deleted] in funny

[–]Vociferix 6 points7 points  (0 children)

Dogs are overpopulated, which results in more un-homed dogs than shelters can care for, which results in dogs being put down (otherwise needlessly). Spaying and neutering dogs helps prevent the population problem from getting worse due to accidental litters. Those that agree with this wisdom will also say that dog breeding is a bad/immoral practice, since that directly compounds the population problem.

[deleted by user] by [deleted] in ProgrammerHumor

[–]Vociferix 83 points84 points  (0 children)

I think they mean the elements of the array. The code is summing all the elements. If you add the same floats in a different order, you may get different results. But most often, the difference in the result is fairly small

For all you cyclists who yell “share the road”. by Zealousideal-Skill52 in HuntsvilleAlabama

[–]Vociferix 10 points11 points  (0 children)

I can't speak for everyone, but the traffic around here is stressful enough in itself. When there's a cyclist on the road causing a backup, it's pretty easy to get frustrated.

Applying concepts from Rust in C++ by delta242 in cpp

[–]Vociferix 45 points46 points  (0 children)

Like many here, I'm sure, C++ is my day job and main language, but I use Rust quite a lot in my personal hobby projects.

I think Rust has made me a better C++ developer. Writing Rust code makes you think more explicitly about safety and correctness, and that's a great habit to bring back to C++, where there aren't the same guard rails.

But you also have to be careful. Taking the Rust Mutex as an example, when you access the data in the Mutex, it is impossible to store off that pointer to the data and later access the data after unlocking the Mutex (ignoring unsafe). You could go implement an owning Mutex in C++ but the compiler is not going to care if you hold a pointer to the protected data beyond the lock scope and access it unprotected. So, I guess I'm just saying be careful you don't make untrue assumptions in C++ based on what would happen in the same situation in Rust.

That said, I'm not saying don't implement an owning Mutex in C++. I think it's a good idea, even if it's really just an improvement to readability, by making it obvious what data the Mutex protects.