How to become a competent coder? - I was advised to cross post here.
-
[email protected]replied to [email protected] last edited by
I'll be random and toss you a BASIC bone..
FUNCTION CalcPI# X# = 0: Y# = 1 FOR N% = 1 TO 26 R# = SQR(X# * X# + Y# * Y#): X# = X# / R#: Y# = Y# / R# P# = (2 ^ N%) * SQR((X# - 1) ^ 2 + Y# * Y#): X# = X# + 1 NEXT CalcPI# = P# END FUNCTION``` Figure it out, or not. 26 is not exactly fixed, the higher that number, the more accurate π is...
-
[email protected]replied to [email protected] last edited by
I believe the formatting issue is because the triple back tick is on a line with other text. In most markdown flavors triple backticks should be on blank line (with some exceptions for hinting at syntax highlighting). Slack's is the only dialect I've seen that specifically strips newlines from triple backticks and I hate it.
-
[email protected]replied to [email protected] last edited by
you're not yet in college and have been coding for 4 years?
You already have a head start. Most of my Comp Eng classmates hadn't written a hello world when they started. Go through your CS, get one or more internships, and you'll have some perspective.
-
[email protected]replied to [email protected] last edited by
I just tried an edit to add blank lines before and after the backticks, now happy formatting!
-
[email protected]replied to [email protected] last edited by
Why does everyone seem to thump on 'Hello World' as their first program?
My first program was BEEP
At least I learned that the computer could follow commands.
-
[email protected]replied to [email protected] last edited by
My suggestion which you seem to be doing is just to continue making things that are useful for yourself and others. Helped me a bunch in my early career. I could tell you so many stories ...
-
[email protected]replied to [email protected] last edited by
as in printing
\a
in c? It was one of my first ones too. -
[email protected]replied to [email protected] last edited by
actually create code that works as intended intentionally, and not through trial and error / stack overflow.
When do we tell them?
-
[email protected]replied to [email protected] last edited by
You'll formalise your knowledge in college, for now just work on whatever you enjoy most without worrying too much about what its teaching you.
-
[email protected]replied to [email protected] last edited by
Write code, lots and lots of it. Make it really good, clean code. Rewrite it multiple times if that's what it takes to get it clean. Developing those instincts puts you way ahead of just reading about another damn framework.
-
[email protected]replied to [email protected] last edited by
I was 15 years old. QBasic + BEEP was amazing to me at the time.
That's when I learned words could tell a computer what to do.
-
[email protected]replied to [email protected] last edited by
I will try to guess how that works!
keep in mind that I have no clue on how BASIC sintax works lol
1 -> function declared
2 -> variable x and y initiated to values 0 and 1.
3 -> for loop created that goes from 1 to 26 (updating variable N)
4 -> Variable R is created, its value is the square root of (x^2 + y^2). Xs and Ys values are set to be themselves divided by R.
5 -> P variable created (it stores the value of PI), and set to (2 ^ N) * square root of (x - 1) ^ 2 + y ^ 2. Lastly X is increased by one
6 -> Proceed only after for loop is done
7 -> return the variable P(I do recognize I just transcribed the code, and I also made an implementation in python of it, lol)
now for why that works ill figure another time, its 12:30 pm here and I am eepy :). But I have recognized that X tends to 2 and Y to 0.
and I am pretty sure this implements the algorithm of creating higher and higher "resolution" circles so starting with a triangle and adding more and more vertices (vertex?). Ill edit in the full explanation late
here is my implementation:
def CalcPi(): X = 0 Y = 1 P = 0 for i in range(1,26): R = sqrt(X**2 + Y**2) X = X/R Y = Y/R P = (2**i) * sqrt((X-1)**2 + Y**2) X += 1 return P
-
[email protected]replied to [email protected] last edited by
That was my first too! Followed by
BEEP
BEEP
BEEP -
[email protected]replied to [email protected] last edited by
Looks perfect to me!
Hell, resembles my first variation of the code back around the year 1999
-
[email protected]replied to [email protected] last edited by
The best way to learn is to just do it! When I'm starting out with something I generally have a few ideas of basic things I could do with it, generally that's making simple CRUD apps (when I started using Axum I made a simple API that returns json from a file directory as long as the directory is formatted as: /type/name. Then I went and made a website using vanilla js/html/CSS and made everything run using the backend).
This second project is great because there's always something else I could do like auth, like not doing a post and redirect to the same page for updates, like creating dynamic client & employee pages, like using an actual db instead of a script to make CSV files as a db. IMO, THIS is where you learn things.
-
[email protected]replied to [email protected] last edited by
sshhhh let the kid develop a bit of impostor syndrome first
-
[email protected]replied to [email protected] last edited by
I'm impressed!
Too lazy to test your version of the code, cuz I don't think I even need to. You understand the code from the start!
Wonderful! I love my π circles round...
-
[email protected]replied to [email protected] last edited by
Aside from what everyone else is saying, don't use dependencies that you don't have to. Particularly don't use big "frameworks". If you use any dependencies, use tiny, focused ones that do one thing. The more code there is underneath what you're writing, the more likely it will cause problems that you will internalize. I've seen it many times. Spring (Java), for instance, will do something not as advertised, and devs will think they're bad coders because they "can't write code that works as it's supposed to." Avoiding that vicious cycle will make you a better coder in the long run.
Also, when things aren't working with your dependencies, do google for fixes, but don't google too long. If you haven't got a solution after an hour of no progress, look at your dependencies' source code until you understand why and how to fix it.
-
[email protected]replied to [email protected] last edited by
And then cry when you land your first development job, knowing that you'll never get to build anything so clean and effective that will actually get implemented in the real world.
-
[email protected]replied to [email protected] last edited by
Proceed way past 26 if you want more accuracy, assuming the CPU can handle more accuracy (most likely these days)..