Hacker News new | ask | show | jobs
by steveklabnik 2000 days ago
> (it is possible this aside already exists and I just missed it)

Yeah I am not sure if it does or not; I'll make a mental note to go check sometime.

> I kind of wish the compiler had a "turn off all implicit behavior" option,

The problem is that what is "implicit" is different for everyone. Some people would say that Box::new is "implicit" because you don't see the malloc. Some might even say that malloc is implicit because you don't see the sbrk/memmap!

> But in the context of learning, it is not such a strict win,

Yeah so it's tricky! The thing is, without some way to jumpstart knowledge, people may never even learn in the first place. Like, by this argument, everyone should start with physics, because well, C compiles to asm complies to machine code which is actually just code for a chipset. There is no "I know what everything is doing" starting point. In reality, people jump in, start somewhere, and then expand what they know from there. This is true on every topic in every field. We still teach kids Newtonian physics even though on some level it's "wrong," you know?

1 comments

Sure, but Rust takes implicity a lot further than most. Implementation details of a function call are one thing; applying an operator in the current context, or adding an invisible generic type (lifetime parameter) to the current context, are something else. I think one key difference is that the unknowns are within the actual code that you're writing, not in places where you explicitly delegate to some other code to do something. The other key difference is that they're highly irregular: they apply sometimes and don't apply other times, which makes them hard to predict. The same syntax means one thing in one situation, and something different (or "nothing", when it doesn't compile) in another situation.

I guess I assumed there was some rustc compiler pass that would match certain patterns where stuff (like dereferences or lifetime parameters) has been omitted, and transform it into code where those things have been inferred and explicitly inserted. In which case it would theoretically be easy to skip that pass and turn those omissions into compiler errors.

Maybe it's my Ruby background, but I don't find Rust very implicit at all, haha. We all have our own things :)