Is there any argument that C is a better beginner language to learn than Python?

Is there any argument that C is a better beginner language to learn than Python?

bump

it's old and antiquated but you'll probably learn a bit more about how to manage memory with it

Python is written in C

C teaches you program logic and memory management.
Python lets you feel like a programmer by gluing together other people's libraries and functions.
If you're persistent, you'll also learn how to write "one-liners", which are autistic concatenations of higher order python functions that exist only to stroke the writer's ego.

Would you say it's a waste to take a course on it if it's a pre-req for C++ at my college or should I just learn Java?

I did not know this. I was mainly curious because my programming logic course has us use python for like the last two weeks.

C++ is not even comparable to C.
The only thing they have in common is the backwards compatibility, which isn't even really worth it.

Python is written in C, and is used as an abstraction over most common tasks, including its dynamicity.

I believe it's essential to learn a bit of C as it can help you understand writing algorithms in general, however Python is the superior long-term language especially in terms of career.

I have a Python job myself and working with it professionally is much more productive and fun than C just because you're working with common abstractions rather than still memory/type managing.

> Is there any argument that C is a better beginner language to learn than Python?
Yes if you're (aiming to be) an electrical engineer.

> Would you say it's a waste
Personally, I find that it's not a waste. I started learning C++ without knowing C, and ended up not understanding a lot of things. So I went to learn C and have all my questions answered, and continued to learn C++ afterwards.

Personally, I just stick with Python and shell because they do what I need and there's still a lot about Python that I haven't learned yet. I do plan on learning C/C++ in the future though because they are great languages.

So you think it's a retarded that the college made it a pre-req for C++ while Java requires only programming logic?

C: steeper learning curve, better return on investment

Python: No learning curve, low return on investment

Of course.
You can learn C++ without C just like you can learn C without ever learning C++.

In real world usage, they're completely different.

also, my college has no stand-alone python course. Like I said, we use it for about two weeks in programming logic.

>Yes if you're (aiming to be) an electrical engineer.
I don't think I am. In fact, I'm not sure where I'm going with my career. Just going for a B.S. in CS.

>beginner

No. At least, learn the very basics (control & data structures, organization, etc.) with Python, so you don't have to worry about memory managment and you get a REPL. The whole compile-check-fix-cycle will make learning much slower.

Do eventually study a bit of C, though.

C used to be the introductory programming language for Computer Science.

>The whole compile-check-fix-cycle will make learning much slower.
There are so many ways to automate that, though.

Programming in python requires a wholly different kind of thinking than programming with C. With C, you need to know how computers operate, with Python you need to know how the libraries you are using are implemented. At least if your goal is best performance. Example: Integrate sin(x) from 0 to 1 numerically with a very naive rectangle rule [Note for people that don't know what that means: Sum sin ( i / N ) for i in [0...N] and divide them by N. ]

C:
#include
#include
#include

int main ()
{
const size_t N = 100; // Number of samples
double sum = 0.0;
for ( int i = 0; i < N; ++i )
sum += sin ( ( double ) i / ( double ) N );
printf ( "Integral of sin(x) from 0 to 1: %e", sum / ( double ) N );
}


Python:
import numpy as n

N = 100 # Number of samples
integral = n.mean ( n.sin ( n.linspace ( 0.0, 1.0 - 1 / N, N ) ) )
print ( 'Integral of sin(x) from 0 to 1: %e' % ( integral ) )


So, whereas in C you would really go through all values and sum them together, one after the other, the Python implementation first generates a vector filled with N values from 0.0 to 1.0, applies the sinus on all of them and then takes the mean of them (which only works in this case of course, not in general), all using numpy functions, which are probably not much slower than the C version (albeit using a lot more memory).

Having started with C and it was honestly hard at the beginning for me to get used to the "Python-thinking". It's actually not much different in C when you are using external libraries, but doing it from scratch anyway has just a very small penalty (or even no penalty at all), so you are not forced to use all kinds of obscure methods from your library to get stuff done, which can be very annoying.

I wouldn't recommend C as babies first language. However, once you are comfortable using some other higher level language (i.e. an advanced beginner to intermediate user with that language) I would highly recommend learning to use C to the same level.

After you've done that—even if you never use C again—you will have a much better understanding of what is going on below the hood of your chosen language. I'm not saying this will make a profound difference to how you program—certainly lots of fine programmers get by without even touching a low level language. But I do think you will be a better programmer for it and that it is worth the few days of effort.

Python is a way better beginner language than C.

If you want to be a great python programmer though, you have to learn C since python is written with C.

Python is a just meme, a toy language. C is a real programming language.

The average software developer should not be handling memory. The vast majority of software is not performance capped by allocations and memory limits. Even most video games pre-allocate and do no more.

The computer can handle memory better than you can in the most circumstances, and allocations/pointer dereferencing are 90% of what clutters up C code and makes it nigh-unreadable in cases. Python or Lisp are far better languages for first-time learners.

>numpy
So, why don't you use some math lib for C?

Because it's not needed to achieve close-to-optimal performance (given the language). If you'd implement the "C-way" 1:1 in python, you'd have absolutely horrible performance, that's why I used numpy. I basically tried to do it the way I would intuitively do it in both languages, just to illustrate how both approaches can be very different in those languages. Of course there's always a million ways to do this kind of stuff.

Many libraries in python are actually written in C/C++. Numpy is implemented in C, but the interface is implemented in python. Another notable library is opencv, which is also fully implemented in C++ and has python bindings.

If you go and implement, say, Haar cascades purely in python code, it will take less time to implement, but will run like shit.

If you implement the same algorithm in C, it will be fast, but to make the code stable, it will require a ton of work due to the fact you have to manage memory, pointers, handles, errors and all that fun stuff yourself.

Python is what it is, a scripting language. C is compiled and potentially the fastest. The point I'm trying to make, is that one should learn both, maybe even simultaneously. Then, when one is proficient enough in both, learn how to build python interfaces for C. In the end you'll end up having a tool to write fast efficient code, and a tool to easily use that code in a easily readable and logical form.

I'm doing an internship writing firmware for high performance storage servers in C, and I recommend all my CS friends learn to write good C code. C forces you to REALLY think about what you're doing and not take anything for granted. It makes you a better programmer overall.

There's a saying around my office that you can write C in any programming language. For Software developers, learning The C language is like learning Latin for a linguist

If you don't learn c first you will want to do things like you would in Python

So you're saying that C really makes you think.