how to learn to code

In a formal degree program, the similarities between linguistics and computer science appear even stronger. (Linguistics isn't language learning, but it's along the same vein).

The difference between a prefix notation and an infix notation language is about as small as the difference between a head initial and a head final language. (They look very different on the surface, but if you're drawing syntactic trees instead of reading full sentences, it's just one little thing that gets flipped around).

And listening to people from both sides talk about semantics gets really redundant.
While that's true, I'd just add that languages aren't math. They are organic and there's tons of ways to express meaning in a language that literally make no sense if you look at them from a purely grammatical perspective, they're just exceptions to grammatical rules. On the other hand, programming is purely mechanical and technical. If the computer says there's a problem with your code, the computer is always right. There are NO arguments in C++ like the disagreements over verb splitting in English. Like, this phrase, "To very quickly run away" is considered incorrect by some people because "To run" is supposed to always be one (1) unit that can't be broken up by adverbs.
 
While that's true, I'd just add that languages aren't math. They are organic and there's tons of ways to express meaning in a language that literally make no sense if you look at them from a purely grammatical perspective, they're just exceptions to grammatical rules. On the other hand, programming is purely mechanical and technical. If the computer says there's a problem with your code, the computer is always right. There are NO arguments in C++ like the disagreements over verb splitting in English. Like, this phrase, "To very quickly run away" is considered incorrect by some people because "To run" is supposed to always be one (1) unit that can't be broken up by adverbs.
It's been a long while since I did a linguistics syntax course so I can't give a super thorough explanation of it, but they reduce human languages to be just as restrictive as computer languages.

Sentences that have two possible interpretations are basically the result of putting parenthesis in different places, so the structure of the sentence is different even if the sequential string of words is identical. Garden path sentences are fun examples of people's parenthetical instincts being subverted.

The thing about splitting verbs is just head movement. Basically, you can draw sentences as binary trees to show the relationships between the words in the sentence. The words have classes (kind of like parts of speech, but more specific than that), and there are rules about which classes of nodes are allowed to go into other nodes. This is like when a function requires arguments of specific types.

Often times, the syntax trees will have nodes that appear to be empty, but we know that the nodes are there because of the type compatibility thing. If the types don't match up, there's some number of invisible null-only layers between the words that we can see. Verb splitting is not random, it occurs when a verb uses those null nodes to climb the syntactic tree to another position in the sentence. The OK-ness of that movement varies between people/languages, but there are also degrees of wrongness and some people who say it's wrong will still say that it makes sense.

If you can put an explicit word in one of the null nodes to "block" the verb from moving but still try to split the verb, then the result is an even more wrong sentence that sounds wrong to everyone - even the people who are OK with verb splitting balk at it. Due to Universal Grammar, this can be seen across different languages too, and the sentences used to probe the phenomena are often not even in English. (we can still more or less figure it out because of the data type compatibility thing; even if the words look like nonsense to us we still have the basic concept of what a noun and a verb are).

I would try to give you sample sentences to demonstrate, but again, it's been a while, they're not usually in English, and quite honestly doing grammar badly in purpose is hard. If you actually care, maybe Google syntax head movement and hope someone was forced to do a presentation for class.

E: I will add that there is meaning that doesnt fit under grammar like idioms and metaphors, but verb splitting isn't one of them. Verb splitting is just people having different configurations set for when head movement is legitimate.
 
Last edited:
In C++ you have things like adding numbers, and that's fairly easy. It goes something like: firstnumber + secondnumber
But firstnumber and secondnumber are variables you replace with other numbers, so it's like firstnnumber = 15

Later on I guess I'll learn more complicated math functions, but, as a general question, how much math is usually used in coding? If I ever begin working on a personal programming project, I guess I'll find out. Today learned about basic functions, like adding 2 numbers. This is the first thing I found somewhat challenging in learning how to code, but I will practice it and I should master it pretty easily.
 
Later on I guess I'll learn more complicated math functions, but, as a general question, how much math is usually used in coding? If I ever begin working on a personal programming project, I guess I'll find out. Today learned about basic functions, like adding 2 numbers. This is the first thing I found somewhat challenging in learning how to code, but I will practice it and I should master it pretty easily.
Almost none, unless you are trying to solve a mathematical problem. At your stage, its mostly learning how to call functions and set the input arguments to get the expected outputs.

The bulk of programming would be trying to solve problems in a logical way.

