this post was submitted on 13 Jun 2024
17 points (100.0% liked)

Learn Programming

22 readers
1 users here now

Posting Etiquette

  1. Ask the main part of your question in the title. This should be concise but informative.

  2. Provide everything up front. Don't make people fish for more details in the comments. Provide background information and examples.

  3. Be present for follow up questions. Don't ask for help and run away. Stick around to answer questions and provide more details.

  4. Ask about the problem you're trying to solve. Don't focus too much on debugging your exact solution, as you may be going down the wrong path. Include as much information as you can about what you ultimately are trying to achieve. See more on this here: https://xyproblem.info/

Icon base by Delapouite under CC BY 3.0 with modifications to add a gradient

founded 1 year ago
MODERATORS
 

I'm trying to make minesweeper using rust and bevy, but it feels that my code is bloated (a lot of for loops, segments that seem to be repeating themselves, etc.)

When I look at other people's code, they are using functions that I don't really understand (map, zip, etc.) that seem to make their code faster and cleaner.

I know that I should look up the functions that I don't understand, but I was wondering where you would learn stuff like that in the first place. I want to learn how to find functions that would be useful for optimizing my code.

you are viewing a single comment's thread
view the rest of the comments
[โ€“] cflewis@programming.dev 4 points 5 months ago (1 children)

This is probably going to get downvoted into oblivion but: try writing some Haskell for a while. Learn You A Haskell is a good place to do it, just bail out when you get to monads.

When I was taught programming at university, we did one assignment in Java, then the next one was the exact same assignment but in Haskell. The idea was not to bias us towards imperative vs functional programming. I don't think it worked -- I would guess almost everyone preferred Java -- but over my career I've learned how much Haskell has offered me for writing imperative code for my day job. I think you will get what you are looking for by trying some Haskell for a while.

[โ€“] ericjmorey@programming.dev 2 points 5 months ago

just bail out when you get to monads.

Isn't writing Haskell nearly equivalent to writing monads? How could they start without using monads?