[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y ] [Home]
4chanarchives logo
I've started learning C++ as my first programming language
Images are sometimes not shown due to bandwidth/network limitations. Refreshing the page usually helps.

You are currently reading a thread in /sci/ - Science & Math

Thread replies: 62
Thread images: 5
File: 1051.png (4 KB, 340x340) Image search: [Google]
1051.png
4 KB, 340x340
I've started learning C++ as my first programming language three months ago. I didn't have any programming experience before that, and until now it is still all kind of blurry.
My question is: how do you start thinking in programming language, so you can solve problems?
I could say that I kinda understand the overall look of how programming looks and works like, but I just can't start thinking in the way so I could solve problems. If someone else told me the solution, I would be like: "oooh, yeah that's totally easy!" But I can't seem to come up with solutions on my own yet.
I understand how if statements, loops, functions, arrays and structures work - this is what we learned in school so far.
How was your first experience with programming? How long did it take you to just "get" it?
>>
>>7745870
If you have to ask. You're not cut out for this. Perhaps a mcjob is more your speed?
>>
>>7745874
thanks fag i just want to talk about it
>>
>>7745870
Start of by solving trivial problems and move from there. Make a random name generator that just puts together names from a list of first and last names then move onto something slightly more difficult like making a minesweeper that works in your terminal by taking the coordinates of the place you picked. Its all practice, no matter how simple the problem may seem. You'll eventually see patterns and how to solve some primitive issues as they arrive.
>>
>>7745879
Thank you! Up until now I was only listening to what professor told us, I wasn't really doing anything on my own in my free time and I think this is the main issue, only homeworks. Doing it for somewhere around 4 hours a day should give me some progress.
>>
>>7745889
I used to tutor c++ and the most common problem I saw was that people had all the prices but they just could use them to form a solution. It takes practice more than you can learn in a class room. Practice a little bit every now and then 30min - an hour a day is good for a beginner. After a while it gets easy
>>
>>7745870
>how do you start thinking in programming language, so you can solve problems

There's no quick way. Just keep at it until it becomes natural and always remember that the computer is a retarded uneducated child. Unless you explicitly tell it what to do, it will never figure it out on it's own.

>How long did it take you to just "get" it

The 2nd semester data structure class.
>>
File: 12904781290384712351.jpg (9 KB, 183x200) Image search: [Google]
12904781290384712351.jpg
9 KB, 183x200
>>7745870
>three months ago...still all kind of blurry
>how do you think...so you can solve problems
>I can't think in the way to solve problems
>If someone told me the solution...i would get it
>I can't come up with solutions on my own yet
Critical thinking is not for you, find something else to do with your life. Takes me a few hours to learn any language after looking over the syntax. Takes me the same amount of time to solve any problem and articulate it into an actual program after pen/papering it.
>>
>>7745870
You 'get it' after you have solved many problems on your own and developed your own way of thinking about them. Think of or find some challenges online and solve them. Starting from the easiest. The closer the tasks will be to your personal interest the more enthusiasm you will have to implement them and the less dull it will be. To solve difficult problems you sometimes have to think for long. You don't just sit down and start programming it. You might think about it for hours or days, and not while your programming but while you are doing other stuff like walking or taking a shit etc...
Google 'programming challenges' . There are endless lists of tasks and problems that you can start solving. Also, if you are into stuff like simulations or robotics or what not then you can learn how to use a graphical framework like box2D for cpp and learn tonnes of stuff from trying to program various things.
>>
>>7745940
> Any problem
You stand ankle-deep on the beach and boast about having explored the depths of the ocean. Also, if you already know 4-5 languages then it is very easy to learn a new one.
>>
>>7745874
>>7745940

Learning to code for the first time is hard for everyone. It only look highly trivial in retrospect, but neophytes need time to get used to listing out every computational step in autistic detail.
>>
File: challenge.png (302 KB, 1920x1080) Image search: [Google]
challenge.png
302 KB, 1920x1080
>>7745879
>>7745893
>>7745930
>>7745947
Just like they said, it takes practice. Try some of these starting from the easy ones. Skip the ones that look boring to you, but try ones you would find interesting/challenging.
>>
>>7745870
OP what you need and nobody is telling you is modeling.
Pick up UML or some similar shit, it's very simple to understand and use.
You need to start thinking like an engineer.
What is the problem I need to solve
What are the needs
What are my inputs
What are the outputs
What are the constraints
How do they translate in what I will do
What classes do I need? Do I need to add one?
What attributes do I need
What functions do I need
Do I need to write libraries or can I use already existing ones

You can even automatically generate the structure using this and UML (for example), and your job afterwards is to do the algorithmics part (creating or using the right functions), the testing etc
>>
There is good news OP. If you actually learn C/C++ you will be able to learn any language. These two language alone are the base code for nearly every language to date.