I was just hacking a Rimworld mod again, to bypass a password screen (part of the mod story/fluff, but I couldn't be assed to decode cryptic clues). The screen in question calls a one way hash function to compute the password string into an integer value hash and compares it to a stored hash value. So I just modified the hashing function to attempt to parse the input string as an integer and return it as the result of the hash compute. The result was that I can just put in the expected hash result as the password and it'll match perfectly. It's just a few lines of code that runs after the original code to override the results and bypass everything, but learning how the password screen worked was the real fun.

tldr find something you want to do, do it with what you know of programming.
 
Right now, I'm beginning to learn how to code. For me, it's PURE profit incentive. What is concerning for me is that, while learning the languages is fine, I want to be really professional. In computer science they teach you math and other mathematical algorithms to both optimize what you're doing so it takes up the least computer resources and also is useful for encryption. I've heard, for some reason, that programmers who work on games are the lowest level of programmer. It's like being a doctor and then somebody asks you : "OK, do you work at a walk-in clinic or are you a neurosurgeon?"

Nothing wrong with being a doctor at a walk-in clinic or even a game developer, I just want to get really good at coding (for the money) and I don't know how far and how complex it can get. I DON'T know what compilers do. There's gcc and clang and msvc for C++. I don't know what any of them do and which I'll need, but if I stay optimistic and keep working hard I WILL learn how to code.
Not sure of your age, but if you're in high school or college, look into in person classes.

If not, find other peoples code, look at it, digest it, learn what it means. Code is usually pretty straight forward in the way that you can interpret the meaning easily. After you read through it, try to take what you learned and apply it to your own code replicating that program's function, and look for reference if needed. From my time programming, I learned pretty quickly that trying to learn it by yourself with just resources or a textbook is rough. Online IDE's Like Replit are your friend. Replit will help correct your code along the way. Personalizing your code is what makes you good at it. You can go by the book and write scripts down, but think while you're writing it. Is this code worth it if it's 10 lines? Can I make it 5 lines instead? That'll help you progress. Programming is all about taking what you learn and making it your own. Also, don't feel bad to use things like Stack Overflow.

Also, to answer your question about math in coding, it depends on what you're making. I made a Python program for a class that had a grid with moving pieces that moved based on them being "content" or "discontent". It was heavily math focused and was complex, but the actual mathematical part was not hard at all (I am terrible at math) and just involved critical thinking.

You'll get better at it the more you do it. Good luck :)
 
In C++ you have things like adding numbers, and that's fairly easy. It goes something like: firstnumber + secondnumber
But firstnumber and secondnumber are variables you replace with other numbers, so it's like firstnnumber = 15

Later on I guess I'll learn more complicated math functions, but, as a general question, how much math is usually used in coding? If I ever begin working on a personal programming project, I guess I'll find out. Today learned about basic functions, like adding 2 numbers. This is the first thing I found somewhat challenging in learning how to code, but I will practice it and I should master it pretty easily.
The primary math you learn for programming is discrete mathematics. It's kind of a hodgepodge of things like number theory, set theory, formal logic etc. For things like graphics and AI, you'll also need linear algebra (or at least be able to understand it well enough to use someone else's shit) and statistics.

Discrete math is very important once you start moving on to optimizing your code. Understanding things like set operations can trivialize a lot of slow and error-prone algorithms you see beginners write.

If not, find other peoples code, look at it, digest it, learn what it means. Code is usually pretty straight forward in the way that you can interpret the meaning easily. After you read through it, try to take what you learned and apply it to your own code replicating that program's function, and look for reference if needed. From my time programming, I learned pretty quickly that trying to learn it by yourself with just resources or a textbook is rough. Online IDE's Like Replit are your friend. Replit will help correct your code along the way. Personalizing your code is what makes you good at it. You can go by the book and write scripts down, but think while you're writing it. Is this code worth it if it's 10 lines? Can I make it 5 lines instead? That'll help you progress. Programming is all about taking what you learn and making it your own. Also, don't feel bad to use things like Stack Overflow.:)
The number one way to get better is to read other people's code and digest it. You'll eventually reach a point where the niche use case you want to use some library for isn't in a neat annotated form on Pajeet Overflow. At that point, you must be able to find a working example out in the wild, read it, understand what it's doing, and synthesize your own way of using it based on what you learned.
 
ALSO I think compilers are things that your code into .exe files so you can "execute" them.

Maybe a way to think about it:

The computer is a machine. It's a mess of thousands of buttons and switches that can do useful tasks. The compiler is a robot that knows how to operate the machine, and the programming language is the way a human communicates to the robot.

You don't really care which buttons the robot presses and in what order. You only care that the machine output matches the tasks expressed in your instructions. An old robot might do your task in 1,331 button presses. A new, more efficient one does it in just 397 presses.
 
What I'm discovering is that there's a wealth of both video and written content to help people learn programming. Not all of it is the best, and it's not exactly easy to learn from scratch, but everything is basically open to you. With enough dedication (a lot of dedication) you can learn advanced programming just with what is available to you for free
 
  • Like
Reactions: Aidan
The stuff in the spoilers are code that I've written to state your name, age and job. If done correctly, it should go like "Hello John Metroid, your age is 45 and Table Cleaner is your job."

For some reason this is the only configuration of the code that works:
std::string full_name, occupation;
int age3;
std:: cout << "Please type your name, age and job : " << std::endl;
std::getline(std:: cin,full_name);
std::getline(std:: cin,occupation);
std:: cin >> age3;

std:: cout << "Hello " << full_name << " you are " << age3 << " years old and " << occupation << " is your job." << std::endl;
return 0;
}

