Okay this is just a simple question, but how does Python differ from C and C++? Because I'm trying decide on a language. |
|
I'm approaching mastery level in python. I can answer questions about anything from basic syntax to to generator expressions to decorators and metaclasses. I disassemble python code to see how it works and profile all competing idioms so I know what's fast. I can fairly reliably predict generated bytecodes and fastest implementation. I am becoming a python god and I love answering questions. Ask away. |
|
Previously PhilosopherStoned
Okay this is just a simple question, but how does Python differ from C and C++? Because I'm trying decide on a language. |
|
"Don't kill me. I'm in a dream right now, and if you kill me I'll die in real life too!" -Me, age 5-8, talking to a dinosaur.
Python is an easier language to start with so you should probably start with it as opposed to C or C++. From a programmers perspective, the differences are that |
|
Previously PhilosopherStoned
According to this site, it was Assur. Howzit? |
|
Previously PhilosopherStoned
Is it possible to shut off the garbage collector? Professionals hate garbage collectors. |
|
Last edited by ninja9578; 10-01-2010 at 05:24 PM.
I need to write a python program soon which generates simple musical sequences (monophonic) in real-time according to various parameters. Tone quality is not essential but reliability and efficiency are (and ease of use is a bonus). Do you have any recommendations on libraries etc.? |
|
Last edited by DuB; 10-01-2010 at 08:53 PM.
Professionals don't hate garbage collectors. Professionals like to get as much work done with as little code as possible in the most readable manner because that allows for a better program. That's why professionals use python when it's appropriate. |
|
Last edited by PhilosopherStoned; 10-02-2010 at 12:56 AM.
Previously PhilosopherStoned
I haven't done any audio programming but it looks like pyo is your best bet. It's written in C so it should be very low overhead to call into. If you write correct python code, then efficiency and reliability shouldn't be a problem. I can surely help with that but It's hard to say more without knowing what your parameters are and how they map to output. |
|
Last edited by PhilosopherStoned; 10-02-2010 at 12:53 AM.
Previously PhilosopherStoned
Where'd my damn post go? |
|
No I wasn't; I was demonstrating how C++ programmers use the predictable behavior of when destructors get called. If there is garbage collection, you have no idea when destructors get called, so you can't use them the way you can in C++. pthreads's locking mechanism was just to show how scope is used in C++, I could have also show glBegin/glEnd statements paired together, or new/delete (called scoped pointers.) When things go out of scope' they are immediately destroyed, so you can put code in your destructor to do work. With a garbage collector, you can't do work, you can only clean the object up. Maybe python does it differently, but thats how it works in java and PHP. |
|
Last edited by ninja9578; 10-02-2010 at 03:58 AM.
What I don't get is why C++ programmers always insist that if you can't accomplish something the way that you do in C++ then it's not as good. I've literally had someone try to tell me that C++ is more powerful than python because python doesn't have a 'do' loop. One would often use the 'with' statement to have a context manager have code run when exiting a scope as I demonstrated in my example (though it's much more flexible than that) |
|
Last edited by PhilosopherStoned; 10-02-2010 at 04:44 AM.
Previously PhilosopherStoned
I don't think jokes should be gratuitously deleted by the forum Gestapo. |
|
Thanks, I'll look into pyo. |
|
What does it do? And how can I benefit from such a subject? |
|
it's a programming language. You can make programs. |
|
Previously PhilosopherStoned
I'm not sure I'd say lisp is a "modern" language... It's the second oldest high-level language, originally specified in the late 50s. |
|
April Ryan is my friend,
Every sorrow she can mend.
When i visit her dark realm,
Does it simply overwhelm.
That doesn't mean that it's not the most modern, it just means it was (and still is) remarkably ahead of its time. It's the most powerful language I could possibly imagine. |
|
Last edited by PhilosopherStoned; 10-14-2010 at 01:00 PM.
Previously PhilosopherStoned
C++ is not loosely typed, it's one of the strongest typed languages there is, behind only Ada. And you can turn on compiler options to make it just as strong as Ada. Polymorphism is not the same as loose typing. |
|
Of course polymorphism isn't loose typing. Polymorphism is one of the foundations of good design. void* is loose typing and I see it used all over the place (at least in C). "Exists in the language" means the language is not strongly typed. You may program in a subset of it that is (and I commend you for that) but you can't seriously claim that a language that lets you treat any type as any other type is strongly typed. |
|
Last edited by PhilosopherStoned; 10-14-2010 at 02:43 PM.
Previously PhilosopherStoned
I was looking for some python help and hopefully you're still able and willing to answer some questions here, so I'll just post them and hope for the best |
|
Last edited by khh; 07-19-2011 at 12:11 PM.
April Ryan is my friend,
Every sorrow she can mend.
When i visit her dark realm,
Does it simply overwhelm.
It's kinda tough for me to help with this as I'm limited to coding in javascript at the moment. Hence I can't post running code. |
|
Last edited by PhilosopherStoned; 07-19-2011 at 11:35 PM.
Previously PhilosopherStoned
Oh yeah. I just remembered that you'll want to override __getattr__ for that to work. And it occurs to me that socket.accept is a method on socket.socket and not a module level function of socket as I treated it in my first post. So the code will be something like: |
|
Previously PhilosopherStoned
Bookmarks