Take R for example, which a lot of /sci/fags use. Written mostly in C and runs slows as hell, especially for idiots who use things like for loops. The reason loops run slow in R is due to embedded C functions which themselves contain loops. So, this increases runtime, because noobies to R who do this are making nested loops without realizing it. All my R scripts contain no loops what so ever, it's forbidding by the pros.

There are many other examples of languages which build upon C/C++, because the runtime is so damn good.
>>
>>7745870
>How long did it take you to just "get" it?
kind of a while honestly

it's hard to say how to just "get it". for me, it came after doing a lot of programming exercises.

you start to learn the workflow necessary to program - you break the problem down into small pieces, and you solve those pieces one at a time.

you also start to learn the basic questions - how do you store the data, what parts of the data are important, how are you going to manipulate the data.

it helps to know the basic data manipulations performed by almost all languages.

>>7745978
>especially for idiots who use things like for loops
let's not rehash that old bullshit

loops in R are slow if you're doing something stupid like calling vectorized functions point by point. if you're calling a vectorized function in a loop in a case where that's actually necessary, the R overhead is minimal

there's plenty of times when loops in R are necessary because there is no vectorized or efficient way to move over the data
>>
>>7745991
>overhead is minimal
>no efficient way to move over the data
I don't know about you, but I only use R for big data and "minimal overhead" adds up fast when dealing with stock market modelling and big government data downloaded/sorting. If you using a for loop in R, you doing it wrong lad.
>>
>>7746019
I use R for analyzing datasets at the terabyte scale.

When I talk about cases where there's no efficient way to move over data, what I mean is cases where you have loops where the state of each individual loop is somewhat dependent on the state of previous loops. Unless you abandon R entirely and move to strict C code, there just isn't a way to avoid using loops in that case.

In my typical use cases, that usually involves things like scanning over high throughput sequencing reads and keeping track of the overall state of the scan - operations that just can't be encapsulated in any single function in R without leaving R entirely and writing my own low-level compiled function
>>
>switch to python
>you're welcome
>>
>>7745958
This. Being able to plan and perform the transistion of a problem to its solution is what makes a programmer a good programmer.
>>
>>7745958
>UML
UML?
>>
>>7745870
Try Python, it's really easy to read and learn.
>>
>>7745889
forget about lectures

learn it online
learncpp.com is where I learned it

you can also search around for some programming courses that cost $. you get assignments, hand them in and recieve feedback
>>
>>7746886

No webpage is as good as a good book for learning programming.
>>
>>7746859
https://en.wikipedia.org/wiki/Unified_Modeling_Language
>>
It's just experience. Stick with it, and eventually you'll see results.
>>
>>7746926
Which books would you recommend?
>>
>>7747014
Programming: Principles and Practice Using C++ by Stroustrup
Data Structures and Algorithms in C++ by Drozdek
>>
>>7747028
Would you recommend reading those books to someone without any real practical knowledge of C++, or would first be better to "understand" how it works before reading them?
>>
>>7747035

The first book is aimed at beginners to teach them how to program and uses C++ to do that. The second book is aimed at transitioning you from doing simple programming exercises to solving actual problems once you get the basics of programming (conditional, loops, functions, arrays, pointers, memory allocation, classes, templates) down.
>>
>>7745952
>Learning to code for the first time is hard for everyone.
This is bullshit told to retards to make them feel better
>>
It might help to solve a wide variety of math and physics problems.

Once you get used to solving problems in that domain, it makes it easier to learn to solve problems in another domani.
>>
What would be the best programming language to start with and why?
>>
>>7747203

Assembly language.

You need an introduction to the level at which the processors work. If you learn that well, the other languages make more sense.
>>
>>7747203
If you're non-technical, Java. It's the McDonald's of languages; everybody uses it and nobody likes it all that much. However, it does a lot (too much IMO) to protect you from doing the wrong thing and there are plenty of resources out there.

If you're technical, C. If you can cope with pointers and manual memory management, you will have a basic grasp of how the underlying hardware works, which puts you ahead of 90% of the "programmers" out there.
>>
>>7747203
Joel, the cofounder of Stack Exchange posted an answer to this question, but I'm too lazy to look it up right now since I'm on my phone. He recommended that someone new to programming first read The Code Book (not the crypto one), then read SICP (learning Scheme along the way) and lastly K&R, where you'll learn C.

After that, you should have a good enough foundation to tackle any programming language.

Not a very exciting path (I doubt most beginner programmers have the discipline or motivation to do it), but it's a good thing to do once you can think algorithmically. I'd probably suggest learning a bit of C#, Java, or maybe Python to get a good feel for what programming is like, and then dive right into what Joel suggested.
>>
>thinking in programming languages
nigga you dont
programming is all about problem solving, about how to break down a problem into small pieces
if you dont know how to do it, you never will
>>
>>7747203

