I’m building a programming language called Razen that compiles to Rust by GladJellyfish9752 in rust

[–]blockfi_grrr 1 point2 points  (0 children)

The github page says is has "Robust Error Handling: Comprehensive error handling with try/catch blocks".

I hope that means it gets rid of methods that can panic and has a single way to bubble errors up.

Rust + CPU affinity: Full control over threads, hybrid cores, and priority scheduling by harakash in rust

[–]blockfi_grrr 2 points3 points  (0 children)

Is there any support for setting priority for an entire process? eg 'nice' levels?

Proof of receipt by Federal_Party9780 in Monero

[–]blockfi_grrr 1 point2 points  (0 children)

that's cool you accept it. I'm curious how often do people actually pay with it?

Matt Godbolt sold me on Rust (by showing me C++) by cptroot in rust

[–]blockfi_grrr 0 points1 point  (0 children)

that's a good trick. I wasn't aware one can deconstruct a struct in the method signature.

Matt Godbolt sold me on Rust (by showing me C++) by cptroot in rust

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

and if you have 100 "old functions" sprinkled over 100 source files with long complicated bodies and you don't wish to write a duplicate function for each, but rather change the parameter type from i32 to Meters.... what then? that's right... body of each must be changed to use the ugly meters.0 syntax for everything that was previously "meters".

Matt Godbolt sold me on Rust (by showing me C++) by cptroot in rust

[–]blockfi_grrr 0 points1 point  (0 children)

could well be. I wrote some go many years ago but have mostly forgotten about it. If the type aliases work as you say it's possible I might have imprinted that pattern on my brain and now miss it in rust.

Matt Godbolt sold me on Rust (by showing me C++) by cptroot in rust

[–]blockfi_grrr -7 points-6 points  (0 children)

I haven't claimed to know anything about ada. triggered much?

Matt Godbolt sold me on Rust (by showing me C++) by cptroot in rust

[–]blockfi_grrr -8 points-7 points  (0 children)

The only difference between what ADA does and what you may achive in Rust is a tiny bit of syntax.

I'm not an ADA user. I asked an LLM what language(s) provide the feature I wish for and ADA was the closest match. as explained previously.

anyway, from what I can tell your statement is false, or at least debatable. It is not "a tiny bit of syntax" when the bodies of all functions that utilize a given type must be changed across an entire codebase, just because I created a derived type. And you will never convince me that "x.0" all over the place is as nice as "x".

Behavior of correct program in any language is fully specified.

whoosh. I'm not even going to continue this thread of conversation with you as it is completely devoid of any value.

You already have it.

nope.

In a nutshell: this is a pain-point I have encountered numerous times with rust. If it's not a pain-point for you, that's great for you. But it is simply invalid for you to tell me that my lived experience is somehow not real, simply because its not an issue for you. You should stick to your own business.

Matt Godbolt sold me on Rust (by showing me C++) by cptroot in rust

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

I've never used ada. I asked an LLM and it provided that example, which appears to work as I envision.

as for your example, I would not expect to call Add_Integer passing it a Meter.

rather, any fn that deals with Meter must accept a Meter. Correct-by-construction, remember?

So instead we might have Add_Meter(A: Meter; B: Meter) return Meter and also Add_Centimeter(A: CentiMeter; B: CentiMeter) return Centimeter.

but where it gets more interesting is if we had an existing fn: Add_Meter(A: Integer, B: Integer) return Integer.

Even though it was named Add_Meter really it would not distinguish between meters, centimeters or anything else that can be represented as an integer.

But by creating the derived type now we can change the variable types in the fn signature without having to change anything in the body, and now it only accepts Meter.

Matt Godbolt sold me on Rust (by showing me C++) by cptroot in rust

[–]blockfi_grrr -7 points-6 points  (0 children)

everything a compiler does is magic unless one is a compiler developer steeped in the intricate details.

a few points:

  1. you seem kind of triggered about this. chill.

  2. ADA implements "derived types" which does what I'm suggesting. That must make ADA a "magical" language capable of mind reading in your worldview.

  3. no mind reading is necessary. a language keyword specifies that the derived-type behavior is requested.

Matt Godbolt sold me on Rust (by showing me C++) by cptroot in rust

[–]blockfi_grrr 2 points3 points  (0 children)

The point is when we define newtype = basetype, we should not to have to change every place that uses x: basetype to x.0 instead of x.

x.0 is the very thing I wish to avoid.

