Yep! That was my inspiration. I'd love to be able to do this in Rust. Soon, hopefully!
Will the Rust compiler ever understand numbers in types? I.e. will the numbers ever be more than just part of the string that is the type name? If not, then I don't know how possible powers will be. Maybe the solution…
Great question. I believe each unit struct would need to implement PartialEq or something similar. That would define the canonical nesting order. Alphabetical would make sense. We would to resolve the nesting during…
Lately I've been playing around with static dimensional analysis in Rust. The overall idea is similar: Use PhantomData to add a type parameter and define an empty struct for each unit. So you might end up with, say,…
> Hasn't every template language in the world has come to a similar conclusion? No, not even every mainstream template language. For example, I still use ERB and EJS extensively, and so do many other engineers. ERB and…
> This isn't security through obscurity I don't necessarily disagree. But how, other than through obscurity, does HTML5 DRM inhibit copying, given that the client possesses the decryption key? (Let's assume the would-be…
> Or does it truly rely on blackbox obfuscation? The client ultimately has to decrypt the data somehow. So the key is there on the client. I take it obfuscation is the only thing standing between the user and that key.…
Thanks so much for working on the grammar docs! This is much needed and very helpful, considering how quickly Rust's grammar has been evolving.
Ah, my mistake. So would I be correct in saying that a trait is a type, but it does not necessarily implement the Sized trait, and if it does not, then it cannot be allocated directly on the stack? Also, I've been…
Rust has algebraic data types. They're one of Rust's most important features. But algebraic data types do not in themselves provide a way to express the notion of a type with variants or sub-types.
I'm hoping the next post will talk about this use case: Suppose I have an enum called "Canine" and I want each of its variants to implement a different "bark" method. Currently, as far as I know, I have to write a match…
> I guess it just seems overly ambitious to me.. finding the right abstraction for the server is difficult enough without polluting it with the front-end. Certainly. That's why I'm skeptical that this will ever happen.…
> The examples you give don't seem to be typing problems, they seem to be wrong-value problems. They're like type or name errors because the "apple" and "orange" here are like identifiers, not data. Sure, to the…
Strong typing on the web has been an intractable problem for me so far. Sure, I can have strong typing in my server-side code. But so many errors result from the interaction between the server, CSS, HTML, and JS. For…
True, but the parent commenter is getting at something important. The article suggests that researchers have found a new, much more concise way to express the solutions to difficult problems. That's different from a…
Good to know. Thanks! So I guess the moral is, if you have a big, expensive struct, make sure the expensive part is in a sub-structure you know is heap allocated, such as a Vec. E.g.: struct Expensive { cheap_value:…
Oh, agreed. But how about this: let x = BigExpensiveStruct::new(); some_function(x); That won't trigger a big, expensive memcpy of the BigExpensiveStruct, will it? I'd thought that its memory was on the heap.
Yes, I had understood the struct's memory to be on the heap. My thinking was, keeping the memory on the heap allows for inexpensive moves. Whereas, the pointer to the heap space may indeed be on the stack, as far as I…
> Semantically speaking, the only difference between a move and a copy is that you're allowed to use a copy type afterwards Are you speaking about Rust specifically, or move in general? I had always understood that move…
> It seems to me like the value would be memcpyed, when you pass by value. As far as I know, the compiler should not copy in that instance. Rather, it should move. > There is not one unit of memory that is "taken over,"…
The author mentions that Rust's "Box type is an owning type" and compares Box to C++'s std::unique_ptr. Worth noting: Rust's most basic variable syntax provides unique_ptr-like behavior, so you usually don't need the…
The relative impact of your money vs your time depends in part on your income, you skill-set, and the causes you would choose. A person with a high income but few relevant skills would probably have the greatest impact…
I've always been uneasy about the fact that Stack Overflow users can edit each other's posts more or less arbitrarily. User A can edit user B's post to say something embarrassing, and most readers will attribute it to…
Even though 1.0 isn't out yet, today you can use Rust for many real projects. I'm unsure whether I'd bet my business on it yet, but I'd be open to the idea. And I'm usually a very late adopter. I've been building a 3d…
The article suggests that solar panels could be an "existential threat" to power companies. For those of you who are familiar with the math of solar panels, how realistic is that prediction? How much of a normal home's…
Yep! That was my inspiration. I'd love to be able to do this in Rust. Soon, hopefully!
Will the Rust compiler ever understand numbers in types? I.e. will the numbers ever be more than just part of the string that is the type name? If not, then I don't know how possible powers will be. Maybe the solution…
Great question. I believe each unit struct would need to implement PartialEq or something similar. That would define the canonical nesting order. Alphabetical would make sense. We would to resolve the nesting during…
Lately I've been playing around with static dimensional analysis in Rust. The overall idea is similar: Use PhantomData to add a type parameter and define an empty struct for each unit. So you might end up with, say,…
> Hasn't every template language in the world has come to a similar conclusion? No, not even every mainstream template language. For example, I still use ERB and EJS extensively, and so do many other engineers. ERB and…
> This isn't security through obscurity I don't necessarily disagree. But how, other than through obscurity, does HTML5 DRM inhibit copying, given that the client possesses the decryption key? (Let's assume the would-be…
> Or does it truly rely on blackbox obfuscation? The client ultimately has to decrypt the data somehow. So the key is there on the client. I take it obfuscation is the only thing standing between the user and that key.…
Thanks so much for working on the grammar docs! This is much needed and very helpful, considering how quickly Rust's grammar has been evolving.
Ah, my mistake. So would I be correct in saying that a trait is a type, but it does not necessarily implement the Sized trait, and if it does not, then it cannot be allocated directly on the stack? Also, I've been…
Rust has algebraic data types. They're one of Rust's most important features. But algebraic data types do not in themselves provide a way to express the notion of a type with variants or sub-types.
I'm hoping the next post will talk about this use case: Suppose I have an enum called "Canine" and I want each of its variants to implement a different "bark" method. Currently, as far as I know, I have to write a match…
> I guess it just seems overly ambitious to me.. finding the right abstraction for the server is difficult enough without polluting it with the front-end. Certainly. That's why I'm skeptical that this will ever happen.…
> The examples you give don't seem to be typing problems, they seem to be wrong-value problems. They're like type or name errors because the "apple" and "orange" here are like identifiers, not data. Sure, to the…
Strong typing on the web has been an intractable problem for me so far. Sure, I can have strong typing in my server-side code. But so many errors result from the interaction between the server, CSS, HTML, and JS. For…
True, but the parent commenter is getting at something important. The article suggests that researchers have found a new, much more concise way to express the solutions to difficult problems. That's different from a…
Good to know. Thanks! So I guess the moral is, if you have a big, expensive struct, make sure the expensive part is in a sub-structure you know is heap allocated, such as a Vec. E.g.: struct Expensive { cheap_value:…
Oh, agreed. But how about this: let x = BigExpensiveStruct::new(); some_function(x); That won't trigger a big, expensive memcpy of the BigExpensiveStruct, will it? I'd thought that its memory was on the heap.
Yes, I had understood the struct's memory to be on the heap. My thinking was, keeping the memory on the heap allows for inexpensive moves. Whereas, the pointer to the heap space may indeed be on the stack, as far as I…
> Semantically speaking, the only difference between a move and a copy is that you're allowed to use a copy type afterwards Are you speaking about Rust specifically, or move in general? I had always understood that move…
> It seems to me like the value would be memcpyed, when you pass by value. As far as I know, the compiler should not copy in that instance. Rather, it should move. > There is not one unit of memory that is "taken over,"…
The author mentions that Rust's "Box type is an owning type" and compares Box to C++'s std::unique_ptr. Worth noting: Rust's most basic variable syntax provides unique_ptr-like behavior, so you usually don't need the…
The relative impact of your money vs your time depends in part on your income, you skill-set, and the causes you would choose. A person with a high income but few relevant skills would probably have the greatest impact…
I've always been uneasy about the fact that Stack Overflow users can edit each other's posts more or less arbitrarily. User A can edit user B's post to say something embarrassing, and most readers will attribute it to…
Even though 1.0 isn't out yet, today you can use Rust for many real projects. I'm unsure whether I'd bet my business on it yet, but I'd be open to the idea. And I'm usually a very late adopter. I've been building a 3d…
The article suggests that solar panels could be an "existential threat" to power companies. For those of you who are familiar with the math of solar panels, how realistic is that prediction? How much of a normal home's…