# Inefficient Code

**URL:** <https://forum.freecodecamp.org/t/inefficient-code/68798>\
**Category:** General\
**Created:** [December 24, 2016, 4:05pm UTC](https://forum.freecodecamp.org/t/inefficient-code/68798 "2016-12-24T16:05:41Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![tophermurphy](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/tophermurphy/32/109066_2.png) [@tophermurphy](https://forum.freecodecamp.org/u/tophermurphy)\
**Post date:** [December 24, 2016, 4:05pm UTC](https://forum.freecodecamp.org/t/inefficient-code/68798/1 "2016-12-24T16:05:41Z")

</div>

I just finished **Sum All Primes** and **Smallest Common Multiple** and I am realizing that my code is probably the slowest possible.

Would you all recommend pushing through and possibly returning later or should I look to other resources to learn about more efficient code and mathing?

---

<div class="post-metadata">

**Author:** ![lincore](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/lincore/32/101809_2.png) [@lincore](https://forum.freecodecamp.org/u/lincore)\
**Post date:** [December 24, 2016, 4:33pm UTC](https://forum.freecodecamp.org/t/inefficient-code/68798/2 "2016-12-24T16:33:35Z")

</div>

Many very smart people have thought a long time about efficient ways of finding primes or calculating the scm so I’d say it’s totally normal that your solution isn’t as elegant as theirs. Of course, one has to differentiate between inefficient code and an inefficient algorithm. The former is comparatively easy to improve, the latter no so much. Of course, the problems you mentioned have been studied for millennia, so you can look up efficient algorithms on Wikipedia 🙂 .

Should you push trough? Depends if you think you understand what you were taught. Or maybe you are curious to learn more about the mathematical problems presented in the challenges. If you aren’t, I’d assume the focus is more on basic programming than it is on the sieve of Eratosthenes 😉 Over time you’ll learn to write better code, don’t worry. Experience is a major factor here.

---

<div class="post-metadata">

**Author:** ![jenovs](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/jenovs/32/60963_2.png) [@jenovs](https://forum.freecodecamp.org/u/jenovs)\
**Post date:** [December 24, 2016, 4:38pm UTC](https://forum.freecodecamp.org/t/inefficient-code/68798/3 "2016-12-24T16:38:25Z")

</div>



---

<div class="post-metadata">

**Author:** ![tophermurphy](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/tophermurphy/32/109066_2.png) [@tophermurphy](https://forum.freecodecamp.org/u/tophermurphy)\
**Post date:** [December 24, 2016, 7:03pm UTC](https://forum.freecodecamp.org/t/inefficient-code/68798/4 "2016-12-24T19:03:46Z")

</div>

Thanks all for the responses.

It reminds me of another thread else where about using Vanilla Javascript as opposed jQuery. Someone brought up, what is the point of worrying about 241kb of extra code, when you have a site filled with large uncompressed images and video.

---

<div class="post-metadata">

**Author:** ![AdventureBear](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/adventurebear/32/74786_2.png) [@AdventureBear](https://forum.freecodecamp.org/u/AdventureBear)\
**Post date:** [December 24, 2016, 7:26pm UTC](https://forum.freecodecamp.org/t/inefficient-code/68798/5 "2016-12-24T19:26:21Z")

</div>

keep moving forward. You can always come back and refine later with the things you learn while doing additional projects and algorithms.

---

<div class="post-metadata">

**Author:** ![JacksonBates](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/jacksonbates/32/123402_2.png) [@JacksonBates](https://forum.freecodecamp.org/u/JacksonBates)\
**Post date:** [December 24, 2016, 8:16pm UTC](https://forum.freecodecamp.org/t/inefficient-code/68798/6 "2016-12-24T20:16:19Z")

</div>

My previous answer to this question:

> **[How do people refactor code?](https://forum.freecodecamp.org/t/how-do-people-refactor-code/43188/4)**
>
> One of the pieces of advice that gets trotted out here fairly often is: Don’t refactor… …yet. While you are still learning the fundamentals, just keep chugging through the algorithms. Each time you solve one, celebrate the win and then move on....

---

<div class="post-metadata">

**Author:** ![RadDog25](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/raddog25/32/55504_2.png) [@RadDog25](https://forum.freecodecamp.org/u/RadDog25)\
**Post date:** [December 26, 2016, 8:49am UTC](https://forum.freecodecamp.org/t/inefficient-code/68798/7 "2016-12-26T08:49:54Z")

</div>

I agree with other posters before me, just keep going. Optimizing a program that finds prime numbers isn’t going to help you make a cool app or get a good job. Computers can handle thousands of iterations like nothing and are getting faster all the time, and I don’t feel bad about making them do some heavy lifting. As long as you don’t cause noticeable lagging I wouldn’t worry about.

---

<div class="post-metadata">

**Author:** ![bastienvinh](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/bastienvinh/32/516_2.png) [@bastienvinh](https://forum.freecodecamp.org/u/bastienvinh)\
**Post date:** [December 31, 2016, 8:27pm UTC](https://forum.freecodecamp.org/t/inefficient-code/68798/9 "2016-12-31T20:27:16Z")

</div>

In fact, I remember my boss using the term “Intellectual Masturbation”.

Well, I attacked the UK job market and you must know how to code something fast. Know all the well-known pattern, all the algorithms, …  
Whatever …

I still think that the user experience is important. And people forget that a lot. And even my code is not fast, I’m very good refactorer coder. That means a good coder should be able to debug, to destroy his code and remake a logic to apply to the current logic like a surgeon. You can see a good developer in an emergency or develop a critical environment.

There is no such thing as an ultimate program. You will always code, debug, modify the code anyway. And I use the SOLID principle where a function does one thing at a times and very well.

I learnt years ago this expression: “[Make it works, make it right, make it fast](http://wiki.c2.com/?MakeItWorkMakeItRightMakeItFast)”

You can also read this: “[Premature Optmisation](http://wiki.c2.com/?PrematureOptimization)”

You can read this too: “[Blub Paradox](http://wiki.c2.com/?BlubParadox)” or this “[Mental Masturbation](http://wiki.c2.com/?MentalMasturbation)”

---

<div class="post-metadata">

**Author:** ![AdventureBear](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/adventurebear/32/74786_2.png) [@AdventureBear](https://forum.freecodecamp.org/u/AdventureBear)\
**Post date:** [December 31, 2016, 8:53pm UTC](https://forum.freecodecamp.org/t/inefficient-code/68798/10 "2016-12-31T20:53:41Z")

</div>

> [@bastienvinh](#):
>
> You can read this too : “Blub Paradox”

I grew up with Paul Graham. Wicked smart.

---

<div class="post-metadata">

**Author:** ![jwilkins.oboe](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/jwilkins.oboe/32/179497_2.png) [@jwilkins.oboe](https://forum.freecodecamp.org/u/jwilkins.oboe)\
**Post date:** [January 16, 2021, 6:11am UTC](https://forum.freecodecamp.org/t/inefficient-code/68798/11 "2021-01-16T06:11:26Z")

</div>


