Created
October 16, 2012 19:02
-
-
Save eevee/3901262 to your computer and use it in GitHub Desktop.
Rust nitpicks
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some rough edges I have bumbled across. Bearing in mind that I don't do a lot | |
of low-level statically-typed work: | |
- Strings are indexed as `u8`, which is incompatible with `char`. If strings | |
are going to be a first-class type, they should really really REALLY REALLY | |
act as sequences of Unicode codepoints as much as possible, whatever the | |
implications of that may be. A trait for `[u8]` could add some niceties for | |
sequences of meaningless bytes, and `str` could have a method that provides | |
a view to its UTF-8 encoded byte sequence without needing copying etc. (I | |
know, indexing by codepoint is O(n), but there are countermeasures.) | |
pcwalton proposed merely removing indexability altogether; might work, might | |
also get you stabbed. | |
- Strong numeric typing is awesome, but with the plethora of numeric types | |
(and especially when interacting with C code) there is a lot of manual | |
casting involved. Which is okay, except now my code is full of explicit | |
conversions that worry me, rather than implicit conversions that worry me. | |
I don't want the typing to become weaker, but as the compiler already knows | |
the sizes of all the numeric types and thus which casts are safe, it would | |
be nice to have /some/ distinction between `some_u8 as u16` and `some_u32 as | |
i16`. | |
- I doubt I'll get any sympathy for this, but I'd really rather have `and or | |
not` than `&& || !` :) `!` in particular is easy to overlook. | |
- I miss being able to inspect things: module contents, struct attributes, | |
trait methods. | |
- The implicit-return thing sucks. I did Perl for many years and still find | |
it basically unreadable there, and now it's a required feature (returning | |
from a closure or emitting a value from `match`) but draped in the guise of | |
a missing semicolon, which to my eyes always registers as a typo or | |
laziness. | |
================================================================================ | |
And stdlib in particular: | |
- The rendered HTML docs kinda suck. Hard to distinguish items that have | |
subheadings, `const`s take a ton of vertical space, function index for large | |
modules (like `vec`) is only so helpful. | |
- Hard to tell what methods are actually implemented on any given type. For | |
example, in `io`, there's a heading for `Implementation of ReaderUtil for T` | |
-- what? | |
- Also not obvious what the canonical constructor for a given type is, but | |
maybe "classmethods" will solve this. (Can types have docstrings? I | |
haven't seen any.) | |
- Not sure if this is a problem with the docs generator or the actual docs, | |
but a couple docstrings have been cut off -- see `vec::each_const` and | |
`vec::each_mut`. | |
- Docs could use more examples. Or any examples. :) | |
- Doesn't seem to be an equivalent to exit() -- there's an | |
`os::set_exit_status`, but it doesn't actually kill the program, and `fail` | |
will override the status. Maybe this is a feature. | |
- Network stuff is spread around; what is `net` for if it doesn't contain any | |
of the net_* modules? | |
- A separate std module for every single hash function is a bit extreme; | |
oughta live under a `hash` roof. Even better, oughta all implement the same | |
trait. | |
- core has several modules implementing effectively the same functions for | |
various numeric types -- the signatures even mention `T`. Methodize? | |
- It's kinda subtle whether functions are intended to be used with `do` or | |
`for`; rustdoc should notice a compatible signature and Do Something to | |
highlight it. | |
- Sorting surely doesn't need to be a whole module. Just steal timsort. :D |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment