4 ms·
I mean, maybe? If you come into Rust thinking you're going to write doubly-linked lists all day and want to structure everything like that, you're going to hav
by jkelleyrtp 2y ago
I mean, maybe?
If you come into Rust thinking you're going to write doubly-linked lists all day and want to structure everything like that, you're going to have a bad time.
But then in python you run into stuff like:
```
def func(list = []):
list.append(1)
```
and list is actually a singleton. You want to pull your hair out since this is practically impossible to hunt down in a big codebase.
Rust is just different, and instead of writing double-pointer code, you just use flat structures, `Copy` keys, and `loop {}` and move on with your life.
- fiedzia 2y ago> this is practically impossible to hunt down in a big codebase use linters, they keep getting smarter
- n_plus_1_acc 2y agorustc is a good smart linter
- junon 2y agoAnd if you're really wanting to be stringent, clippy exists for more subjective or more expensive lints. And it's also very good.
- Izkata 2y agoFYI this site doesn't use ``` for code blocks, it uses indentation (two spaces). https://news.ycombinator.com/formatdoc https://news.ycombinator.com/formatdoc
- mewpmewp2 2y agoA bit off topic, but how do people usually write code here or on Reddit, I always find it to be really cumbersome to make sure there's two spaces etc in front of everything? Is there some formatting tool that I'm not aware of that everyone else uses? Because in both forums I keep coming back to edits, and it takes forever to edit some of the things, manually. I feel like I'm being stupid or the UX of all of that is just so terrible.
- satvikpendem 2y agoI actually use a formatting tool online if on mobile, or just vim if on the computer, which can add two spaces in front of every line.
- Izkata 2y ago> or just vim if on the computer I use Firefox + Tridactyl + the native extension, so with the cursor in any text field I can hit Ctrl+i and it pops up a gvim window with the contents of that text field. When you save+quit, it copies the contents back into the field. So glad someone figured out how to do this again once Vimperator died.
- steveklabnik 2y agoI write it in play.rust-lang.org, then indent using the vim keybindings. I do this even for not rust code.
- pjmlp 2y agoCode editor and then paste.
- School-Cotton 2y agoI paste the code into an invocation of sed s/^/ /
- jasomill 2y agoSpecifically: 1. Copy code to clipboard. 2. From a shell prompt on macOS, pbpaste | sed 's/^/ /' | pbcopy Linux (Wayland), wl-paste | sed 's/^/ /' | wl-copy Linux (X11), xclip -o -se c | sed 's/^/ /' | xclip -se c Windows (PowerShell), Get-Clipboard | % { $_ -replace '^',' ' } | Set-Clipboard 3. Paste into HN.
- School-Cotton 2y agoThanks, I didn't know about xclip -se c I've been typing out "-selection clipboard" this whole time!
- s17n 2y agoI have literally never used a doubly-linked list in my life, and I'm pretty sure that most programmers can say the same thing. As for the example... yeah, Python is pretty terrible (for writing production codebases, I think its a great language for short-lived, one-person projects). Interesting that you mention Python because if you're considering Python and Rust for the same use case that's pretty bonkers, for anything that you might possibly have used Python to do there are many more natural choices than Rust. If you wouldn't have done it in C/C++ ten years ago, you probably shouldn't be doing it in Rust today.
- deleted 2y ago[deleted]
- pjmlp 2y agoIf the programmers have a proper degree, they surely have used them, additionally they probably have done it inderectly, depending on what languages they use.