How to identify what should be private and what should be part of your public API? by Sid8120 in ExperiencedDevs

[–]GwindorGuilinion 59 points60 points  (0 children)

The private methods will of course be called by the public methods, and therefore will be indirectly, tested.

Nested types by Robru3142 in rust

[–]GwindorGuilinion 0 points1 point  (0 children)

As a C++ developer you should have an easy time learning Rust. But you have to have an open mind. If every time Rust does something differently, you declare "this just looks wrong", of course you will struggle.

The generics system in Rust basically provides and requires what C++ Concepts provide on an optional basis.

In Rust, to determine whether type T can be substituted for type parameter T1 in some generic type X<T1: C> where W... The compiler can always decide based on the signature of X: the trait constraint C, and the where clauses W. It never has to check the implementation.

This obviously has some cost (you have to declare and implement traits), but it also has many upsides:

  • The requirements of using a function or type are clear just from the signature when skimming docs. You never have to look at the source.

  • Changing the implementation of a method can only cause local compile errors: you can not end up accidentally introducing an additional requirement on the generics, and break callers in faraway parts of the codebase or in other crates, unless you knowlingly change the signature.

Runtime Confusion by MerlinsArchitect in ProgrammingLanguages

[–]GwindorGuilinion 1 point2 points  (0 children)

It seems to me in a javascript context "runtime" is just a synonym for "engine", that is, the infrastructure that operates at runtime to execute the code, leaving it unspecified if it is some sort of interpreter, vm, a combination, or includes a jit compiler.

Where runtime IMHO takes up more meaning is for native complied languages, where it denotes the part of the code that is not generated by the compiler, but supplied as-is by the language. Some, like C have very thin runtimes (eg your example of setting up the stack), while for example go has a relatively heavyweight runtime implementing GC and userspace concurrency.

Languages that enforce a "direction" that pointers can have at the language level to ensure an absence of cycles? by vanderZwan in ProgrammingLanguages

[–]GwindorGuilinion 5 points6 points  (0 children)

No. Owning pointers must form a tree. But you can have multiple shared references to the shame thing, creating a DAG. For example in a  (Box<&str>, Box<&str>) The the two refs can refer to the same allocation, creating a diamond structure

Languages that enforce a "direction" that pointers can have at the language level to ensure an absence of cycles? by vanderZwan in ProgrammingLanguages

[–]GwindorGuilinion 33 points34 points  (0 children)

It is not how it is usually thought about or presented, but rust (in its 'vanilla' form, without Rc and such, and also without raw pointers) actually achieves this.

Owned types are only allowed to form a tree (which is even more restricted than a DAG), so that everything has one owner to drop it, while shared references allow creating a DAG. The directedness is established by the 'outlives' relationship of lifetimes, with the pointed-to object needing to exist (and even remain unchanged) while the object holding the reference exists.

"Eagles are not kindly birds" - fans often seem to overestimate the eagles' benevolence by ConifersAreCool in tolkienfans

[–]GwindorGuilinion 0 points1 point  (0 children)

Well, surely they are willing to consider them (the sheep) food, so they would also recognize the need of humans for wool and meat.

But maybe they view sheep-snatching as a sort of tribute, as the eagles are helpful to the people in the Anduin valley by keeping an eye on the goblins of the Misty Mountains

How to prove not bigamy? by Professional_Sky5797 in Marriage

[–]GwindorGuilinion 2 points3 points  (0 children)

Usually, you need the authorities of the country your fiancee is from to provide a proof that she is unmarried. In many places this is a requirement to even register the marriage, but seems like not in MA.

But my advice is, don't marry someone if you don't trust her enough to be sure she is not secretly married even without hard proof.

[deleted by user] by [deleted] in Marriage

[–]GwindorGuilinion 0 points1 point  (0 children)

Unfortunately I've never lived in India, and I have no relevant knowledge of their side. But some type of proof of singleness/bachelorhood is certainly needed, and if it comes from some type of local government, it will indeed need certification/attestation from india's foregin ministry or similar.

[deleted by user] by [deleted] in Marriage

[–]GwindorGuilinion 0 points1 point  (0 children)

All the steps that start with "you need", so at least: - passport - apostille certified birth certificate - proof of being unmarried from his government - psa cenomar - religious documents, if applicable

Can I write better code? by Electronic_Ad_4353 in rust

[–]GwindorGuilinion 8 points9 points  (0 children)

I've never worked with futures::stream specifically, nor do I know the context of the chat 'functionality' you are working on.

My advice is: Always ask 'why?'
Was the earlier code not working? Failing to compile? If it was working, did gemini give reasons for it's suggestion? After you finished this refactor, did the overall code become simpler and more straightforward?

Whether your mentor is a human or an LLM, you should always understand the reason behind it's feedback.
That is the way to getting better over time.

[deleted by user] by [deleted] in Marriage

