10 ms·
I really appreciate the user-friendliness of Rust's error messages -- I can't remember seeing a compiler tell me "maybe try this instead?" before (perhaps somet
by cfallin 10y ago
I really appreciate the user-friendliness of Rust's error messages -- I can't remember seeing a compiler tell me "maybe try this instead?" before (perhaps something from Clang, but never with the specificity of, e.g., a suggested lifetime annotation). And from a parsing / compiler-hacking perspective, it seems really hard to get the heuristics good enough to produce the "right" root cause. Kudos to the Rust team for this continued focus!
- jerf 10y agoIt's taken... I dunno, 50+ years?... but it's nice to see more and more code being written that doesn't assume programmers are superhuman beings with an IQ of 250 and infinite concentration and working memory. We need all the help we can get, so that we can focus as much of our precious, limited cognitive firepower on what really matters. When even John Carmack is talking about getting all the help he can from his development environment [1], you really ought to listen. [1]: http://number-none.com/blow/john_carmack_on_inlined_code.html http://number-none.com/blow/john_carmack_on_inlined_code.htm...
- hinkley 10y agoPair debugging is an exercise in patience that I often lose. If I had a dollar for every time I asked someone "Okay, look for other uses of this variable" and they grab the mouse and stare at the screen because THEY'RE READING THE ENTIRE FILE LOOKING FOR A PIECE OF TEXT, instead of using any of the dozens of search mechanisms at their disposal, I could retire and write self-help books for programmers. Stop trying to white-knuckle everything all the time, you masochistic people. Use tools like a sentient creature is supposed to.
- quantumhobbit 10y agoMaybe the other person in the pair is forgetting to use their tools because they are stressed out by the aggressive person standing over their shoulder looking for any excuse to grab the keyboard?
- kctess5 10y agoSometimes, this might be the case, however after the nth time of nicely saying "oh btw you can just do [insert shortcut] and find it right away!" it's hard to not get frustrated. I have definitely worked with people who for whatever reason, absolutely refuse to learn their text editors and debugging aids.
- hinkley 10y agoUsually this becomes an interpersonal issue when you're working with someone who has a track record of only changing 90% of the code that needs to be changed to implement a feature/bug fix because they keep missing one spot where the information is used.
- hinkley 10y agocough I have no idea what you're talking about. Mostly I think the exploratory phase of debugging is a battle between your limited short term memory and your imagination. It's a think you need to do alone and without someone stopping you to ask why every fifteen seconds. I think that's why people are so big on repro steps, so they can go off and start the process of elimination without having to dump state while defending checking possibility A before checking possibility B. I think the only reason (besides tenacity) that I fix bugs that others gave up on is that I have tricks that let me walk the code faster, which lets me make forward progress on deduction before I forget WHY I was looking under this rock in the first place. My debugging practices look not unlike a guy looking for his missing keys. You have to be careful about when to hit him for questions, and most of the time it's better to just start your own parallel search if you want to help.
- kbenson 10y ago> which lets me make forward progress on deduction before I forget WHY I was looking under this rock in the first place. There's nothing quite as deflating as finally getting to the end of diagnosing a particularly pernicious bug just to have the understanding trigger the realization that you've encountered this bug before a year or two prior, spent just as much time originally figuring it out, and had somehow forgotten about it the interim. Yay for wasted days of our lives.
- mrob 10y agoIt's your fault for saying "look for". They're doing just that. They're using all their available brain power thinking about the code so they don't have any to spare to interpret unclear instructions. Instead say "search for", or if that's still unclear say "control-F for" (or whatever shortcut activates search).
- donw 10y agoHave you tried suggesting that exact trick (using search rather than scanning) to your pair whenever they default to the Mark One Eyeball? Having paired quite a bit, it's rather amazing how many programmers just don't know the full utility of their existing tooling. Not because they are stupid, but just because they never made that particular connection. I have been on the receiving end of this dozens of times, and it is one of my favorite things about pairing as a programmer: where my pair shares a neat trick that saves me a notable amount of time and/or aggravation.
- cmontella 10y ago> it's nice to see more and more code being written that doesn't assume programmers are superhuman beings I would say that most compilers don't even assume the programmer is human. The root cause of bad errors is that they emanate from the compiler, and are reported from the perspective of the compiler. That's why you get errors like "can't access method undefined of undefined", or the hell that is C++ template errors. Sure, the errors make perfect logical sense from the perspective of a compiler, but they make my human eyes bleed. My favorite is a single missing semicolon that causes a cascade of unrelated errors, none of which indicate there's a missing semicolon. grammars, parsers, compilers, and languages as a whole should be designed for humans first. Even if it makes the language implementation a little more complex, human users will benefit greatly and thank you for it.
- boznz 10y agoI think that is why ADA became popular for mission critical stuff as you can inform the compiler a lot more about the constraints and so in effect make the compiler more user friendly. (Disclaimer happy to be corrected as I have never used ADA but I just finished listening to the podcast on embedded.com and thought it relevant)
- msbarnett 10y agoThe biggest correction I have is that it's not an acronym -- Ada, not ADA.
- eatbitseveryday 10y ago"ADA" as an acronym is more easily know as "Assistant District Attorney".
- nommm-nommm 10y agoI read ADA first as Americans with Disabilities Act (https://www.ada.gov https://www.ada.gov). In all seriousness, Ada the programming language is named after a person - the English mathematician Ada, Countess of Lovelace known as "the first computer programmer" ( https://en.m.wikipedia.org/wiki/Ada_Lovelace https://en.m.wikipedia.org/wiki/Ada_Lovelace)
- overcast 10y agoReading HN comments, I assumed everyone is a superhuman with an IQ of 250 and infinite concentration.
- qwertyuiop924 10y agoAre you even reading the same website as me?
- D-Coder 10y agoNot all of us.
- telotortium 10y agoJust wait until the next politics thread.
- smcl 10y agoDid you post the right link? That one was about John Carmack inlining some function calls and eliminating weird branching to (potentiall) reduce bugs/errors. Or am I missing something?
- ams6110 10y agoIn OpenBSD you'll see stuff like: warning: stpcpy() is dangerous GNU crap; don't use it warning: strcpy() is almost always misused, please use strlcpy() warning: strcat() is almost always misused, please use strlcat() warning: sprintf() is often misused, please use snprintf()
- jules 10y agoThose error messages, no matter how good, are curing the symptom not the cause. In other languages this particular problem doesn't exist in the first place.
- Sir_Cmpwn 10y agoRust has not killed and will not kill C. Can we please cut this crap out? Rust is a cool and useful language but I am getting tired of its proponents talking smack about everything else all the time.
- dikaiosune 10y agoThe person you're replying to didn't even mention Rust -- and they're right that many languages other than Rust avoid the problems cited in the listed error messages.
- Sir_Cmpwn 10y agoLoads of languages have old functions that could be better with hindsight, I'd probably say all of them. Some of them even have security implications (mysql_real_escape, anyone?). C isn't going away any time soon, and there's no value in decrying it as a response to being told about a feature that makes it safer!
- nickpsecurity 10y ago"Loads of languages have old functions that could be better with hindsight" Strawman. C's predecessors did it better with foresight. One of best such systems was built by C's inventors. BCPL author and C inventors deliberately removed safety at OS and language level due to hardware constraints plus personal preferences. Then nobody changed it to avoid work or broken apps. Hindsight aspect has nothing to do with it. "C isn't going away any time soon, and there's no value in decrying it as a response to being told about a feature that makes it safer!" Got mixed feelings on when to slam C or help its users out. I agree with you that bashing it at a comment on a safety improvement is probably a bad idea. It might have effect of reducing number of people promoting safer C strategies. I usually ignore, upvote them, or mention stuff like SAFEcode/Softbound depending on what's in comment. I go anti-C when misinformation shows up or on more general topics of safe, efficient apps.
- tetrep 10y agoHaskell has gotten really good at more or less telling you what to do, it's a pretty common technique while developing to have the compiler run in the background whenever you change a file[0]. I've found it to be great when developing because you can just let the compiler tell you what type you need to put somewhere, and you can use something like Hoogle[1] to find how you can get that type. [0]: usually people use this: http://www.mew.org/~kazu/proj/ghc-mod/en/ghc-modi.html http://www.mew.org/~kazu/proj/ghc-mod/en/ghc-modi.html [1]: http://hoogle.haskell.org/ http://hoogle.haskell.org/
- cfallin 10y agoI've heard that technique described as "type tetris". I find myself trusting the type system to guide me a lot in Rust too -- it's very nice!
- runeks 10y agoAt the end of that spectrum (moving away from values and towards types) are languages like Coq, where you have only types, no values, and it's the compiler that derives the implementation/values from the types you define. Like Haskell Servant[1], where you define your API as a type, and then you can derive functions from that type to query the API, because the type itself contains all the information necessary. Pretty fascinating stuff. [1] http://haskell-servant.readthedocs.io/en/stable/tutorial/ApiType.html http://haskell-servant.readthedocs.io/en/stable/tutorial/Api...
- cmrx64 10y agoCoq unifies terms and types, so that all you have a terms, but there's still a very concrete meaning of value: that which can be reduced no further (normalization, a property that the calculus of inductive constructions has).
- runeks 10y agohlint is also pretty good at giving advice: http://imgur.com/a/9oXd8 http://imgur.com/a/9oXd8
- edgyswingset 10y agoElm has great error messages which do this. F# is also adopting some of that style in F# 4.1: https://blogs.msdn.microsoft.com/dotnet/2016/07/25/a-peek-into-f-4-1/ https://blogs.msdn.microsoft.com/dotnet/2016/07/25/a-peek-in...
- fizzbatter 10y agoI'm quite new to a lot of the concepts in Rust, and while many error messages are simply infuriatingly confusing.. there are many that are extremely helpful. Hell, just the underline showing you what area is wrong really helps you spend the fewest cycles on simple typos and etc. It's really a joy. Fwiw, the frustrating times are usually involving some semi-obscure type system issue i've caused. But seeing as i'm probably their target user for these sort of messages (beginner), i guess my issues are still probably relevant.
- steveklabnik 10y agoIf you have the energy, we have an entire tag, A-diagnostics, on the tracker. It's to track confusing/poor error messages. So please file them!
- taeric 10y agoThe jikes java compiler had very well done error messages, from what I remember.
- amelius 10y ago> I can't remember seeing a compiler tell me "maybe try this instead?" What is next? Clippy? [1] [1] https://en.wikipedia.org/wiki/Office_Assistant https://en.wikipedia.org/wiki/Office_Assistant
- steveklabnik 10y agohttps://github.com/Manishearth/rust-clippy https://github.com/Manishearth/rust-clippy
- cpeterso 10y agoHave any Clippy warnings be added to rustc? Many of them look like real bugs that would benefit more people if included in rustc itself.
- steveklabnik 10y agoNot yet. Adding warnings is tough; some part of the ecosystem compiles with "warnings == errors", and so adding new lints can cause ecosystem breakage.
- lifthrasiir 10y agoAnd not to mention that "soft" warnings not included to the list would essentially have the same problem as `-Wall` vs. `-Weverything`. wink
- chrismorgan 10y agoCrates.io should have a check for things that get published to it that objects if you try to upload something with `#![deny(warnings)]` on the crate. It’s fine for your own code, but production libraries should never use it.
- GolDDranks 10y agoThe joke's on you: Clippy – A bunch of lints to catch common mistakes and improve your Rust code https://github.com/Manishearth/rust-clippy https://github.com/Manishearth/rust-clippy
- kalleboo 10y agoI don't know if I've seen it in compiler output, but I've seen IDEs like Eclipse and XCode have some pretty good "fix it for me" suggestions (maybe those are sourced from the compiler, I'm not sure).