d2jsp
Log InRegister
d2jsp Forums > Off-Topic > Computers & IT > Programming & Development > [C++] Pong Project > Ascii Art Game
Prev1345679Next
Add Reply New Topic New Poll
Member
Posts: 6,953
Joined: Sep 27 2003
Gold: 518.50
Oct 2 2009 02:51pm
Quote (Muukalainen @ Fri, Oct 2 2009, 03:35pm)
write metaclasses

"Metaprogramming" is not a concept unique to Python. So, I take my knowledge and skills from other languages with metaprogramming support, do a Google search for something like "metaprogramming in python" and see the Python syntax for it (which is basically JSON).

Quote (Muukalainen @ Fri, Oct 2 2009, 03:35pm)
decorators

Once again, decorators are not unique to Python. Check out "aspect-oriented programming."

Quote (Muukalainen @ Fri, Oct 2 2009, 03:35pm)
bytecompiler optimzations

Optimization? If you've read a book on optimization (The Art of Computer Programming, Volume 4 is a good choice), then you can see that writing optimized code in most situations is a practiced similarly in any language you use. Yes, there are subtle differences that may give you a 0.5% performance improvement for certain cases, but these rarely matter. Algorithm design is infinitely more important than language subtleties.
Member
Posts: 31,680
Joined: Nov 10 2007
Gold: 1.00
Oct 2 2009 02:52pm
Quote (Muukalainen @ Fri, 2 Oct 2009, 15:35)
I am working around 12 months now, the last 6 months around 50h weekly on python. and still i would describe myself as a python newbie, compared to what there is still to learn... btw part of knowing a language is also knowing its libraries (which are huuuuuuuge for python - batteries included philopsophy)


There is no defined way of saying you "know" a language. That's like saying you don't know English 'cause you don't know all 250,000 words. Where-as in Korean, there's literally only 2,000 words (total).
To know a language is to know all the syntax, I say. But to be able to use it, is to be able to use a lot of the libraries and know what's out there. But as said by experts before: You shouldn't try memorizing the libraries.
You should simply know the most common ones you'll use 24/7, and look up the rest as you seldom use them - which is what I do. When I forget how to do something, or learn something new, I look it up and try to use it.

When I found out about vectors/lists/maps, etc. I wanted to use them everywhere, even where they didn't "Belong" but could be used, just so I could learn what's what.
Member
Posts: 11,637
Joined: Feb 2 2004
Gold: 434.84
Oct 2 2009 02:59pm
Quote (Muukalainen @ Fri, Oct 2 2009, 04:35pm)
Then I wanna see how you can write metaclasses, decorators and bytecompiler optimzations in python after a week...

I agree that you can pick up the basic syntax of a language within a week, thats really nothing special. every monkey can learn syntax. but understanding the philosphy and conventions, best-practises, style guides, etc... getting into the community of a langage... thats what i count as "knowing a language". and thats not so quickly done. I am working around 12 months now, the last 6 months around 50h weekly on python. and still i would describe myself as a python newbie, compared to what there is still to learn... btw part of knowing a language is also knowing its libraries (which are huuuuuuuge for python - batteries included philopsophy)


The "batteries included" philosophy behind Python is a complete blessing and curse rolled into one. The only language I've ever seen with a more bloated standard library would be PHP.

This post was edited by rockonkenshin on Oct 2 2009 03:00pm
Member
Posts: 6,953
Joined: Sep 27 2003
Gold: 518.50
Oct 2 2009 03:02pm
Quote (Muukalainen @ Fri, Oct 2 2009, 03:35pm)
I agree that you can pick up the basic syntax of a language within a week, thats really nothing special. every monkey can learn syntax. but understanding the philosphy and conventions, best-practises, style guides, etc... getting into the community of a langage... thats what i count as "knowing a language". and thats not so quickly done. I am working around 12 months now, the last 6 months around 50h weekly on python. and still i would describe myself as a python newbie, compared to what there is still to learn... btw part of knowing a language is also knowing its libraries (which are huuuuuuuge for python - batteries included philopsophy)

And I use Python to script various internet browsers to run automated tests. The language is a tool I use to solve problems. Could I have written it in Perl? Yes. C? Yes. Java? Yes. I picked Python because I felt it was a good choice for the job. That's it. You probably have more intimate knowledge of Python then I do, but I have a feeling that it would have taken us a similar amount of time to write the package. Knowledge of the library system is not knowledge of the language. Knowing the libraries is a huge help, but library knowledge can be picked up in no time.
Member
Posts: 6,953
Joined: Sep 27 2003
Gold: 518.50
Oct 2 2009 03:03pm
Quote (rockonkenshin @ Fri, Oct 2 2009, 03:59pm)
The "batteries included" philosophy behind Python is a complete blessing and curse rolled into one. The only language I've ever seen with a more bloated standard library would be PHP.

At least Python has package scoping.
Member
Posts: 1,443
Joined: Jun 11 2008
Gold: 47.33
Oct 2 2009 03:04pm
Quote (ASBands @ Fri, 2 Oct 2009, 22:51)
"Metaprogramming" is not a concept unique to Python.  So, I take my knowledge and skills from other languages with metaprogramming support, do a Google search for something like "metaprogramming in python" and see the Python syntax for it (which is basically JSON).


nope, its not.
Also knowing what a static method in java wont help you generally in python. Because python classmethods resemble the java-static behaviour a lot better. You only get to know these pitfalls when you really deal in-depth with a language. Thats my point. You may know 20 languages, but if you know them as well as you know python, then you dont know much about their details, and you wont even use them anywhere near their potential, hence my point, dont exaggerate. learn one of each _type_ of language, but concentrate your focus as well, dont get lost in diversity.

