Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Python

What is even python good at or use for?

What is python? i mean as i read somewhere python is like worse version and less powerful than C programming language. Python has fairly easy and friendly syntax and its much easier etc.. i think . But what is this useful ? whats the difference between C with a language that you can do everything and python ?

6 Answers

I dont mean to sound condescending but I probably will. Most languages will fall short when compared to C, so lets chuck them all out the window and lets use C for everything right?

python is a very powerful language and is preferable to C in many occasions

first off, a newcomer to programming can use python as an introduction to the subject as opposed to learning that much more daunting C. Readability and simplicity in python means new programmers can focus more on learning fundamental programming concepts instead of worrying about understanding the syntax.

python has built in libraries that will decrease coding time and increase efficiency of your software

python can be used as a scripting language, C cannot, which means python is better for web applications

the only advantage for C that I can think of is memory management, which allows you to build larger scale applications without worrying about performance

so unless you are building an operating system or a massive application such as photoshop, why would you not use python?

This view is very skewed, dangerous and not that helpful to new people, IMO. Being a language elitist helps no one. You know why there are so many languages? Because the authors creating new languages can't find one that fits their needs. No language is perfect. Yes, Python is well known as a very easy to learn language. That is a major selling point. It is also great for scripting. Again, point for Python. No, C can't be used for scripting because it needs to be complied, this is true. However, with Python, and not just with major applications, if you have somewhat complicated programs you are going to suffer a performance hit because it's being interpreted on the fly. You make the point that Python is better for web applications, what do you think the interpreters converting your Python code are written in? It's wholly unfair to say that memory management is C's only advantage. Actually, since you manually manage memory in C it's only as good as the programmer. What makes it perform so well is the low level at which you are able to provide commands to be converted into assembly and then into binary. To say that Python is the only choice unless you are writing an application like Photoshop that contains millions of lines of code is irresponsible and a disservice to new programmers. Please be more careful about what you state as fact in the future.

how did you get the impression that I am an elitist? I clearly state that most languages do fall short of C and I imply that they are all useful and have their place

I was talking about how good python is because this is the question here, is python necessary?

Based on everything you say after that first line, the line comes off as sarcastic and insincere. I'm sorry if that's not the way it was meant. However, I'm sure I won't be the only one who reads it that way so I want there to be a counter point to your point should new developers come along and think "Eff C! C is effing stupid! That guy in the forums listed like 10 reasons why Python is good and 1 reason why C is good!" Regardless of how you actually feel your final sentence seems to imply that if you aren't writing a huge program, the only acceptable language is Python, when this absolutely is not the case.

well, actually, if you read your own post, the only good thing you mention about C is indeed performance

when the program is small enough, the difference in performance between the two languages is arbitrary, so why would you choose C? actually, by using the python built in libraries, you can improve performance which would suffer in C because you would have to write the functions yourself

I am far from elitist, my goal is to be proficient in as many languages as possible, and I am always open to discussion.

it seems to me that python would outperform c in smaller applications, and even if it didnt, the advantages of using it would out weight the negligible difference in performance.

so I seem to be missing something which maybe you'd want to clarify

