How Rust Gets Polymorphism Right [video]
youtube.com
youtube.com
>I'm using nalgebra for math. I'll write a bit about it here, because I think it's relevant to Rust as whole. I'm not sure if I actually like it. It's so heavily templated that most of the error messages are impossible to understand, so I usually just double-check what I wrote and try to guess what's wrong. It's also where rust's documentation generator gets in trouble. Signal to noise ratio there is <10%. Not sure how to fix that. Anyway, my point is that maybe it's not always the best idea to write code as generic as possible.
[1]: https://www.reddit.com/r/rust/comments/795dg4/i_spent_the_la...
Of course, the UI is a part of Rust, so these things do matter, but as far as the language implementation is concerned, it’s not as bleak as all that. Rust, being a comparatively complex language (unlike Go, for example, where linguistic simplicity is a feature) is taking a long time to mature, but it is steadily maturing.
But this is the case of one library. Another library to suffer from poor errors is the futures lib, but that will be solved with the `impl Trait` syntax that is in the works.
Definitely agree it's a good idea to have a balance when it comes to generics, but likewise I'm glad folks are pushing the boundaries and finding room where things could be improved. It does take time for the language to catch up though, but they're working on it. Lots of good stuff is coming out of the current impl period.
For what its worth, my cgmath library just has a bunch of hardcoded `Vector{2,3,4}`, `Point{2,3}`, and `Matrix{2,3,4}` types.
Although Rust heavily borrows from the ML family, the fact it has mutability and imperative reasoning makes it hard to compare them.
But if you want a short one:
- Sum Types EDIT: AND Product Types (silly me)
- function-objects & closures
- typeclasses (as far as I can tell), but no higher kinded types
- no monads, functors nor monoids built-in
- trait objects (eg. runtime polymorphism, think "abstract classes")
Maybe I'm missing something, but aren't tuples and structs/records examples of product types? Which both rust and haskell have?
Rust most certainly has them, as does Haskell. Records/structs of course are just the same thing with names for the components.
Thus, even Java has product types.
Even C has product types. Which is why I'm always bothered when people claim language X lacks algebraic data types.
They probably lack sum types, but are very unlikely to lack product types.
That makes no sense. Algebraic data types are not expressed, they're a concrete thing, a classification of composite types (by multiplication (hence product types) or addition (hence sum types)).
Some shitty languages don't have a concise way for you to express particular things (like sum types), so you have to rely on idioms or "patterns".
{ 1 = "hi", 2 = "howdy" };
And get: val it = ("hi","howdy") : string * stringI don't think Rust is that much different from other functional languages. The main critical difference is the manual memory management feature - the way it's acknowledged and used throughout the language and the ecosystem means that the functional patterns commonly used in garbage collected languages don't look nearly as natural in Rust.
http://science.raphael.poss.name/rust-for-functional-program...
Trait objects are basically existential types, with a few more restrictions on them. But in essence polymorphism in Haskell and Rust are very similar.
The big thing Rust is missing is higher kinded polymorphism, ie the ability to abstract over type constructors. This makes it easy, for example, to abstract over a container type while putting different things in that container.
This has get approved in the Associated Type Constructors RFC, but it's still in the works for actually landing.
Whilst this is obviously useful, it makes it impossible to perform parametricity type-based reasonbig.
Also, I'm not sure why you would ever want a "partial instance," as it would mean that your program could be unsafe but still typecheck (I haven't checked out Rust's implementation or motivation). Just use more specific classes, and you can even use a "generic" "instances of the components imply an instance of the whole" class and instance.
Newtypes also exist in Rust but this is an alternative that is not the same as the overlapping instances extension.
You can either have overloading classes or you can have your classes declaration independent of the type declarations. You can not have both.
(Interpretation of that raised eyebrow: text isn’t hard to mess up. It is nonetheless more accessible in general, I just couldn’t leave the “text is very hard to mess up” unremarked on.)
Edit: or have I completely missed the point of what you're saying!
Consider that there was a time not so long ago where the vast majority of people didn't know what LOL meant and would be confused when encountering it. On the other end you could probably copy some heavy British slang in here right now and I would be very confused.
The fact that it was open to several additional interpretations merely suited my sense of humour.
Giving a presentation though there isn't such an incentive and the goal is more explicitly to explain your idea rather than to prove how clever it is. So I find presentations easier to follow in general (unless they are a bad speaker, of which there are unfortunately many).
Destroy all software is closer, but is kind of like one guy. Great for him! And for me on my flight here in a few minutes. But what I envision is more like training speakers to be concise and engaging yet informative. Kinda like how an editor helps a writer cut out things to make a better novel, but for tech talks. A tall order, I know.
I always fantasize about a collaborative app that would blend a few smartphone audio recordings to cancel noise and room reverb into a nice vocal signal.
The bigger trick would be getting various parties at any given event to help out by first recording and then submitting their data to the same collaboration service. I've seen enough rooms full of techies struggling to get a projector or conference call working to imagine all kinds of headaches with connectivity, app installation, finding the right event reference, etc. If you allow post-event submission, most people would probably forget or not care by the time they got back to their home networks only to be annoyed weeks or months later that they still have a large audio file taking up space on their device.
As more people are posting various captures (just for personal-reasons/vanity, without necessarily going out of their way to prescribe any particular remix), maybe something like PhotoSynth where you crawl the web for media having similar GPS and timestamps could work. Maybe people could be bothered to tag their posts with hashtag #YetAnotherCon2017; then you just have to monitor a couple of the more popular social channels.
About cooperation, I'm sure it's not hard to find 10 people willing to contribute. You can even count the people talking or organizers.
Here's one for example: https://twei7.com/papers/Sur_Wei_MobiSys14_Dia.pdf