|
|
|
I like Python's significant white space, however, it does have one disadvantage: it does make some metaprogramming harder (you have to make sure that the indentation in the code your are creating matches correctly, which is significantly harder than matching begin/end statements/characters). However, since extensive metaprogramming isn't part of the Python way, I don't consider it a disadvantage for Python.
Another mostly good/bit bad thing about Python is its "batteries included" philosophy, which is great on the desktop, but if you're looking at running on an extremely memory constrained device, well, it's just way too big. I'd like to see crappy BASIC's (like on the BASIC Stamps) die a well deserved death; Python won't make it happen, but a language like Lua (which Ralph Hempel has running on the Lego Mindstorm NXT in 64k RAM/256K flash) might.
Tony |
08/09/04 - 1:16 am | #
|
|
Hmmm... metaprogramming by code generation is my least favourite kind of
metaprogramming (although it has its place of course).
Memory usage is a real issue for embedded programming. Perhaps you could look at tinypy or Shedskin.
Michael Foord |
Homepage |
08/09/04 - 10:00 am | #
|
|
I read the generators doc a few weeks ago and it totally blew me away, so that is a definite on my list for PyCon. It just feels both efficient and elegant and although partially replicable (real word?) in C# it just won't be the same.
It doesn't take long to get used to the whitespace thing, but I think it is a love it or hate it thing. My biggest problem (coming from C#/Java) is that I can't seem to stop my hands adding ; at the end of each line 
Ross |
08/09/04 - 10:24 am | #
|
|
Well - at least a ';' at the end of the line is *valid* in Python. It just looks a bit odd... 
Michael Foord |
Homepage |
08/09/04 - 10:26 am | #
|
|
You probably mean `sum, difference = ...`, since it's computing a sum rather than a product. 
Jacob |
08/09/04 - 10:26 am | #
|
|
Heh - thanks. 
Michael Foord |
Homepage |
08/09/04 - 11:08 am | #
|
|
I like Python for all the same reasons (and more), but I have to take exception to your base class method call. It's better to use super() than explicitly name the base class. Otherwise you break subclasses with multiple inheritance.
I.e., instead of this:
BaseClass.instance_method(self, arg1, arg2)
do this:
super(SomeClass, self).instance_method(arg1, arg2)
I'm sure you knew that...
kbob |
08/09/04 - 4:49 pm | #
|
|
Comment on the correct post this time:
generator = (f(value) for value in iterable if value > 0)
That syntax is just syntactic sugar for an older way of doing Python generator functions, which just requires defining a function that uses the "yield" keyword instead of "return". In other words, it's equivalent to:
def generator():
for value in interable:
if value > 0:
yield f(value)
Of course, the former syntax is more concise in this case, but the extended syntax allows for more complicated constructions.
L33tminion |
Homepage |
08/09/04 - 5:28 pm | #
|
|
"Otherwise you break subclasses with multiple inheritance."
True - you only need super if you are using multiple inheritance (which you usually shouldn't).
Yes - generator expressions are syntactic sugar for standard generators, just like list comprehensions are syntactic sugar for standard loops. Generator expressions are purely a new syntax - but they are very nice...
Michael Foord |
Homepage |
08/09/04 - 5:38 pm | #
|
|
This should be included in your IPy book.
Matt |
08/09/04 - 11:23 pm | #
|
|
Have you checked out Boo yet? I suspect you may really like it.
From the homepage http://boo.codehaus.org/
"Boo is a new object oriented statically typed programming language for the Common Language Infrastructure with a python inspired syntax and a special focus on language and compiler extensibility."
If you investigate it, I'd be interested in hearing your thoughts.
BTW, I have no connection to the Boo project other than being a fan of the language.
Mike K. |
08/09/06 - 6:38 pm | #
|
|
Boo even gets a mention in the blog entry - in the indentation section.
Michael Foord |
Homepage |
08/09/06 - 10:38 pm | #
|
|
That was one of the paragraphs I skimmed 
Have you used it enough to form any strong impressions?
Mike K. |
08/09/07 - 12:49 am | #
|
|
I've not used it much. Looks *very* good though.
Michael Foord |
Homepage |
08/09/07 - 8:17 pm | #
|
|
I looked at bit at tinypy - it's definitely not ready for microcontroller use. Looks like current RAM memory usage is ~400K, while a typical "large RAM" MCU has 64K->96K. OTOH, Lua is already running on 64K RAM (pbLua for NXT), and has a significant community using it for various embedded applications.
Another small language I'd love to play with is Io, which looks incredibly powerful for the size. It's also probably too RAM hungry for MCU use, and even its BDFL says it's not particularly fast.
I think that different programming styles match different programming languages. Metaprogramming seems much more common, and seem to fit much better, with programming languages such as Lua and Ruby.
I do quite a bit of .NET development. I've played around a little bit with Boo and even less with IronPython. Boo does have significant advantages. The biggest one for me is that Boo can create code that VB.NET and C# can use, but IP can't easily do this.l There are others; for example, I have some VB.NET code that uses a lot of enumerations, which Boo handles, but IP 1.x doesn't.
But Boo's progress as a language seems slower than IP, and it doesn't have the MS backing. So at work, for new code, considering all the politics and other likely developers, most likely I'll settle on C# for the core, maybe some VB.NET, and then most likely use IP for non-core activities such as testing and embedded scripting (if required).
Tony |
08/09/23 - 11:02 pm | #
|
|
|
Commenting by HaloScan
|