C++11, very little boilerplate and it doesn't hide details/does magic in the background (if you don't want it to) that makes it easier to understand. There is a lot of depth to it but you don't need to explore the bottom of the ocean to learn how to swim.
>>
>>7747168

It's like riding a bike or walking, it's only easy in retrospect.
>>
ejfxmnksmld.,as
>>
>>7747242

Java is only liked/viewed as easy because you can make ZERO progress in solving a problem but gain plenty of "partial credit" for writing down dozens of lines of generic boilerplate.
>>
>>7747206

Topp kik
>>
>>7747324
There's no partial credit in the real world, kiddo.
>>
>>7745957
100 - Compute the determinant of a matrix
>>
>>7747470
The world isn't black and white, kiddo.
>>
Euler project. I wouldn't learn python, java, or other big languages. They're geared toward something specific. Programming is problem solving which is why /sci/ always say learn proofs. Its literally programming on paper. C/C++ are the parents of programming that what you need to learn after learning how to problem solve.
>>
File: CS.jpg (96 KB, 650x369) Image search: [Google]
CS.jpg
96 KB, 650x369
>>7747470

Which is why absolutely no one wants to hire CS majors.
>>
>>7747526

Proofs are (countably) infinitely harder than programming, this is a proven fact.
>>
>>7747526
Euler is not a very good platform to learn programming. In my experience it's a great way to learn about mathematics, but if you want to produce the "non-naive" solutions you already have to have a decent basis in programming with at least two languages of different paradigms (for Euler: imperative and functional do the job reasonably well).

C is also geared toward something very specific. Namely: systems programming. Great stuff if you plan to work on OS, firmware, drivers (embedded in general) etc.. Perhaps not so great for higher level applications programming.

And C++ IS one of the two big languages whereas Python despite the rigorous shilling is still used mostly as a scripting language.
>>
>>7746886
This is terrible advice. His professor will make tests and assignments that assume everyone is familiar with the lecture material, not the material on that site. It may be a useful resource for doing stuff on his own but just saying "forget lectures" is idiotic.
>>
>>7747579

I always see programming as somewhat similar to making a constructive proof to a theorem. The theorem, of course, is the problem you are trying to solve.

Most programming fails miserably at "proving the theorem".
>>
>>7747579
Proofs are hard at first because you need to learn inductive reasoning. Its counter-intuitive to our biological programming of deduction. But proofs and programming go hand in hand.
>>7747582
I will admit Euler is not easy and no one should feel bad that you can't do one problem. But its a great way to learn. C is the goal if you want to work in something very technical and not just your typical code monkey stuff in web dev or apps. I would say the perfect middle ground is C++ because its literally the basis for windows and its other applications. Python is great for calculating huge numbers for data modeling in science. Its considered a companion to C/C++. I would avoid java because its so fucking shit. The language itself assumes way too much and pisses off a lot of technical staff. I blame Oracle for shilling Java to the world. Their entire product line was shit before they bought sun micro systems and getting the rights to Java.
>>
>>7747640
>C++ because its literally the basis for windows
The basis of Windows is C and iirc the standard used in Windows programming is still C89.
>>
>>7747692
>C89.
No wonder they'er still getting viruses. That shit is archaic.
>>
>>7747704
The reason Windows users get viruses is not C coding standards, but the users themselves.

polite sage
>>
>>7747709
>which is easy because of C and stupid windown users.
>>
>>7747715
>which is easy because of C
And the kernel of linux (and most of user land) is written in...
>>
>>7747608
fuck off underage b&
nobody cares about grades

more importantly, if you learn c++ you will easily crush shitty university level problems
>>
>>7747754
>fuck off underage b&
>proceeds to do just that
>>
>>7747314
Is there an NSA encoded message here?
>>
>>7745870
Idk OP

I started programming when I was really young, in the fifth grade. It just makes sense. Keep programming until your brain begins to work that way.

And for God's sake, make sure you use loops when you should.
>>
>>7749567
no:
cout<<"no! \n\a";
goto no;
>>
File: BASIC Programming.png (31 KB, 1453x204) Image search: [Google]
BASIC Programming.png
31 KB, 1453x204
>>7749621
I really like BASIC, It was my first language
Thread replies: 62
Thread images: 5

banner
banner
[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y] [Home]

All trademarks and copyrights on this page are owned by their respective parties. Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
If a post contains personal/copyrighted/illegal content you can contact me at [email protected] with that post and thread number and it will be removed as soon as possible.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com, send takedown notices to them.
This is a 4chan archive - all of the content originated from them. If you need IP information for a Poster - you need to contact them. This website shows only archived content.