C Programming: What's Next After Learning C?

  • Thread starter Thread starter Drakkith
  • Start date Start date
Click For Summary
The discussion revolves around the practical applications of C programming and the transition to learning C#. The original poster expresses frustration with their limited exposure to real-world programming scenarios, having only worked within Visual Studio and basic text-based interactions. Suggestions include deepening their understanding of C by applying it to personal interests, such as astrophotography or game development, and exploring graphics programming with OpenGL. Participants emphasize the importance of mastering C concepts like pointers, memory allocation, and data structures, as these skills are foundational for programming in any language. They also recommend using Integrated Development Environments (IDEs) like Eclipse or NetBeans for better programming experiences. The conversation touches on the value of practical projects, such as simulations or automation tasks, to enhance programming skills and understanding. Overall, the consensus is to focus on applying C effectively before moving on to higher-level languages like C#.
  • #31
Most of my data collection, numerical modeling, and analysis programming has been done in C, with a bit of Fortran and LabVIEW mixed in for good measure.

The best follow-up on a programming course for a physicist is likely a numerical analysis type course, likely taught in the math department.

I've written code for real time data acquisition, Fourier analysis, integrating differential equations, and lots and lots of other stuff.

Expand that tool box.
 
  • Like
Likes Drakkith
Technology news on Phys.org
  • #32
Have you written the recursion program for "Newton's method" yet?
It's a good one.
 
  • #33
I'm surprised no one has mentioned Python. I'm learning Python now as part of my grad school curriculum but I chose it initially to do cool physics visualizations ala VPython simulations I found on this guys channel:



A guy that works in my lab has also encouraged me to learn Java. Matlab is good to know too.
 
  • Like
Likes jedishrfu and Drakkith
  • #34
OmCheeto said:
Have you written the recursion program for "Newton's method" yet?
It's a good one.

I get several different hits for that when I search for it. Which one are you referring to?
 
  • #35
DiracPool said:
I'm surprised no one has mentioned Python. I'm learning Python now as part of my grad school curriculum but I chose it initially to do cool physics visualizations ala VPython simulations I found on this guys channel:



A guy that works in my lab has also encouraged me to learn Java. Matlab is good to know too.


Python wasn't mentioned because the thread topic is about doing something in C. Drakith could write some C code that interoperates with Python, Java, MATLAB or Julia as an interesting use of C.
 
  • #36
This thread is going everywhere. To your disadvantage, IMO.

Bottom line - as some folks politely pointed out:
1. You have been exposed to C. That does not mean you can program well - undefined behavior comes to mind here.

Great advice! :
2. Do not go learning the syntax of another language - especially just because people here like it.

Follow the advice already given multiple times:
3. Find something to build your skill set. If nothing else learn some algorithms expressed in C:
Try: http://rosettacode.org/wiki/Category:C -- several hundred algorithms. Good algorithms are absolutely key. Period. Some on the page may be over-simplified
 
  • Like
Likes phinds and Drakkith
  • #37
So it seems this thread has run its course.

However by popular demand it is now open for more ideas for Drak.
 
Last edited:
  • Like
Likes Drakkith and jim mcnamara
  • #38
Depending on how much you like puzzles there are challenges like those listed on projecteuler.net
One thing you will learn (this is my view on the matter) from that is how to work with big numbers and how to use maths to avoid overhead.

I don't really know the quality of the challenges at hackerrank.com but I see promising sections like data structures.
It contains linked lists, trees, sparse arrays, ...

Sparse arrays are a nice thing to think about. Suppose you have huge arrays representing a grid. Most of the entries are zero.
How would you save such an array? (there are a lot of ways)

Ultimately I would say you just need to find something that's interesting to you.

One final note, when I was doing a course on Monte Carlo simulations I found it incredibly useful to integrate GNUplot in my code.
This way I got the plot immediately. I'm not sure how easy this is on windows but on linux it took but a few lines (it also helped to understand pipes a little better).

Another thing I implemented back then were named arguments i.e.

Code:
./Simulation -s 10000 -N 500

