Programming thread

On the topic of normies being unable to program, my alma mater used to do research on this topic. They gave everyone coming into CS1 a test (no credit attached, just for fun) to gauge how 'ready' they were to complete an introductory computer science course and also to gather data used in CS education research.

The subject matter of that test? Variable assignment. There actually weren't specifically wrong or right answers. Rather the metric used was whether or not a prospective student could form a consistent mental model of variable assignment. It didn't matter if the semantics you settled on matched a specific programming language, but rather whether or not you could mentally model the transformation of variables throughout the lifecycle of a program in a way that kept to the same logic from one question to the next.

Anyway, anecdotally every dude I knew who did poorly on the test later dropped from the program so I don't think it was complete bullshit.

EDIT:
To give you an example of the kind of questions you saw on it -

1. What is the value of i at the end of this program? Note - the '--' operator decreases a variable's value by one.
i = 11
j = i
j--

a. 11
b. 10
c. 12
d. None of the above

2. What is the value of y at the end of this program? Note - the '++' operator increases a variable's value by one.
x = 5
y = x
x++

a. 5
b. 6
c. 4
d. None of the above

For the above two questions, the 'correct' sets would be either (a, a) or (b, b). Other combinations would be incorrect - the key is to either model assignment happening by value or assignment happening by reference and stick to it throughout the entirety of the test. It was thought (and I'm not sure how much current research has verified this) that the ability to mentally model the transformation of data within a program is the critical 'secret sauce' required to be a programmer.
 
Last edited:
The problem with that is then they see something like "x = x + 1" and their brain breaks because "x can't be two different things." You have to deprogram them of what they actually learned about variables in algebra.
From what I remember from university, teaching people static single-assignment form didn't seem to make them any less confused. Most of the students I remember could understand that variables can change value, but the struggles were (in order): telling the difference between a pointer to something and the thing itself, and recursively defined functions / proof-by-induction.
 
From what I remember from university, teaching people static single-assignment form didn't seem to make them any less confused. Most of the students I remember could understand that variables can change value, but the struggles were (in order): telling the difference between a pointer to something and the thing itself, and recursively defined functions / proof-by-induction.
For me pointers were difficult but didn't take too long to understand. What really got me, and still gets me, is trying to read code where pointers are constantly being referenced, dereferenced, passed to a function and then dereferenced, doubled, partially dereferenced from a double to a regular pointer, etc. It's a linguine nightmare and I absolutely hate trying to parse other peoples' C/C++ because fucking everyone does it for no reason.

Sometimes it feels like programmers force pointers where they don't belong simply because using pointers makes them feel more programmer-y.
 
Sometimes it feels like programmers force pointers where they don't belong simply because using pointers makes them feel more programmer-y.
I think it's more that C needs pointers for a lot of things where other languages get by without. Want to pass by reference? That's a pointer. Want multiple return values? That's a pointer. Want to pass an array? That's a pointer. Want to return a struct by value? That's (usually) a pointer.
 
For me pointers were difficult but didn't take too long to understand. What really got me, and still gets me, is trying to read code where pointers are constantly being referenced, dereferenced, passed to a function and then dereferenced, doubled, partially dereferenced from a double to a regular pointer, etc. It's a linguine nightmare and I absolutely hate trying to parse other peoples' C/C++ because fucking everyone does it for no reason.

Sometimes it feels like programmers force pointers where they don't belong simply because using pointers makes them feel more programmer-y.

There's a cost to dereferencing a pointer, so I doubt many people are doing it for no reason.

Pointer hell is the reason why I try to use references in C++ if at all possible - it's the same thing under the hood, but looks far more readable.
 
Same reason the average Java dev needs three factories to write an app that adds two numbers together, I suppose. Simplicity is hard and it's easy to say "I'll clean this up later" forever.
We're pretty dumb like that. Most java codebases I've been assigned to have the constant aura of being a messy prototype, and I'll often find myself spending more time refactoring code than implementing features.
 
I've been doing some research into what websites use for payment processing and a name that comes up alot is "Stripe". Can someone explain to me what it is, how it works, and how to learn it. Every video that claims to teach how to add it onto your website is by an indian guy and is like 7 years old. I want to make sure I dont leak my future users credit card information ya know.
 
I've been doing some research into what websites use for payment processing and a name that comes up alot is "Stripe". Can someone explain to me what it is, how it works, and how to learn it. Every video that claims to teach how to add it onto your website is by an indian guy and is like 7 years old. I want to make sure I dont leak my future users credit card information ya know.
It's a payment processor company meant for programmers to just plug in their app and not care about the rest of payment details. You don't store any credit card information, only Stripe does. For basic stuff it should be easy enough to read the docs.
 
It's a payment processor company meant for programmers to just plug in their app and not care about the rest of payment details. You don't store any credit card information, only Stripe does. For basic stuff it should be easy enough to read the docs.
Their fees are super fucking high though.

Depending on expected transaction volume and revenue it might be worth it to just start a big boy merchant account.
 
Is using ChatGPT bad if youre learning? I've tried using stackoverflow but its so confusing for me. Meanwhile with ChatGPT it breaks down what went wrong with my code and gives a solution in which i learn something. I guess im just worried im not a "Real Programmer" if i use ChatGPT and it will teach me bad habits for programming.
 
Is using ChatGPT bad if youre learning? I've tried using stackoverflow but its so confusing for me. Meanwhile with ChatGPT it breaks down what went wrong with my code and gives a solution in which i learn something. I guess im just worried im not a "Real Programmer" if i use ChatGPT and it will teach me bad habits for programming.
ChatGPT can be correct but when it's wrong it's an extremely great bullshitter, and if you don't know enough then you can't tell when it's bullshitting and when it's correct. I'd say it's okay to use it but you should always check its answers.
 
Finally wanted to try out an AI code generator plugin for VS Code and found out that ChatGPT Plus doesn't give you access to the OpenAI API. :(
Some plugins say they don't require API keys, but I don't know if they're any good.
Anyone have any experience with those AI plugins? Any recommendations?
 
ChatGPT can be correct but when it's wrong it's an extremely great bullshitter, and if you don't know enough then you can't tell when it's bullshitting and when it's correct.
Pretty much. From a language point of view, it knows syntax but not semantics.

It's good for easy shit. Do not ask it anything more involved. It will start hallucinating.
 
  • Agree
Reactions: Markass the Worst
Is using ChatGPT bad if youre learning? I've tried using stackoverflow but its so confusing for me. Meanwhile with ChatGPT it breaks down what went wrong with my code and gives a solution in which i learn something. I guess im just worried im not a "Real Programmer" if i use ChatGPT and it will teach me bad habits for programming.
I wouldn't worry about bad habits at this point. Instead, I would worry about writing a program that achieves the desired goal and then perhaps asking for feedback about whether it could be better. It's fine to be assisted doing that but to solidify the understanding I'd suggest writing the same program or method from memory maybe a week or two later and seeing how you compare.

Modern language teaching theory is somewhat similar - a good teacher won't get hung up on grammatical problems or mispronunciations when teaching a beginner. Instead, they focus on using language to achieve a goal such as asking for directions, making reservations, ordering at a bar, etc and building confidence in that way. They only correct you when you say something totally wrong.

ChatGPT is an amazing tool for learning programming and I wish I'd had it when I was learning. I use it myself when reading code in a language I don't know well - if you already know one language you can get your answer about the language you don't know translated into the language you do. While it does come up with some pretty crazy bullshit sometimes, at least it doesn't smugly say "well why would you want to do it like that anyway? Just google it noob."
 
Finally wanted to try out an AI code generator plugin for VS Code and found out that ChatGPT Plus doesn't give you access to the OpenAI API. :(
Some plugins say they don't require API keys, but I don't know if they're any good.
Anyone have any experience with those AI plugins? Any recommendations?
Actually, nevermind.
I just got whitelisted for Copilot Chat. Thought they'd take more time to accept new users.
 
For me pointers were difficult but didn't take too long to understand. What really got me, and still gets me, is trying to read code where pointers are constantly being referenced, dereferenced, passed to a function and then dereferenced, doubled, partially dereferenced from a double to a regular pointer, etc. It's a linguine nightmare and I absolutely hate trying to parse other peoples' C/C++ because fucking everyone does it for no reason.

Sometimes it feels like programmers force pointers where they don't belong simply because using pointers makes them feel more programmer-y.

I've been coding for years but I still don't understand pointers. I mean I understand what they are but I have a hard time coming for a rationale to use them. All of the newer languages within the past couple decades seem to be getting rid of them or at least transforming them into something different so maybe I'm on the right track.
 
I've been coding for years but I still don't understand pointers. I mean I understand what they are but I have a hard time coming for a rationale to use them. All of the newer languages within the past couple decades seem to be getting rid of them or at least transforming them into something different so maybe I'm on the right track.
A pointer is a location in memory. A value is the data in that location in memory.

For example, a character is stored at 0x00000001 in memory. The pointer is the value of 0x00000001. The compiler knows that a character only takes up one byte of data. When you dereference a pointer you are loading the one byte at that memory address. When you set it you are writing something to that specific address. Each class has a datamap to determine the location of values and pointers. The compiler knows how much space it takes up and how to get values values based on the pointer. For example, a class with two chars stored in memory 0x00000001 will know that char1 is at 0x00000001 and char2 is at 0x00000002. When you pass a variable in that class by value, the program does the heavy lifting, and determines the address of the variable based on that map and then loads the value from it.

When you make a call to a function though things get more interesting. The computer then finds an address in memory and loads all of the variables you pass in, into a stack of variables packed together into memory side by side. Any other variables made during the function are also stored on that stack. The function then operates on them. When the function exits, a value is written to a register on the CPU. You lose the address of where the function started storing its values when the function exits. When you return back a pointer initialized in a function, you are putting the address of that value into a register on the CPU. You then use that address just like you would any other pointer.

Tl;Dr: Pointers are used when a program needs access a data in context outside of the current scope of where it is operating. A called function has no idea where the calling programs data is stored in memory. Similarly the main program has no idea where the address of the functions stack begins and thus cannot read data from it. You use pointers to let either of them know where the other is.
 
Last edited:
Back