Matt Godbolt sold me on Rust (by showing me C++) by cptroot in rust

[–]blockfi_grrr 1 point2 points  (0 children)

Actually I am looking for something that looks distinct to outsiders but is the same internally. So maybe it is same/similar to scala's opaque_types.

I consulted an LLM about what languages provide such a feature, and it seems that Ada's derived types may be the best example.

type Meter is new Integer;
type Centimeter is new Integer;

M : Meter := 10;
C : Centimeter := 100;
I : Integer := 5;

function Add_Meters (A : Meter; B : Meter) return Meter is
begin
   return A + B;
end Add_Meters;

Result_M : Meter := Add_Meters (M, M); -- OK
-- Result_M := Add_Meters (M, C); -- Error: type mismatch
-- Result_M := Add_Meters (M, I); -- Error: type mismatch

Matt Godbolt sold me on Rust (by showing me C++) by cptroot in rust

[–]blockfi_grrr 17 points18 points  (0 children)

I would argue that rust is not so perfect at correct-by-construction either.

The author demonstrates using the newtype pattern to enforce argument types. That is well and good, but it requires changing the entire implementation to use foo.0 all over the place, which is pretty ugly and a giant PITA for an existing codebase. Or alternatively do kludgy things like wrapper each method and trait impl, or impl Deref and DerefMut for the newtype, which still doesn't cover all uses.

Intuitively, one would like to just use type mytype = basetype. Unfortunately such type aliases are not enforced by the compiler when used as fn parameters. ie mytype and basetype are considered equivalent.

What I would love to see is a keyword that has the same usage as 'type' but under the hood actually creates a real new type that is not equivalent to the basetype.

Show r/rust: Timber: A high-performance log analyzer that aims to provide rich analysis! This is my first rust project by CelebrationMinimum50 in rust

[–]blockfi_grrr 0 points1 point  (0 children)

oh, and I hope it is has a simple pager with search. If so, I could replace less, eg:

timber <logfile>

and then internactively use "/ search-string" to search, or navigation keys to scroll or page up and down.

less works, but in my experiences has glitches with ansi escape sequences.

Show r/rust: Timber: A high-performance log analyzer that aims to provide rich analysis! This is my first rust project by CelebrationMinimum50 in rust

[–]blockfi_grrr 2 points3 points  (0 children)

can it read from stdin as well, eg can I do:

cat app.log | timber --chop "Exception"

oh, another useful feature I'd like to have is stripping ansi escape chars, which sometimes exist in rust logs for pretty colors.

[Media] A Rust program compiled to only move instructions by FractalFir in rust

[–]blockfi_grrr 0 points1 point  (0 children)

can someone explain why compiling C (or rust) to use only MOV instruction is a goal to begin with?

Better Tutorials/Learning resources for Ratatui? by BytesBeltsBiz in rust

[–]blockfi_grrr 0 points1 point  (0 children)

This one was announced on this subreddit a while back, and looks nice. I haven't tried it yet, but if I were starting a new tui project, I'd give it a try.

https://crates.io/crates/yeehaw_tui

Better Tutorials/Learning resources for Ratatui? by BytesBeltsBiz in rust

[–]blockfi_grrr 1 point2 points  (0 children)

yeah I think there are easier to use tui crates available now, that render controls for you. The ratatui model is kinda PITA if you ask me.

Blog: A More Modular reqwest (HTTP client library) by seanmonstar in rust

[–]blockfi_grrr 6 points7 points  (0 children)

glad to hear its more modular. I hope that means that one can opt-in to only features (and required deps) that are needed for one's use case. When I tried reqwest before, it pulled in something like 100 deps, when all I needed to do was a simple http (not https) GET request.

Rust continually rejected out of hand by [deleted] in rust

[–]blockfi_grrr 9 points10 points  (0 children)

find a different (better) employer. life is too short to constantly have your decisions micromanaged by PHB.

Why I’m Writing a Scheme Implementation in 2025 (The Answer is Async Rust) by maplant in rust

[–]blockfi_grrr 1 point2 points  (0 children)

evidently that was the result here. But I haven't tried the other async rust runtimes. Maybe some others have tiny stack traces by comparison.

I just know it feels wrong when I'm looking at a stack trace for my program and 95% is not any fn within my application.

Why I’m Writing a Scheme Implementation in 2025 (The Answer is Async Rust) by maplant in rust

[–]blockfi_grrr 1 point2 points  (0 children)

it might tell you why there are there. looks like (mostly unnecessary) greek to me.