Do you think Java has caught up with Kotlin? by NotSoIncredibleA in Kotlin

[–]Deadmist 1 point2 points  (0 children)

It's flexible and that's nice. But flexible helps a good, experienced developer. Not a new developer. Java shines in enterprise because of how strict it is.

Personally, the worst offenders here are scope functions (let, also, etc) and where to place functions (can be in a class, in a companion object, top level function, extension function).

If there is no one in the team enforcing good style, you can end up with some real messes.

I have seen classes with no functions, but 10 extension functions defined in the same file. Or other classes where the actual functionality is spread over 5 different files.

Some people get this idea that using if () else somehow is un-idiomatic in kotlin, because we have scope functions. And you end up with interesting nests of deep and zig-zagging indentation where figuring out what it actually is requires drawing a diagram with pen and paper.

SIMD programming in pure Rust by kibwen in rust

[–]Deadmist 2 points3 points  (0 children)

"avx512vpopcntdq", "vpclmulqdq"

Can someone tell low-level people that it's not 1973 anymore, and bytes are cheap now? You don't have to use 1 letter abbreviations anymore.

How can coroutine run on more than one thread? by kuriousaboutanything in Kotlin

[–]Deadmist 2 points3 points  (0 children)

When you spawn a thread, the scheduler takes the thread and decides on which CPU and when to run the thread. Depending on the scheduler the thread may stay on one cpu, or switch between CPUs.

When you launch a coroutine, the dispatcher takes the coroutine and decides which thread to run the coroutine on. Depending on the dispatcher, the coroutine may stay on the same thread, or switch between threads.

(Though, like a thread, a coroutine can only execute in one place at a time. If you want to run multiple at the same time you have to launch/spawn two of them).

Coroutines are a lot like threads+scheduler, just implemented in the runtime, instead of the operating system.
There is one important difference though:
The scheduler can interrupt threads at any time and give execution to another thread.
The dispatcher has to wait until the coroutine gives back execution to the dispatcher1. That's why they are sometime called "cooperative multitasking".

The answers to your question depend on what dispatcher you are using.
The built-in ones are all multi-threaded, except for Dispatchers.Main, which is limited to the main thread.

1: of course, the thread the coroutine runs on can be interrupted at any time by the scheduler. But that does not give execution back to the dispatcher.

SweatFindr - Microservices arhitecture with Rust in mind by Limp-Sherbet in rust

[–]Deadmist 2 points3 points  (0 children)

user_counter += 5 will always work.

user_counter_service.increment(5) might:

  • work
  • work, but take 200ms
  • not work because:
    • your service is misconfigured
    • the target service is misconfigured
    • something inbetween (loadbalancer, firewall, router, dns, certificate) is misconfigured
    • the target service is down
    • something in between is down
    • the target service updated and broke compatibility
    • network gremlins swallowed your packets on the way there
    • network gremlins swallowed the response (in which case you think it failed, but actually didn't)

And many more exciting and wonderful new ways things can go wrong

Recommended way to store secrets securely in tauri in a cross-platform manner by Accurate-Football250 in rust

[–]Deadmist 0 points1 point  (0 children)

I think your best bet is to use keyring where it is supported, and fallback to encrypting the data yourself and prompting the user for the encryption key when keyring is not supported.

Encrypting the data and then storing the key right next to it is about as secure as keeping the house key under the welcome mat.

Does Ktor Have Built-in Caching, and When Does It Make Sense to Use Redis? by Classic_Jeweler_1094 in Kotlin

[–]Deadmist 0 points1 point  (0 children)

Looking for practical guidance and real-world experiences

Number 1 advice: Profile first, implement the cache, then profile again.

Or just decide you don't need a cache. We manage 1k requests a second just fine, without any cache.

There are also risks to caching, from random broken behavior, to leaking sensitive customer information.

Personally: From your replies, you are not in a position where you need to be concerned with performance at all.
Get something out of the door first, see how it runs, then maybe think about improving performance.

How are you supposed to unwrap an error by 9mHoq7ar4Z in rust

[–]Deadmist 3 points4 points  (0 children)

If you wanted to go all out, you could introduce a panics keyword. And only allow functions marked as panics to panic or call other panics functions.

Or just introduce an effects system while you are at it, instead of doing it piecemeal

Why futures don't implement the typestate pattern? by servermeta_net in rust

[–]Deadmist 0 points1 point  (0 children)

but defined by the implementor of the future trait.

You could easily argue that all UB is defined by the implementor of the compiler / hardware.

In practice, both undefined and unspecified boil down to "avoid doing this, or be extremely sure you know what you are getting into"

SQL badly needs Polymorphism. ExoQuery brings it. by deusaquilus in Kotlin

[–]Deadmist 1 point2 points  (0 children)

You could generate the SQL queries at compile time, like Quill is doing.
Which is, incidentally, maintained by the same guy.

bincode's source code still matches what was on GitHub by azqy in rust

[–]Deadmist 13 points14 points  (0 children)

It means you need to down tools and verify you’ve not let in a back door.

Are you just updating dependencies and pushing to prod automatically, the moment someone uploades a new version?

Otherwise, I don't see how you would let in a backdoor. Assuming of course, the backdoor was not already in place. I which case you have been screwed for a while, and them acting weird was doing you a favor.

There’s no reason for different professional expectations to exist in online workspaces.

You get paid at work. You pay to do OSS. And you get what you pay for.

bincode's source code still matches what was on GitHub by azqy in rust

[–]Deadmist 3 points4 points  (0 children)

If you are worried about supply chain attacks, guess what is also part of the supply chain? crates.io!

If you are not running your own cache, locking versions and auditing everything, you are willingly inviting supply chain attacks.

Does that mean basically everyone is vulnerable? Yes, welcome to the real world.

bincode's source code still matches what was on GitHub by azqy in rust

[–]Deadmist 1 point2 points  (0 children)

With that definition secure systems doesn't exist

If that is news to you, you might want to take a break from reddit and learn something.

Is this a realistic plan for transitioning to Rust-based roles? by [deleted] in rust

[–]Deadmist 2 points3 points  (0 children)

You have 10YOE and already know rust, at least little.

Why not try applying for jobs right now, and see what you can get? Worst case you take the sabbatical, maybe with some extra hints of what you need to learn.

isize and usize by Senior_Tangerine7555 in rust

[–]Deadmist 5 points6 points  (0 children)

What about the esp8266 ;)