Here the "s" argument would signify the number of steps (typically a lot more) and "N" the number of particles.
The big advantage of this approach is that you don't have to remember a specific order for the parameters.
With a "help" option it becomes even easier.
 
  • Like
Likes Drakkith
  • #39
After a basic course in C and provided that you like this language, my recommendation is:

- Learn about algorithms and data structures. This is the real "working engine" for any program. I highly recommend Robert Sedgewick's "Algorithms in C".

- Learn about C libraries (Standard and many others contributed) and become well acquainted with pointers and memory allocation concepts. If you can't make your machine throw up, you have not learned enough C.

- Learn to use even the modest tool to do your job. Back when I learned C, we were forced by the professor to use various simple editors, so to focus on language and not on IDE's - what existed back then anyway, bells and whistles. Now, it is an absolute necessity to use some decent IDE to do your job but if you know C (or any language for that matter), it is just a matter of getting used to.

- Try to make a whole world ticking through the command line first. Full blown applications with candy GUIs, come second.

- Choose between going "low" or "high". I'm not particularly exposed to low level programming but I think that going "high" gives much more opportunities to get decent programming skills, taking into account the bunch of languages you can migrate to and the bunch of kinds of applications you can develop.

- If you want to take a really big dive into C world, then get into the inner world of some Linux distro (you name it), however "deep" in the system you like.

- Get into the C++ world as well, for an overdose of hard times in programming which will pay millions in programming experience.

I did not say anything new, most of these have more or less already been mentioned in the thread, but this is my opinion, based solely on my own programming experience. In short, don't just use C for scientific purposes: go for being a top - notch programmer too!
 
Last edited:
  • Like
Likes Drakkith
  • #40
Drakkith said:
Any suggestions for a guy with no money?
A friend of mine has written a system to predict the English Premier League football scores. Albeit with limited success.

If you could do better, you could perhaps make some money from the unsuspecting bookmakers.
 
  • #41
Checkout Rosettacode.org and see if you can implement any of the examples better and learn how others solved the same problem.
 
Last edited:
  • #43
I was teaching "Programming 101" and my last lecture/task to students before exams used to be to write a N-body gravity simulator. It's not too hard, and let's them see how they created something rather cool.
 
  • Like
Likes Drakkith
  • #44
Thanks to everyone for their suggestions. Even if I haven't quoted or liked your post, I assure you that it's been very helpful!
 
  • Like
Likes jedishrfu and Dr. Courtney
  • #45
Drakkith said:
So I'm about to be done with my first class in programming where we learned C programming. Unfortunately, I don't actually know what you can do with it. All of our programs in my class have involved us programming and running everything using Visual Studios, not developing standalone executables or something. The only way we've had our programs interact with the 'outside world' is through the keyboard and screen or through text files.

To be honest I feel like I've been trained to use a lot of specialized tools but don't have any use for them. Perhaps like a carpenter with no wood and no work.

Thanks.

Given your interest, I suggest looking into the world of embedded systems. It's a huge part of the computing world. You can control an external device using a microcontroller which you can program in C. For example, you can control a robot arm. This is just one example. Think about scientific instrumentation. Medical devices is another example. Pacemakers for example. How about drones? You get the idea.

There is no need to learn numerous programming languages in order to do something useful. Lots of people make a living programming embedded systems in C or maybe C++ with perhaps a bit of assembly language as well. I would think about that and also about learning more about algorithms and data structures.
 
Last edited by a moderator:
  • Like
Likes OmCheeto and Drakkith
  • #46
According to me C programming is the basic of all programming languages. Once you have learned C programming, you will be very comfortable with other languages to learn. You must try to learn Java programming.
 
  • #47
Juanita Smith said:
According to me C programming is the basic of all programming languages. Once you have learned C programming, you will be very comfortable with other languages to learn.
While I agree w/ you, I have come to learn that that is JUST an opinion and not everyone agrees.
You must try to learn Java programming.
Why? I've been programming in various languages for 50+ years and have never bothered with Java. Why should the OP?

Besides, the OP is a bit slow and Java might be too hard for him :-p
 
  • Like
Likes OmCheeto
  • #48
phinds said:
Besides, the OP is a bit slow and Java might be too hard for him :-p