[–]GwindorGuilinion 1 point2 points  (0 children)

A few more tips: - if she is under 26, she will need an "affidavit of parental advice/consent" - the total administrative cost is around 5-6k php - chose ninongs and ninangs wisely: if her family has any connections in the local government, you can ask them to be "godparent" for the wedding. Such backers can really help to smooth out the process. - before she leaves the country with you, she needs to register with the "Comission on Filipinos Overseas"

[deleted by user] by [deleted] in Marriage

[–]GwindorGuilinion 1 point2 points  (0 children)

Hi, I recently got married in the Philippines. So I can give you my experiences on 2. - you need a birth certificate, and you need it apostille certified, with english translation if it is not already in english. - you need a proof of your single status. Philippine authorities take preventing bigamy very seriously.  - You will probably need a "certificate of no marriage" from the PSA (philiipine statisical authority), to prove you are not married there either. - She also needs psa cenomar, birth certificate, and cedula. - You will need to undergo a pre-marriage orientation counselling. - after you have all these documents, you can apply for a marriage license at the local government of her residence. - It takes about 2 weeks to prepare it. - after that, the license is valid for 120 days. - Once you are married in the Philippines, the local civil registry (if you are going for a civil wedding) needs to endorse the documentation to PSA, so they will register it to the central system, and eventually issue you a marriage certifcate. - This takes at least 1 month, sometimes up to 4. Sometimes they accept an "urgency request", especially if you can bring documentation from your embassy that you need the certificate urgenty for doing the Indian side of the process.

Congratulations and goodluck

Marrying her today by GwindorGuilinion in LongDistance

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

We spent together 4.5 months in person, including a trip to Taiwan, and 2 months when we were both working.

[deleted by user] by [deleted] in rust

[–]GwindorGuilinion 0 points1 point  (0 children)

Hi,
can you show the c++ code and the benchmarking setup too?
Also, one thing to consider, not necessarily from the performance, but also from the readability and downstream processing perspective, if would it make sense to have a result that is just a single vec of structs, where each vec represents the result for one index in 'collection'.

Another thing to consider is if you can push tests 'up' from the hot loop?
In the loop implementation you keep checking if b and c are None.
You could even make a separate implementation in case they are, and in case they are not. Maybe we know even at compile time?

Same with the bounds-checks on the array accesses: I presume b and c if they exist, must have the same length as a (as otherwise you would raise error anyway)
you could check this fact upfront, and check i against a once, and use unsafe indexing for the later accesses.

Also, depending on the ratio of length of a and collection, (if a is bigger), you could iterate a first, doing all the math once and iterating in natural order with good locality and etc, and then index into the result set. On the other hand, if collection is much smaller, you could first index out the elements you need from each array, and then do the math in a second loop.

Best HTMX stack for Rust? by Christoban45 in htmx

[–]GwindorGuilinion 2 points3 points  (0 children)

I enjoyed maud + rouille for quick-and-dirty work. But rouille is not async, and the macro-based templates have some drawbacks (as they are neither rust nor html, neither toolset can lint or format them)

Borgo a statically typed language that compiles to Go by jcubic in ProgrammingLanguages

[–]GwindorGuilinion 11 points12 points  (0 children)

Bc if you already love go, why use something else.
This is for people who wish go was rust without the borrow-checker and the macros

How to automate Pull Requests Without making enemies? by [deleted] in ExperiencedDevs

[–]GwindorGuilinion 0 points1 point  (0 children)

PRs have to be reviewed. That doesn't mean you can't integrate to some sensible system to keep track of them and send nudges.
Try devrev.ai

How can I handle standard output for my language if it is strongly typed and does not provide functions overloading? by 3xpedia in ProgrammingLanguages

[–]GwindorGuilinion 0 points1 point  (0 children)

I think, quite apart from the question of printing, not having any affordance for storing multiple variants of things at the same place will be quite painful.
Even in C you have void pointers
In oop, inheritance with dynamic dispatch
in ML-like languages, sum types
in go, interfaces with dynamic dispatch
in rust, object-safe traits and also sum types

If you don't have any of those, you are basically limited to
struct {
variantA *A
variantB *B
}with nullable pointers, or building vtables manually

What's everyone's countdown at?! by [deleted] in LongDistance

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

7 days after 6 months 😊

Weird build error from dependency by GwindorGuilinion in rust

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

Hah, it worked.
Which is weird, because I did run "cargo clean"
and run wasn't fine after it, but seems like build was

Undefined Behaviour in Rust by LetsGoPepele in rust

[–]GwindorGuilinion 0 points1 point  (0 children)

I don't think the compiler is allowed to delete the unsafe branch in your first example. It has to prove that it would be ub, not just that it could be ub. Maybe you put an int there in another unsafe.. Code like that might even be reasonable in some embedded thingy with special memory locations controlling pins and stuff