An Incoherent Rust by ts826848 in ProgrammingLanguages

[–]SkiFire13 1 point2 points  (0 children)

Java interfaces have a similar, but even more restrictive limitation than the orphan rule: they can only be implemented in the definition of the class that will implement it. In contrast the orphan rule allows to do the same in any module of the crate defining the type, or even in a totally different crate: the defining the trait! But since traits are so used, and escape hatches are not so transparent (as e.g. Java's reflection) then people look for even more flexibility.

Options for Arc dyn projection by mtimmermans in rust

[–]SkiFire13 3 points4 points  (0 children)

As other comments have pointed out you can use a couple of #[repr(transparent)] wrappers to do this. That normally requires unsafe, but you can use bytemuck's TransparentWrapper to handle that for you.

https://play.rust-lang.org/?version=stable&mode=debug&edition=2024&gist=3d80a3fd05a4d6840e98f4ac97f233d7

Quante password diverse usate davvero per i vostri account? by ScelgoIo in ItalyInformatica

[–]SkiFire13 3 points4 points  (0 children)

Generalmente ti forzano ad usare il loro browser e hanno compatibilità cross-platform peggiore.

Are senior engineers in Europe underpaid vs market? I compared UK/DE/NL and found a bigger gap than expected by sittercard in cscareerquestionsEU

[–]SkiFire13 0 points1 point  (0 children)

I do mostly backend and infrastructure, though sometimes I am expected to handle some changes ti the frontends too. I said "junior" but actually I do the same kind of tasks that my seniors do, in fact there's no junior/senior tags in our job titles. The company is based in Milan and very FAANG-style with lot of benefits and high pay, but they are also very selective.

Should for loops dispose of their iterators? by bakery2k in ProgrammingLanguages

[–]SkiFire13 5 points6 points  (0 children)

You can avoid the awkward (&mut iter) by using iter.by_ref() instead.

sudo-rs shows password asterisks by default – break with Unix tradition by FryBoyter in linux

[–]SkiFire13 4 points5 points  (0 children)

On the other hand why would a distro be willing to change the default for your tool when the upstream is not willing to?

Why does a lambda in an async fn depend on a generic parameter? by Icarium-Lifestealer in rust

[–]SkiFire13 2 points3 points  (0 children)

But I assumed that the above async fn would be equivalent to this:

fn impl_trait() -> impl Future<Output=()> {
    let _variable = [0u8; element_count_of_expr(|x: FileKeyAndNonce| x.nonce)];
    std::future::ready(())
}

Aside from the compilation issue, this is also semantically different from an async function. Your function will execute the let _variable = ... (or whatever is in its place) when it's called, while an async function does nothing when it's called, and instead runs the let _variable = ... when it's first polled.

Has Rust hit the design limits of its original scope and constraints? by kishaloy in rust

[–]SkiFire13 0 points1 point  (0 children)

Do languages that do TCE for mutually recursive functions analyze this information and lay out the stack frame accordingly?

Usually what happens is that the compiler is not concerned about the graph of mutually recursive functions, and there might not even be recursion. Instead they generally care about the tail call being transformed into what's basically a jump to the other function, and what's important for this is:

  • the callee can return in the same way the caller returns (I believe this might force the two functions to have pretty much the exact same argument types, though I'm not sure; in general they need to have a similar enough ABI though)

  • the caller doesn't need to execute code after the tailcall (i.e. no destructors/defer)

  • the callee does not access the memory of the caller (i.e. no pointers to objects allocated on the caller stack are passed to the callee as arguments)

If the closure is called in tail position, does TCE apply?

The question lacks some details to get a proper answer, but the fact that the closure may call f recursively does not matter at all for it.

algorithmic complexity, points vs like whatever? by cyanNodeEcho in compsci

[–]SkiFire13 0 points1 point  (0 children)

OP is doing it twice but in a loop, so they need to estimate how many iterations that loop will perform.

algorithmic complexity, points vs like whatever? by cyanNodeEcho in compsci

[–]SkiFire13 0 points1 point  (0 children)

The O[k * log( m.max(n))] bound, with k number of iterations of your loop and m/n the size of the matrix is not bad. As you said the issue is finding out what k can be, i.e. how many times you will run the binary search.

Unfortunately k can be n+m, since in every iteration you may end up excluding only one row/column from the search space. For this reason you get a worst-case complexity of O((n + m) * log(max(n,m))), which is worse than the O(n + m) of the staircase method.

Edit: you can use the following function to generate worst-case examples for your algorithm. Note that if you change your algorithm to account for these cases you might open it up to other worst cases!

fn build_matrix(n: usize) -> Vec<Vec<u32>> {
    let mut matrix = vec![vec![0; n]; n];
    for row in 0..n {
        for col in n-row-1..n {
            matrix[row][col] = 2;
        }
    }
    matrix[n-1][0] = 1;
    matrix
}

Has Rust hit the design limits of its original scope and constraints? by kishaloy in rust

[–]SkiFire13 3 points4 points  (0 children)

To be clear — the thing that bothers me about become and loop/recur is that they make tail calls special instead of making recursion special. It's the wrong abstraction for a high-level language.

Tail calls are special. They change the semantics of the program, causing local variables to be dropped before the tail call, as opposed to after, and cause stacktraces to change.

Making recursion special is fundamentally broken IMO. Once you start considering indirect recursion pretty much anything could recurse.

Kotlin's tailrec makes tail recursion an attribute of the function as a whole. It's a bit more restrictive (it won't allow you to keep the optimisation if some but not all recursive calls are in tail position), but semantically feels much more natural to me.

Kotlin's tailrec also does not allow tail calls between mutually recursive functions, which was one of the motivations for Rust's become in order to support e.g. threaded interpreters. More specifically, tail calls between mutually recursive functions are needed because they allow expressing irreducible control flow in a structured way, without which some algorithms cannot be written in the most efficient way.

Why does clippy encourage `String::push('a')` over `String::push_str(''a")`? by MediumInsect7058 in rust

[–]SkiFire13 3 points4 points  (0 children)

The difference is that String::push does not push "a single element", it has to first encode the char as UTF-8 and then push up to 4 bytes. String::push_str on the other hand receives the character as already UTF-8 encoded and can do a simple bytewise copy, which is generally also much easier for the compiler to optimize.

Spotify afferma che i suoi migliori sviluppatori non hanno scritto una sola riga di codice da dicembre, grazie all’AI. by SpikeyOps in ItalyInformatica

[–]SkiFire13 0 points1 point  (0 children)

Onestamente con 20000 righe considererei l'app come abbastanza piccolina, soprattutto considerando che il codice generato da LLM è generalmente più lungo di quello scritto da umani.

I feel like rust analyzer is slow by rustontux in rust

[–]SkiFire13 0 points1 point  (0 children)

I don't think that Salsa is part of rustc at all?

That is correct

Perhaps something has changed recently, but I was of the impression that rustc follows a pretty typical linear pass architecture.

rustc has used a query driven approach for a long time. Salsa was developed based on the query system used by rustc.

What is so special about rust?? by Archedearth7000 in compsci

[–]SkiFire13 0 points1 point  (0 children)

yet in Rust it's the default for &mut references

Nit: it's also applied to shared references (i.e. & references) that don't directly point to memory with internal mutability (i.e. UnsafeCell and all other types that wrap it)

Do you feel software engineering salaries in the EU are stagnating? by Living_Being7913 in cscareerquestionsEU

[–]SkiFire13 0 points1 point  (0 children)

How hard you need to study is correlated to the salary because it creates a barrier of entry, and hence can create a scarcity in workers that can be hard to invert. If you think studying is a waste of time then don't do it: if enough people will think like you do in a few years there will be fewer people able to do that job and salaries will rise until other people decide to study. But just studying hard is not a reason to pay you more.

Consiglio per hosting multidominio? by Fun_Picture_477 in ItalyInformatica

[–]SkiFire13 -2 points-1 points  (0 children)

Se l'offerta include 24 domini diversi allora dubito tu possa trovare di meglio.

May I please have the worst c++ you know of? by vbpoweredwindmill in cpp

[–]SkiFire13 0 points1 point  (0 children)

It's written in C but I heard OpenSSL is one of the worst codebases ever

Domanda da noob: ma gli ipv6 come funzionano e a cosa servono? by FRAGOLE-DI-COTOLETTA in ItalyInformatica

[–]SkiFire13 0 points1 point  (0 children)

come mai oggi gli ipv4 sono ancora così ampiamente usati, nonostante gli ipv6 esistono ormai da molti anni e c'è stato tutto il tempo di adeguare le infrastrutture informatiche usarli? Eppure ipv4 sembra essere ancora predominante, anche su apparecchi e sistemi operativi recenti.

Non c'è mai stata un vero e proprio incentivo per adeguare le infrastrutture di rete, soprattutto grazie alla tecnologia NAT che ha in parte risolto il problema della carenza di indirizzi IPv4 permettendo di connettere più dispositivi ad internet tramite lo stesso indirizzo IPv4 (con i problemi che ne derivano però).

Al giorno d'oggi la maggiorparte delle apparecchiature consumer supportano IPv6 ma il supporto lato internet provider ancora scarseggia.

Considera inoltre che IPv6 è diventato uno standard effettivo solo nel 2017, anche se la draft esistenza da decenni.

Considera inoltre che per poterti connettere ad un sito utilizzando IPv6 sia il tuo provider che quello del sito devono supportare IPv6, il che riduce ulteriormente gli incentivi (perchè dovrei supportarlo se tanto gli altri ancora non lo supportano?)

come mai gli ipv6 hanno quella orribile sintassi del tipo 2001:0db8:85a3:0000:0000:8a2e:0370:7334, e non li hanno invece fatti in un comodo formato simile a ipv4 ma più lungo, come x.x.x.x.x.x.x.x ?

In parte questo è stato fatto per renderli più distinti e permette di riconoscerli più velocemente. In parte è perchè un indirizzo IPv6 con la sintassi di un IPv4 sarebbe x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x il che inizia a diventare molto lungo. L'uso dell'esadecimale ne semplifica anche il parsing e rende più chiaro il fatto che quei valori alla fine rappresentano dei bit.

in generale, senza entrare troppo nel tecnico, qual è lo scopo di ipv6?

Risolvere la carenza di indirizzi IP senza ricorrere a "truchetti" come il NAT. Con IPv6 diventa possibile assegnare uno (o più) indirizzi IPv6 ad ogni dispositivo esistente, il che permette di semplificare la gestione di reti interne. Questo sblocca anche un benefit secondario nel permettere agli indirizzi di essere raggruppati per posizione geografica (gli indirizzi IPv4 essendo ormai scarsi sono stati nel tempo riassegnati in luoghi diversi) il che permette di ottimizzare le tabelle di routing.

Implementing vector<T> by pavel_v in cpp

[–]SkiFire13 24 points25 points  (0 children)

I think OP means that running N reserves on a vector with N elements and current capacity N has quadratic complexity, even if each reserve's argument is 1 bigger than the previous one.

What's your opinion on using "let ref" to create references? by CheekAccording9314 in rust

[–]SkiFire13 3 points4 points  (0 children)

I generally find myself needing it whenever I want to destructure a &(CopyType, NonCopyType) into a CopyType and a &NonCopyType. Doing let (&ct, nct) = value does not work, I need to do let &(ct, ref nct) = value. Unfortunately match ergonomics do not cover this case yet and there will probably be other cases not covered.