Well, looks like someone isn't getting their Christmas present this year...
 
  • Like
Likes phinds
  • #49
C is about as close as possible to writing directly in machine code without actually doing so, a compiler is used instead.
Every hardware system understands some implementation of C, higher level languages not so much.
Sometimes higher level languages generate C code, and that is what finally gets compiled as an executable program
 
Last edited:
  • #50
rootone said:
C is about as close as possible to writing directly in machine code without actually doing so, a compiler is used instead.
Every hardware system understands some implementation of C, higher level languages not so much.
Sometimes higher level languages generate C code, and that is what finally gets compiled as an executable program
I disagree. ASSEMBLY language is as close as possible to writing machine code without actually doing so. That in fact is why assembly code was invented. We got tired of remembering all those zeros and ones.
 
  • Like
Likes OmCheeto and Mark44
  • #51
True, I meant to say assembly language for whatever system it is.
Pure machine code is all 0/1 and might not even be written on a keyboard but might be input by physically toggling dozens of individual switches.
Does anyone anywhere actually do that these days?
 
Last edited:
  • #52
Drakkith said:
So I'm about to be done with my first class in programming where we learned C programming. Unfortunately, I don't actually know what you can do with it. . . . I don't really have any specific applications that I'm thinking of.

Nidum said:
Real world applications programming is a thousand times more challenging and more interesting than just shuffling fictional data sets around and doing pointless graphics .

I agree with Nidum above.

Beyond that, speaking as someone who many years back did a lot of script-based programming to aid with my work as a technical writer documenting software; as well as many automation routines just for my own enjoyment at home; who used to interview a lot of programmers; and who taught himself the rudiments of C for the fun of it; and did other DIY projects like write an entire shared editing website (back before shared editing became commonplace) for a team of writers on a book project, completely in objects in Python; but who doesn't program at all these days - to me, the disconnect you are experiencing seems directly related to not having any applications in mind, nor perhaps any interest quite yet in programming as a culture (e.g. how language design relates to purpose, for example, as Paul Graham once wrote about).

Which I admit surprises me. I would have thought that in a school setting, your profs would have laid out a general path or out-branching paths in terms of why and how to learn programming. And likewise I would have thought it a natural inclination to come up with some candidate applications that either interest you personally, or seem possibly relevant to your potential career path or paths; and then to take it from there. But perhaps this opening course in C was taught the way my freshman year English lit classes were taught long ago - by rote, very distanced, not much guidance?

Anyway C is just one language - very far from a stopping point or even necessarily something you need to get good at right away; the point is that having learned a little bit about C, learning your next language ought to be easier. Play with C if you think you'd enjoy it; otherwise I'd suggest getting on with finding applications. You can do that by learning one or two more languages; this makes it more likely that at some point you will experience serendipity, i.e. learn about potential applications which are interesting and/or useful to you. Hardcore programmers used to be obsessed in maximizing efficiency with really frugal algorithms and I imagine there must still be some of that aspect today in some areas, in other words really geeky math-driven approaches; meanwhile, cheap fast hardware long ago opened up scripting. All in all programming always seemed more like play than work; so you could think in terms of playing around, experimenting.
- - -

P.S. Back when I was still doing freelance editing, I edited a textbook on programming for biologists - Python for scripting, various tools available in the Linux shell, and Arduino for field data: Practical Computing for Biologists, Haddock and Dunn. It's not anything to do with physics, but but a glance at the table of contents via https://www.amazon.com/dp/0878933913/?tag=pfamazon01-20 does demonstrate that a programming language by itself is just a small part of what computing in science is about. If you're a carpenter, you're going to want more than a single hammer to build something with.
 
Last edited by a moderator:
  • Like
Likes Drakkith
  • #53
rootone said:
True, I meant to say assembly language for whatever system it is.
Pure machine code is all 0/1 and might not even be written on a keyboard but might be input by physically toggling dozens of individual switches.
Does anyone anywhere actually do that these days?
I doubt anyone does now but I did it when I was starting out.
 
  • #54