Quote (ASBands @ Fri, 2 Oct 2009, 22:51)
Once again, decorators are not unique to Python.  Check out "aspect-oriented programming."


Ever seen a decorator around a function in Java for example?

Quote (ASBands @ Fri, 2 Oct 2009, 22:51)
Optimization?  If you've read a book on optimization (The Art of Computer Programming, Volume 4 is a good choice), then you can see that writing optimized code in most situations is a practiced similarly in any language you use.  Yes, there are subtle differences that may give you a 0.5% performance improvement for certain cases, but these rarely matter.  Algorithm design is infinitely more important than language subtleties.


Byte compiler optimizations dont have anything to do with normal optimization, once again. you were wrong in all your points, which obviously shows that you have no clue what youre talking about, and proving you wrong at the same time.

I'm not trying to hate on you, you really seem to know your shit. just trying to make a point here, hope you dont get it the wrong way m8.

This post was edited by Muukalainen on Oct 2 2009 03:08pm
Member
Posts: 31,680
Joined: Nov 10 2007
Gold: 1.00
Oct 2 2009 03:07pm
Quote (ASBands @ Fri, 2 Oct 2009, 16:03)
At least Python has package scoping.


You should have edited your post instead of posting twice - at anyrate...!
Somebody who knows and uses C/C++ often, and uses object oriented design (or the object oriented paradigm), could you explain to me how the program I wrote (Pong) is "bad?"
I created an object, and I initialized it, and I used it in a loop, which is proper as far as I know. There's nothing "wrong" about it, as it obviously compiles it. It is ineffecient but not "that" ineffecient I didn't think.

Could you modify it and post a more "proper" version of Pong...? With the exception of the colors?
Or I could post the SetColor/PlaceCursor functions for you.

Thanks. :)

EDIT: As much fun as this/the other discussion is, it's off-topic and I'd like my answer from the original posts!

This post was edited by Muted on Oct 2 2009 03:13pm
Member
Posts: 11,637
Joined: Feb 2 2004
Gold: 434.84
Oct 2 2009 03:09pm
Quote (Muukalainen @ Fri, Oct 2 2009, 05:04pm)

Byte compiler optimizations dont have anything to do with normal optimization, once again. you were wrong in all your points, which obviously shows that you have no clue what youre talking about, and proving you wrong at the same time.


Define "normal optimisation". Most "normal" optimizations I've seen programmers pull would have most likely been done by the bytecode compiler in the first place and more often than not the person gets them wrong. Premature optimization sucks and should always be avoided. Almost every time I've seen a nutty "performance optimization" in a co-worker's code I can usually take a few minutes and figure out 5 ways to do it better and faster without restoring to crazy optimazation tricks.


Member
Posts: 6,953
Joined: Sep 27 2003
Gold: 518.50
Oct 2 2009 03:26pm
Quote (Muukalainen @ Fri, Oct 2 2009, 04:04pm)
nope, its not.

What are you objecting to here? The fact that metaprogramming is not unique to Python? Or the fact that the Python syntax for metaprogramming loosely resembles the object notation that Javascript uses? Because both of these are pretty clear facts.

Quote (Muukalainen @ Fri, Oct 2 2009, 04:04pm)
Also knowing what a static method in java wont help you generally in python. Because python classmethods resemble the java-static behaviour a lot better. You only get to know these pitfalls when you really deal in-depth with a language. Thats my point. You may know 20 languages, but if you know them as well as you know python, then you dont know much about their details, and you wont even use them anywhere near their potential, hence my point, dont exaggerate. learn one of each _type_ of language, but concentrate your focus as well, dont get lost in diversity.

You're assuming that I only have experience working with object-oriented languages that extend from a C-style syntax. Trust me, when I first picked up Python, I saw immediately where they took inspiration from. I find class methods are actually closer to Haskell. No, they don't look at all alike syntactically.

Quote (Muukalainen @ Fri, Oct 2 2009, 04:04pm)
Ever seen a decorator around a function in Java for example?

They're called "Annotations" -- http://java.sun.com/j2se/1.5.0/docs/guide/language/annotations.html Yes, they are a little different, but guess how much that matters.

Quote (Muukalainen @ Fri, Oct 2 2009, 04:04pm)
Byte compiler optimizations dont have anything to do with normal optimization, once again.

Whatever you say. They couldn't at all resemble externs from C, flags in GCC, HotSpot and they certainly couldn't have taken lessons from Ocaml bytecode optimization, could they? PYTHON IS NOT GOD. Every language takes things from other languages. The underlying knowledge always translates, even if the syntax does not.

Quote (Muukalainen @ Fri, Oct 2 2009, 04:04pm)
you were wrong in all your points, which obviously shows that you have no clue what youre talking about, and proving you wrong at the same time.

I wouldn't say that...
Member
Posts: 31,680
Joined: Nov 10 2007
Gold: 1.00
Oct 2 2009 03:28pm
This thread has gone completely off topic:

Quote (ASBands @ Fri, 2 Oct 2009, 16:03)
At least Python has package scoping.


You should have edited your post instead of posting twice - at anyrate...!
Somebody who knows and uses C/C++ often, and uses object oriented design (or the object oriented paradigm), could you explain to me how the program I wrote (Pong) is "bad?"
I created an object, and I initialized it, and I used it in a loop, which is proper as far as I know. There's nothing "wrong" about it, as it obviously compiles it. It is ineffecient but not "that" ineffecient I didn't think.

Could you modify it and post a more "proper" version of Pong...? With the exception of the colors?
Or I could post the SetColor/PlaceCursor functions for you.

As much fun as this/the other discussion is, it's off-topic and I'd like my answer from the original posts!

This post was edited by Muted on Oct 2 2009 03:28pm
Go Back To Programming & Development Topic List
Prev1345679Next
Add Reply New Topic New Poll