Cobra and the newbie
Posted: Tue Mar 11, 2008 8:35 am
Hello Chuck,
I think that, as it is now, Cobra is easier to learn than Python or Ruby(except for
very initial only procedural code lessons).
I don't know how much importance you give about Cobra being friendly to newbies.
Anyway, I will share some thoughts, based on my personal experience, about things
that make the language harder for a newbie:
1) Zero based indexing. I know this is the pattern in the info world and that Cobra uses .NET base class library. So this will not change. I wrote it here just to help item 2.
2) The Python style for slicing: excluding the last index element:
It is not a pattern in the info world. Even .NET includes the last element - although its slicing uses count from first element index instead of last element index:
This may be tricky even for a skilled programmer from Ruby, for example.
And for a newbie, dealing with item 1 already filled his share of sacrifice.
3) The way to call a constructor without arguments:
Cobra sends warning message each time it sees a function call with parentheses but no arguments. I think it is fine - helps to keep the code visually clean. But, when comes the time to call a constructor with no arguments, Cobra behaves at the opposite, demanding an empty pair of parenthesis(no much coherency). I spent some minutes yesterday because of a missing '()' after a constructor call. I think that
is less error prone(and, in this case, 'new' instead of 'init' would be welcome).
4) Shared X Non Shared. Although I have sympathy for the syntax 'is shared', for a newbie that is writing code, it is important that all the shared stuff of a class be toghether inside the only one shared sector, so keyword 'shared' is used no more than once per class. There is a post in this forum where skilled people stumbled a bit because of spreaded 'shared' declarations.
5) Liberal naming(this is scary):
---
Cobra ROX on many topics, so I feel it could be a pity to keep these small gotchas for newbies.
I hope you don't find me very intrusive.
Thanks for your attention .
-necromanco
I think that, as it is now, Cobra is easier to learn than Python or Ruby(except for
very initial only procedural code lessons).
I don't know how much importance you give about Cobra being friendly to newbies.
Anyway, I will share some thoughts, based on my personal experience, about things
that make the language harder for a newbie:
1) Zero based indexing. I know this is the pattern in the info world and that Cobra uses .NET base class library. So this will not change. I wrote it here just to help item 2.
2) The Python style for slicing: excluding the last index element:
- Code: Select all
'012'[0:2] # makes '01'
It is not a pattern in the info world. Even .NET includes the last element - although its slicing uses count from first element index instead of last element index:
- Code: Select all
someList.GetRange(index, count)
This may be tricky even for a skilled programmer from Ruby, for example.
And for a newbie, dealing with item 1 already filled his share of sacrifice.
3) The way to call a constructor without arguments:
- Code: Select all
SomeClass()
Cobra sends warning message each time it sees a function call with parentheses but no arguments. I think it is fine - helps to keep the code visually clean. But, when comes the time to call a constructor with no arguments, Cobra behaves at the opposite, demanding an empty pair of parenthesis(no much coherency). I spent some minutes yesterday because of a missing '()' after a constructor call. I think that
- Code: Select all
SomeClass.new
is less error prone(and, in this case, 'new' instead of 'init' would be welcome).
4) Shared X Non Shared. Although I have sympathy for the syntax 'is shared', for a newbie that is writing code, it is important that all the shared stuff of a class be toghether inside the only one shared sector, so keyword 'shared' is used no more than once per class. There is a post in this forum where skilled people stumbled a bit because of spreaded 'shared' declarations.
5) Liberal naming(this is scary):
- Code: Select all
class NightmareOfANewbie
shared
def main
.pass
def pass
print "'Hail, newbie!' from method 'pass' :P"
---
Cobra ROX on many topics, so I feel it could be a pity to keep these small gotchas for newbies.
I hope you don't find me very intrusive.
Thanks for your attention .
-necromanco