Main advantage of != only reason for. Don't be confused by me listing performance as the major advantage as it being the only advantage. I'll elaborate more tomorrow (I'm in the States). I'm tired, my birthday is over and I have work in the morning.

ok patrick, but if you are going to accost me for saying that performance is the only advantage that C has, maybe you should then go on to list other advantages

happy birthday btw

Thanks. I could have done without having had to deal with my car insurance company on my birthday but oh well (part of the reason I may have come off a bit abrasive).

tl:dr You also get the advantage of seeing how everything is working at pretty much the lowest level. You also have better control over things like byte streams and your platform in general.

Anyway, I'm not accosting you. You are taking my comments to be personal. They are not meant that way. Maybe the "language elitist" part was a bit personal, I apologize for that. However I will defend the position I took on the content of your posts. They appear very one-sided in favor of Python and make it seem like C has no good applications other than massive software engineering projects. We are a community of beginners. Therefore I feel that we have a responsibility to the community to attempt to provide the most accurate, unbiased information we possibly can.

You bring up very good points in favor of Python for a lot of things. I agree with many of those points which I stated in previous posts. As I mentioned in my initial post (I think) C is "close to the metal". Being close to the metal has its advantages. Not just performance. Though that is the most notable. You also have finer control over the system you are writing code for. For instance I can control individual buffers on a micro controller exactly the way I intend to. When you use Python or Wiring to program an Arduino, what's actually happening is your code is being converted to C then from C to assembly for the MCU. Yes, you can do this, and yes, it's easy. You have no idea how what's happening is happening though. You are at the mercy of whomever wrote that library, trusting that they are doing the task in the appropriate way.

Here's another example that will apply to almost everyone at some point. You want to connect from your piece of software to the internet or to a device on your network. You'll need to work with sockets. Most languages abstract this away which makes it nice and easy to work with. However, you don't have as much control of the byte stream as you might if you are doing the work with C. You have finer control over how to handle the data coming in deciding what to do from there.

This got longer than I had hoped so I'll end it here. To conclude, in addition to the performance benefits you also have the ability to directly control more of your environment, you are more aware of how certain things are being accomplished in your code (it's a plexiglass box instead of a black box) and you have better access to the very low level, raw data/information generated with certain tasks. These are just the ones that come to mind off the top of my head, I'm sure there are others.

By all means, have an opinion on which you like better, say "I like this one better", defend your opinion, but try to be fair about it. "I like XXXXXX because you can do this, this and this more easily but in all honesty you can do this in XXX that you can't in XXXXXXX ." Especially in a community such as Team Treehouse.

I wouldn't equate Python with C. Python is an interpreted language. It's used a lot for scripting. Writing code to automate repetitive tasks. For example comparing the contents of two folders on your computer. You can definitely write full programs in it but that's not an ideal use. C is great for systems programming. If you want to write a piece of software that runs on a server and runs very fast (because it's complied), C is a good language to do it in. C is a very low level language and considered "close to the metal". Meaning you have a lot of control over everything. It's fast but hard to master.

I believe C/Obj-C is hard to master , I'm on it my self and uh its a lot different than JS or Ruby or any other , although as from what i remember python is fairly similar to C as the beginning printf("Hello World"); i believe thats python and C is similar with missing some @ etc..

But over all , in C you could do what you do in Python and more right? as far as i read , so why bothering learning Python ?

I get the idea of what you wrote but i just don't get it , either what i read was messed up . But I'm really curious since it frustrates me as i started once by my self and i would say its pretty simple as ruby , writing a program after 2days .

Since treehouse realised it, i was a bit shocked because i actually though that language is going away , but i see its still in use .

So as in C you could , i believe do the same stuff as on python whats the difference really?

I did watch a intro to C and Objective-C so I'm just wondering with python as i know that you could do similar stuff with it and as in college a teacher told me that you could write and app on mobile with it too but umm.. I'm little confused with it still .

Don't let the syntax fool you. Just because languages look the same doesn't mean they are similar. Many modern languages borrow syntax from C. Most of the people who designed those languages are likely come from a background of C or at the least are familiar with writing C. Actually, C is a great language to write an interpreter for an interpreted language. I'm pretty sure the Python interpreter is written in C. Each has an area where it excels versus the other. Technically you can do most things in C that you can do in Python but why would you want to write a C program you have to compile to do something that you could easily do in Python just by copying a script over to your computer? Python is still very popular. It's a great language for beginners. You can use it to teach most OO concepts, it has most of the important structures of other modern languages. At the core of it, Python is great for writing scripts to improve workflows, etc. C has to be complied so you can't just move files from one computer to the other and run them. You have to build them first. So as in my previous example if you write a script that compares files in a folder, you can copy this to a Mac or a PC, run it in the Python interpreter for that OS and it will just work. Not so with C. C on the other hand is great for making applications that need to perform very well. For example the Python or Ruby interpreters. Also a lot of server software is written in C. Also, if you do any work with embedded electronics, because of the low memory overhead and small file sizes of C you'll likely end up using that.