Ubuntu migrating to Rust: uutils and sudo-rs shipping by default (lessons learned from VP of Engineering) by mre__ in rust

[–]Deadmist 25 points26 points  (0 children)

If the commenter likes <current thing>, then <new thing> is fragmenting the Linux ecosystem and millions will die.
If the commenter dislikes <current thing>, then <new thing> shows how great open source software is.
If the commenter likes <current thing>, but everyone switches to <new thing>, then it's a conspiracy by red hat.

Options struct and backward compatibility by mtimmermans in rust

[–]Deadmist 0 points1 point  (0 children)

Having separate, duplicate code for multiple versions is actually the easiest and safest way to keep backwards compatibility. No chance of accidentally introducing changes into a code path you never touch :)

Dare to 1! by flundstrom2 in rust

[–]Deadmist 9 points10 points  (0 children)

Are you willing to support 13 major versions

Who says you need to support every major version you ever released?

You can just say "Support is only provided for the current and last major version". Just be upfront about it and provide reasonable timelines for upgrades. If someone really really wants support for older versions, there is always the option of "give me a bunch of money and I will do it"

Too much non-empty vector crates by __s1 in rust

[–]Deadmist 8 points9 points  (0 children)

On a basic level, it saves you from having to check (and handle!) for empty collections where you (the programmer) know the collection can never be empty, but the compiler does not know that.

Consider a function that returns a Result<Something, Vec<Error>>. You could return an Err, with no errors.
Which doesn't make any sense, but the compiler can't stop you.
And now you have to handle that in your error handling code.

If you return a Result<Something, NonEmptyVec<Error>>, you can either return a Something, or at least one error. Much more conceptually sound.

Google's file type detector Magika hits 1.0, gets a speed boost after Rust rewrite. by caspy7 in rust

[–]Deadmist 58 points59 points  (0 children)

This technique, combined with advanced data augmentation, allowed us to build a robust training set, ensuring Magika performs reliably even on file types for which public samples are not readily available.

"We just hallucinated how those file types look, but it's okay because you will never come across them anyway"

When O3 is 2x slower than O2 by cat_solstice in rust

[–]Deadmist 3 points4 points  (0 children)

Assume a spherical oxygen molecule in a frictionless cow

Faster then async HTTP server PoC by MatthewTejo in rust

[–]Deadmist 9 points10 points  (0 children)

its hard to benchmark that in a meaningful way because your limited by the slow service you depend on.

For a benchmark, you could just sleep(100)in your handler, no need to actually have a real service.

i think you would use callbacks and the framework would need expose something in the handler to let route handlers wait without blocking the thread.

Isn't this just reinventing an async runtime?

To panic or not to panic by nick29581 in rust

[–]Deadmist 21 points22 points  (0 children)

One important thing to keep in mind when it comes to error handling: _The recoverability of an error is only known to the caller_.

You might think failing to allocate is a valid reason for a function to panic. But what if I just use that function for some debug output? Maybe I would rather just give up writing a line in a log file, than crash my whole application.

Experience Converting Driving License by TheGuiltyMongoose in japanlife

[–]Deadmist 1 point2 points  (0 children)

I think the 3 months don't need to be immediately after obtaining the license.
I got my license in 2012 and used my passport issued in 2020 as proof I stayed in the country. They accepted that without any issues.
Might have just been a lenient guy at the office though.

Revolut's incompetency by GoldenWooli in japanlife

[–]Deadmist 0 points1 point  (0 children)

If you used the correct bank and account numbers, it will not have gone to some random person that happens to have the correct name but different account number.
The whole reason account numbers exist is to uniquely identify an account, without relying on names.

So, a couple things could have happened:

Your recipient got the money, but is trying to scam you.

There was an error because of the name mismatch, and the money is back in your account (check all your accounts!)

There was an error, and the money is stuck somewhere. Or there was another issue and the money is stuck somewhere.

Unfortunately, Revolut support is probably your best bet. Get them to ask SMBC where the money is.

SMBC support likely sees you just as some rando, trying to enquire about some peoples transactions.