phinds said:
I doubt anyone does now but I did it when I was starting out.
Me too when i got my first micro, MITS Altair 680 with the motorola 6800. The computer had a bank of toggle switches for addressing and data and it took forever to enter a program didnt work. I tried to light up the leds with a pattern but it just didnt do anything.

http://www.vintage-computer.com/mitsaltair680b.shtml

I was tempted to buy a televideo mterminal and use the onboard tty monitor program via rs232 but it was not cost effective at $700 for the televideo. I eventually went with the trs80 from radio shack.

http://www.vintage-computer.com/trs80mod1.shtml

In hind sight the MOS KIM 1 6500 system board was a better deal but i was out of money by then. Programming for it was in hexidecimal

http://www.vintage-computer.com/kim1.shtml
 
  • Like
Likes OmCheeto
  • #55
UsableThought said:
I would have thought that in a school setting, your profs would have laid out a general path or out-branching paths in terms of why and how to learn programming.

Lord, no. I only took the class because I needed "programming experience" before taking a Digital Logic class later on. There was absolutely no information given to us about branching out or anything else like that.
 
  • Like
Likes OmCheeto
  • #56
Drakkith said:
...There was absolutely no information given to us about branching out or anything else like that.

I can see now, that you are on the path, young Drakkths.

Acknowledging the landing of the flock of impending black swans, is a sure sign, that you are on the path, to... the dark side...

Code is your father...
 
  • Like
Likes Drakkith
  • #57
Drakkith said:
So I'm about to be done with my first class in programming where we learned C programming. Unfortunately, I don't actually know what you can do with it. All of our programs in my class have involved us programming and running everything using Visual Studios, not developing standalone executables or something. The only way we've had our programs interact with the 'outside world' is through the keyboard and screen or through text files.

To be honest I feel like I've been trained to use a lot of specialized tools but don't have any use for them. Perhaps like a carpenter with no wood and no work.

I've also considered learning something like C# and I'm just curious as to what the differences are in what you can develop with each one, if there are any differences of course. I know that C# is a much higher language than C, but the extent of my knowledge mostly ends there. If I'm not looking to develop blazing-fast programs for huge amounts of calculations, is C# a good choice? I don't really have an specific applications that I'm thinking of.

Thanks.

In C# you can create any application of software which is GUI based easily
 
  • Like
Likes Drakkith
  • #58
jedishrfu said:
Me too when i got my first micro, MITS Altair 680 with the motorola 6800. The computer had a bank of toggle switches for addressing and data and it took forever to enter a program didnt work.
Did it take more time or less time to enter a program that did work? :oldbiggrin:
 
  • Like
Likes jedishrfu and Drakkith
  • #59
Mark44 said:
Did it take more time or less time to enter a program that did work? :oldbiggrin:
Oh, entering the ones that actually WORKED took WAY longer :smile:
 
  • #60
phinds said:
Oh, entering the ones that actually WORKED took WAY longer :smile:
Isn't that the truth?

In your upcoming Insights article, you mentioned some of the early programming languages, one of them being PL/1. The first programming class I took was in 1972, with the language used being PL/C. The C in the name indicated that it was a compact subset of PL/1.

Although we didn't have to set switches on a console, writing code seemed just as arcane. We used a keypunch machine to make the IBM (or Hollerith) cards, added a few Job Control Langauge (JCL) cards at the front and back of our card decks, and submitted them. The computer operator would run the cards through a reader, which would transcribe the code onto a tape reel that was subsequently mounted on the actual computer. The results came back several hours later, or even the next day. Most of my early programs produced no recognizable output -- just many pages of what looked like gibberish to me (a core dump of the computer's memory). Ahh! The good old days!
 
  • Like
Likes jedishrfu, Borg and QuantumQuest

Similar threads

Replies
86
Views
1K
  • · Replies 8 ·
Replies
8
Views
2K
Replies
69
Views
9K
  • · Replies 10 ·
Replies
10
Views
4K
Replies
16
Views
3K
Replies
33
Views
3K
  • · Replies 58 ·
2
Replies
58
Views
4K
  • · Replies 15 ·
Replies
15
Views
3K
  • · Replies 9 ·
Replies
9
Views
3K
Replies
81
Views
7K