1
12
submitted 1 day ago by ChubakPDP11 to c/rust

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.

2
55
submitted 1 day 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.

3
57
submitted 1 day ago by fzz to c/rust

#rust #rustlang

4
21
submitted 2 days ago by BB_C to c/rust
5
11
submitted 2 days ago by BB_C to c/rust
6
40
submitted 4 days ago by snaggen to c/rust
7
21
submitted 4 days 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.

8
15
submitted 4 days ago by ozkriff to c/rust
9
8
submitted 4 days ago by armchair_progamer to c/rust
10
1
submitted 1 week ago* (last edited 1 week 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.

11
21
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?

12
16
submitted 1 week ago by [email protected] to c/rust
13
19
submitted 1 week ago by antoyo to c/rust

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

14
46
submitted 1 week ago by Nereuxofficial to c/rust
15
33
submitted 1 week ago by notriddle to c/rust
16
55
submitted 1 week ago by [email protected] to c/rust
17
25
submitted 1 week ago by yoavlavi to c/rust
18
24
Websurfx 1.15.0 release (programming.dev)
submitted 2 weeks ago by neon_arch to c/rust

Hello again!!

Sorry for the big delay in the announcements. I know it has been a long time I have not made any announcements, but I will try my best next time this doesn't happen again.

So, through the medium of this post I would like to share with you all the v1.15.0 major release version of the websurfx project which was released on the 25th of March.

If you are new, and you don't know what is websurfx then I would suggest taking a look at my previous post here:

https://programming.dev/post/2678496

Which covers in depth about what the project is and why it exists.

Credits

Before I share with you the changelog, what this release version means and a preview on what we are planning to work on for the next major release v2.0.0. I would first like to thank all our contributors and maintainers because of whom this was all possible. Specially I would like to thank spencerjibz, ddotthomas and evanyang1 who have been invaluable to the project. Also, Websurfx would not have been possible without alamin655 and xffxff early involvement.

Thanks 💖 to all the people involved in the project

Now, let's dive straight into what this release version actually means.

What does this release version means

This new release version v1.15.0 introduces the new ranking algorithm for search results on the search page which ranks the results based on the relevancy to the user's search query.

Changelog

The changelog of all the changes can be found here:

https://github.com/neon-mmd/websurfx/releases/tag/v1.15.0

Preview of the goals for the next major release

  • Different levels of privacy to choose from with the help of rust's conditional compiling features (In progress).
  • Even more engines will be supported.
  • Categories would be added to search results like images, news, etc.
  • More themes will be provided by default
  • More animations for the websurfx frontend will be supported.
  • Multi language support would be added.
  • I2p and tor support will be provided.
  • Reduce animations would be added for those who don't want animations and effects on the frontend.
  • And lots more ✨.
19
10
submitted 2 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?

20
29
submitted 2 weeks ago by [email protected] to c/rust

efs is a recently published no-std library which provides an OS and architecture independent implementation of some UNIX filesystems in Rust.

Currently only the ext2 filesystem is directly implemented, but I will soonly work on other filesystems!

It's still young so it may contain bugs, but it's hugely tested so that it does not happen.

Some of the features provided :

  • no_std support (enabled by default)

  • General interface for UNIX files and filesystems

  • read/write regular files

  • retrieve, add and remove directory entries directly from a path and a current working directory.

I hope you will find this useful! If you have any remark, idea or issue, do not hesitate to ask here or to submit an issue!

21
16
submitted 2 weeks ago by Ogeon to c/rust

The maintainer here! Feel free to ask questions. I know especially CAM16 can feel a bit abstract if you aren't in the loop, but I will try to answer what I can. I have tried my best to explain the concepts in the docs, but it can always be better.

22
106
submitted 2 weeks ago* (last edited 2 weeks ago) by [email protected] to c/rust

This was a really good summary of what Rust feels like in my opinion. I'm still a beginner myself but I recognize what this article is saying very much.

The hacker news comments are as usual very good too:

https://news.ycombinator.com/item?id=40172033

23
39
submitted 2 weeks ago by [email protected] to c/rust
24
49
submitted 3 weeks ago by snaggen to c/rust
25
16
submitted 3 weeks ago by kdwarn to c/rust

Docs.rs is great, but if you want to host yourself it's pretty easy.

view more: next ›

Rust

5251 readers
97 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