may I also add that when used in web development, python is much more efficient and than both php and ruby, decreasing both the amount of code required as well as the loading time of your website

I never said C is not a good language, in fact in my very first post I implied it was one of the better ones, so please stop putting words in my mouth

and in the end you are just saying what I said, C is good when you need to create memory expensive software

writing in python does not mean you dont understand the hardware you are programming for, you are just assuming here that someone that would code in python does not know C, or else that's what he would be using. so you are being what you accused me of being, an elitist

there are unlimited instances of where using python would be more beneficial, and here diminishing returns come into effect. the smaller the project gets, the less the performance advantage for C, and at some point, python will take over. If the project is of appropriate size, python could outperform C

You're assuming that by knowing something about your hardware it means you can interact with it on a fundamental level. With higher level languages this is not always the case though many times it also is the case. There is also a difference between knowing how to write code in C and knowing what your code is doing. I know C and I know Python, it doesn't mean I know how the Python interpreter implements APIs. And again, you're generalizing that all my points lead back to memory management which is not the case.

We continue to repeat points so I feel that this conversation has reached it's EOL. I'll leave it with this, I've said numerous times that Python is a good language for certain things. If you review my answer to OP before you and I started our discussion I say "Each has an area where it excels versus the other". I then go on to list a few examples. I've tried to be fair to both languages. I am elitist but with respect to providing fair, unbiased comparisons. To your credit you did say C was good for large programs. While this is true it's not the only reason to use C which is why I felt the need to jump in and add my $.02.

Happy coding (in whichever language you may choose).

Um C has its own advantages over Pyhton.
Python has it own advantages over C.

Python and C are similar as you can make a software but different ( i hope this is understandable).

As reffering to my question , i just wanted to know something , i know it now, and yes, the discussion is longer as for others etc...
Now continuing and arguing about C and Python , clearly theres something different in them .

Its like why using PHP if we have a clean Ruby on Rails easy language . C and Python is the same thing( when were talking on it here ) in my opinion in a certain level .

Hope this helps ^^

Well, heres clear love for python in this room :smiley:

As i see , C and Python are different in a way . Don't get me wrong but i took the informations from net and from a teacher of python and well , i wanted to know more since its like in my head .

Cleary C and Python combined together can have a good resoult. But in iOS apps , C has to be used . Python is good for web development and as you said these files etc..

C has its own advantages and Python . Each of them has different job clear . C is closer to machine ' i believe you wrote metal for that ?"

Depending what is the project about , it depends on programming language . The reason why learn Python if we got C is coz o time learning it as for me I'm learning Obj-C and i wouldn't learn Python now, but for programmers its easier i believe . But lets live that .

Making a project for real life , would be good to combine it with python i believe but it depends what software . Because threes a lot of rings in life we ould do with it . Knowing how to program is like magic i believe in a way : p . Making a software for a garage of cars under earth etc.. who cares how its written as long as it works when you press the button . Maybe when you have to make some changes then yes .

But making an app , you clearly want to develop it in Java or Obj-C . Python is rater for web as we can see so heres my opinion .

C is for something else and Python is for something else so theres not much to compare in a way.

its like comparing JavaScript with Java , different things do different things : p if you know what i mean . But of course python and C are closer an could make a game so as with JS but i hope you get the point I'm coming to and from what point .

Thank you for all replies , it really helped me a lot.

and Happy Birthday Patrick Cooney :smiley:

I think you're getting the most important point. All languages have their advantages and disadvantages. And thanks! :-)