Any other order breaks it, like this for example:
std::getline(std:: cin,full_name);
std:: cin >> age3;
std::getline(std:: cin,occupation);

I don't know why the other order doesn't work. This is because I've started learning C++ a week ago and I barely know what I'm doing
 
The stuff in the spoilers are code that I've written to state your name, age and job. If done correctly, it should go like "Hello John Metroid, your age is 45 and Table Cleaner is your job."

For some reason this is the only configuration of the code that works:
std::string full_name, occupation;
int age3;
std:: cout << "Please type your name, age and job : " << std::endl;
std::getline(std:: cin,full_name);
std::getline(std:: cin,occupation);
std:: cin >> age3;

std:: cout << "Hello " << full_name << " you are " << age3 << " years old and " << occupation << " is your job." << std::endl;
return 0;
}

Any other order breaks it, like this for example:
std::getline(std:: cin,full_name);
std:: cin >> age3;
std::getline(std:: cin,occupation);

I don't know why the other order doesn't work. This is because I've started learning C++ a week ago and I barely know what I'm doing
Not well versed in C++ so I won't be able to give a detailed answer, but the issue seems to stem from your mixing of getline and >>.

>> extracts a value up to any whitespace character (e.g. space, tab and newline) but does not discard it. The discarding is instead done by subsequent calls of >>.

As getline does not remove leading whitespace characters it reads the still present newline character and thus returns an empty string.
 
As I'm progressing in coding, I'm shocked by just how intuitive it is. That, or maybe I have a natural aptitude for coding or the course I'm taking is just good. The more I learn, the more the once previously "arcane language" of programming becomes something comprehensible to me. I can say I'm having a bit of fun doing this.

The take away would be that, in order to learn to code, you need to come at it with a positive mindset
 
In C++ you have things like adding numbers, and that's fairly easy. It goes something like: firstnumber + secondnumber
But firstnumber and secondnumber are variables you replace with other numbers, so it's like firstnnumber = 15

Later on I guess I'll learn more complicated math functions, but, as a general question, how much math is usually used in coding? If I ever begin working on a personal programming project, I guess I'll find out. Today learned about basic functions, like adding 2 numbers. This is the first thing I found somewhat challenging in learning how to code, but I will practice it and I should master it pretty easily.
It just depends on what you are programming.

To really progress beyond a certain point though, you will need to learn how to develop and interpret algorithms. Data structure and algorithms are very math based, but a lot of it is intuition and creativity rather than concrete math skills. This is the skill that will help you with technical interviews if you want to pursue this for a living.
 
Machines can already weld faster than humans. But you need skilled tradesmen to tackle jobs on site, that is not going away in this lifetime.
>they invent the portable robot welder that can go onsite and do the job better than people
god help us all
 
  • Optimistic
Reactions: Pee Cola
It just depends on what you are programming.

To really progress beyond a certain point though, you will need to learn how to develop and interpret algorithms. Data structure and algorithms are very math based, but a lot of it is intuition and creativity rather than concrete math skills. This is the skill that will help you with technical interviews if you want to pursue this for a living.
Yeah it's all really maths and the theoretical history underpinning how we got to these paradigms where it doesn't feel like maths at all are actually super interesting. Now we get to solve the puzzle of tricking computer into doing everything instead, or brute forcing shit until it works. It's fairly rare that you have to get into actual mathbrain mode unless it's maybe some crucial optimisation situation, you're implementing some bullshit for fun that you could have just used a library for, or you're doing some arcane unique thing where you can't scrounge up a research paper and steal their method.
Or if you want you can try prolog or haskell or something and die
 
Machines can already weld faster than humans. But you need skilled tradesmen to tackle jobs on site, that is not going away in this lifetime.
We literally have weirdo Boston Dynamics kill bots running around and you think they can't put a hypothetical AI in one on a job site?

Hell they could literally hire someone unskilled for a third of what a welder makes to bring the welding bot to the site and let it do what it needs to do. Maybe this will not happen immediately but a lifetime is a long time my dude and you're absolutely retarded if you think that it wouldn't happen within a decade of programmers being obsoleted by AI.

Also once programmers and engineers are made redundant, technological progress is going to accelerate exponentially. You shouldn't be thinking about "robots taking welding jobs." You should be thinking about "robots figuring out such advanced materials science that welding is no longer necessary"

Anyway, my plan is to hope our AI overlords really like paperclips and become really good at talking about paperclips to amuse them.
 
Last edited:
The question is really when do these things become more economical than just hiring some dude and the way things are going on both ends the technology would need to become a lot more efficient before it's really worth it. Most of AI stuff will stay virtual, the move to the real world will take a while.

But yes, a surprising amount of real-world things people don't realize are already been basically designed by algorithms and "AI" with little human input. We will eventually reach a point where there are entire generations of technology humans neither designed nor really know how they work on a low level. Look into even very simple neural networks formed through genetic algorithms and selected by fitness. Beyond a certain (very low) level of complexity, it's actually really hard to figure out how exactly they work, even if they work well for the certain task they were created for.
 
Last edited:
  • Feels
Reactions: seri0us
Back