1
16
submitted 1 day ago by snaggen to c/rust
2
22
Rust Analyzer Changelog #235 (rust-analyzer.github.io)
submitted 3 days ago by snaggen to c/rust
3
34
submitted 4 days ago by snaggen to c/rust
4
15
submitted 4 days ago by secana to c/rust

Hi rustaceans! What are you working on this week? Did you discover something new, you want to share?

5
26
submitted 1 week ago by snaggen to c/rust
6
62
submitted 1 week ago by kato to c/rust

This is my first try at anything open source so any feedback is welcome :)

7
16
Rust Analyzer Changelog #234 (rust-analyzer.github.io)
submitted 1 week ago by snaggen to c/rust
8
23
submitted 1 week ago by secana to c/rust

Hi rustaceans! What are you working on this week? Did you discover something new, you want to share?

9
10
Dart Macros (youtu.be)
submitted 2 weeks ago by FizzyOrange to c/rust

Very impressive IDE integration for Dart macros. Something to aspire to.

10
21
submitted 2 weeks ago by snaggen to c/rust
11
10
submitted 2 weeks ago* (last edited 1 week ago) by ChubakPDP11 to c/rust

VOID WRONG

It seems like I misunderstood some stuff.


Over the years, up until Rust, there were 4 ways to have a 'safe' language:

  • A virtual machine (e.g. most languages today)

whether it's a high-level (scripting languages) one or low-level one (JVM, CLR)

  • What C++ and similar languages do, destructors, compile-time bound checks, make a global heap and shit in it, make a local stack and piss in it, etc (basically my AllocPPx.pl but baked into the language)
  • Bake the VM in with the machine code. That's what D and Go do, and I think Nim does that too. This will make the point of your language being compiled entirely moot imo.
  • Finally, the most 'controversial' decision for imperative-loving chuds: make a functional language. ML/Scheme/CLisp achieve memory safety through closures. Haskell achieves this through Monads. Functional languages have a property which allows them to be be both compiled into machine code and bytecode, and also, interpreted like an scripting language.

The problem with all these approaches is the trade-off between safety and speed. There's another factor, and that is low-level access to the system. Languages like OCaml came close to achieving a balance, and that's why Rust bassed itself on it.

Most imperative languages have 'operational semantics', but not 'denotational semantics'. You can't describe what C does with math. What C does depends on the platform, the CPU, etc.

Rust's safety is achieved by 'flattening out' the memory model of a functional language like Ocaml. OCaml is a language with denotational semantics, because it's a functional language. Rust is an imperative language but it has denotational semantics. At least when comes to memory management.

I am not going to even attempt to describe the denotational semantics of Rust because I am just an amatuer and i don't have a master's in LDT. But if someoen tries, they could.

I think people might have already done it. I am not sure.

If you tell me no, and Rust does not have denotational semantics, I stand by my great-great grandfather's barber's grave that yes, it does!

So why do I say Rust 'flattens out' the functional model for memory management? It does at least with lifetimes. So imagine this: lifetimes are just 'let' bindings, but with a different syntax.

OCaml:

let rec factorial = function
  | 0 -> 1
  | n -> n * factorial (n - 1);;

Scheme

; This uses `let` under the hood
(define (factorial n)
  (if (<= n 1)
      1
      (* n (factorial (- n 1)))))  

So these two in Rust would be:

fn factorial<'a>(n: u32) -> u32 {
    match n {
        0 => 1,
        _ => n * factorial(n - 1),
    }
}

I know 'a is almost useless here, but what I meant was, that 'a makes it similar to the 'let' bindings in the prior to examples!

Semantics here is clear. Right?

But C:

int factorial(int n)  {
   if (n == 0) return 1;
   else return n * factorial(n - 1);
}

We do have operational semantics here, but who's to say what are the denotational semantics? Right? What is a 'function' in C? Well most C compilers translate it to an Assembly subroutine, but what if our target does not support labels, or subroutines?

You see what I am arriving at?

Conclusion

Rust is a semi-functional, semi-imperative language, but the difference between Rust and other languages with functional aspects is: denotional semantics!

Note: A language having lambda closures does not make it 'functional', you can do that in GNU C too ffs! Denotational semantics make it functional.

12
63
submitted 2 weeks ago by ChubakPDP11 to c/rust

I thought this might interest you Rust folk. This is kinda like an LLVM bitcode to JVM bytecode translator. So run rustc with --emit=llvm-ir (I think that's the flag) and then pass the bitcode image to this program, then get JVM bytecode which you can make a JVM bytecode archive (JAR) from it. Could be an interesting? The author says it can JVM code from Clang output, so why not Rustc?

Keep in mind that these are two different beasts, JVM is designed for a safe virtual machine and LLVM is chiefly used to be translated into machine code. However, stupider and more wonderful things have been done with LLVM and JVM, for example, there's an LLVM to 6502 translator, so you could be making NES games with Rust.

I will test this in a few days, busy implementing my own JVM (hope I can do it) and I don't have the Rust toolchain installed on my system. But hey maybe someone can make a Cargo plugin from it (is it possible?)

Thanks, later.

13
63
submitted 2 weeks ago by fzz to c/rust

#rust #rustlang

14
10
submitted 2 weeks ago by BB_C to c/rust
15
21
submitted 2 weeks ago by BB_C to c/rust
16
8
submitted 2 weeks ago by armchair_progamer to c/rust
17
43
submitted 2 weeks ago by snaggen to c/rust
18
22
submitted 2 weeks ago by KillTheMule to c/rust

Hey all!

I've just published a small crate, and would like to take the occasion to not only announce this, but also make typst better known in the rust community, because I think it's awesome :)

What does this do?

It provides a derive macro to derive typst::foundations::IntoValue for a struct.

Why would I want that?

If you're using typst as a library, chances are you want to get data into your documents. Rather than using a templating library or rolling your own, I'd suggest using inputs (I'm still excited being made aware of that!), which implies making a Value out of your data. typst_macros provides the possibility to derive Cast, which includes the treasured IntoValue... for enums. This is a gap somewhat closed by this crate.

So what about this typst?

typst is a typesetting system (akin to LaTeX) written in Rust. The core and cli are licensed freely, and it is very useable up to the point that I personally don't use latex anymore, but have switched to typst. I'm personally ultra-fond of the ability to use typst as a library, which makes it perfect for apps that want to produce high-quality documents from user-provided data.

Any questions, comments, criticism, code reviews welcome! Also, give typst a shot.

19
16
submitted 2 weeks ago by ozkriff to c/rust
20
1
submitted 3 weeks ago* (last edited 3 weeks ago) by fzz to c/rust

I’m working on a big project in #Rust, there is toolset and API for #Playdate.

All going great, moving to stabilization step by step, but so tired of looking at the dull amount ⭐️.

Project repository, mastodon.

21
21
submitted 3 weeks ago by secana to c/rust

Hi rustaceans! What are you working on this week? Did you discover something new, you want to share?

22
16
submitted 3 weeks ago by [email protected] to c/rust
23
21
submitted 3 weeks ago by antoyo to c/rust

We fixed a couple of bugs and improved the support for Aarch64 which was requested by some people.

24
44
submitted 3 weeks ago by Nereuxofficial to c/rust
25
34
submitted 3 weeks ago by notriddle to c/rust
view more: next ›

Rust

5281 readers
22 users here now

Welcome to the Rust community! This is a place to discuss about the Rust programming language.

Wormhole

[email protected]

Credits

  • The icon is a modified version of the official rust logo (changing the colors to a gradient and black background)

founded 11 months ago
MODERATORS