Programming


Hmm I am really thinking about trying to code.. I am quite good at writing bash an ksh scripts... but that is really different.

Is there a language that is kind of similar to bash/ksh ?

Oh OK Perl ... but that's not an option... 
 
I guess the basics are similar in most languages, if written tiny things in msx-basic, gwbasic, pascal, pure data, java, ImageJ macro language, R... I think I'll just stick with high level languages that are suited for the thing I do. I have no clue how I would program a synthesizer in C but it's fairly easy in pure data, csound or chuck...

I guess I'm not a real programmer but more a scripter.

Like I said before for me (but I guess for most people) it's a lot easier if you have a clear goal, when I made a synthesizer/sequencer I set myself the goal that It should be able to play the bass part of money from pink floyd, took me quite a while to get all the odd timing and stuff into my patch but it payed off.
 
Last edited by a moderator:
Python has a PEP that says you use spaces
Today I learned that Python developers that follow the specification are horrible people. :p (I jest, obviously. I just find it funny that the best argument I can find for using spaces vs tabs is because the PEP tells them to)

Whilst I don't disagree that clean indentation is good. I indent at 2 spaces, nearly every text editor (and template code) seems to default to 4 (or sometimes 8).
If everyone used tabs and spaces the way they were supposed to be used you could use whatever indent size you wanted and it wouldn't make a difference.
Assume ^ is a whitespace, and # is a tab. If your tab width is 2, the second print i is outside the for loop, whereas if tab width is 4, it would be inside
tabs and spaces are both a single character.^print i

#print i

where ^ is a space and # is a tab are both on the same "level" regardless of where the tabstop is. That's what makes mixing tabs and spaces so problematic in Python. If your tab stop is 4 you can't tell the difference between a tab (single level) vs 4 spaces (4th level).

Which one for someone like me? Lua or Python?
The LUA syntax is probably easier for a beginner, but Python can do more in both the short and long term as you learn. I guess I'd recommend Python, you get rewarded faster and more often and rewards are generally how people are motivated to learn. Rewards in this case being "does something cool".Do also give GLBasic some consideration.
 
Normally I think the whole tab vs space thing is a non issue...

However:

pmprog said:
I indent at 2 spaces
One of THOSE people...
 
I'd also reccomend python as a great language for hacking things together.

Its inefficient, and not the most rigourous from a CS point of view, but allows you to get a working program fast.

I find that getting a result is the most exciting part of any project, and provides the motivation for further work.

Learning to indent your code is good too.
 
Currently learning C# for using the Monogame engine. I hope its of use for programming for the Pyra, too.

Good luck :)
 
I prefer to use my own rules for indentation (ditto for spacing lines (or blocks) of code). Being forced to use it where I don't want to is not a good thing for me personally.

I really like what Python can do, but the indentation requirements mean that I'll never use it.

D.
 
OTOH, I like that in Python I can pick up any random code on the internet and not be immediately confronted by the crazy indentation somebody's decided to employ for unspecified reasons.  Also, I like that it nullifies arguments about where to put your curly brackets ;)
 
OTOH, I like that in Python I can pick up any random code on the internet and not be immediately confronted by the crazy indentation somebody's decided to employ for unspecified reasons.  Also, I like that it nullifies arguments about where to put your curly brackets ;)
I agree.  There's tons of different styles in C++, and I tend to find the ones I don't use distracting.


if (true) {
std::cout << " hello!\n";
} else {
std::cout << " not hello.\n";
}

if (true)
{
std::cout << " hello!\n";
}
else
{
std::cout << " not hello.\n";
}

if (true)
{
std::cout << " hello!\n";
}
else
{
std::cout << " not hello.\n";
}

but I also find people who worry too much about the style are a little off-putting.
 
Last edited by a moderator:
At least indentation makes it clear where blocks of code start and end, provided you also employ another rule of PEP8 and never have multi-line lines ;)

The only problem I've ever found is that sometimes you want to have triple-quoted strings defined in a block, and if you indent the second line it'll end up in the string.
 
with a standard library that is already most capable python is everything but inefficient.


theres modules for pretty much everything already there. with python you spend more time with your actual problem than with reinventing the wheel.


python can serve you in different ways, right according to your needs. from simple scripting engine to huge ass enterprise backend. if that aint versatile, i dunno what is.


its drawbacks are caused by the nature of interpreted high level languages. python as a language is super elegant.


reading code thats not your own? not much of a problem in python.


im a bit of a fan.
 
OTOH, I like that in Python I can pick up any random code on the internet and not be immediately confronted by the crazy indentation somebody's decided to employ for unspecified reasons.  Also, I like that it nullifies arguments about where to put your curly brackets ;)
I agree.  There's tons of different styles in C++, and I tend to find the ones I don't use distracting.


if (true) {
std::cout << " hello!\n";
} else {
std::cout << " not hello.\n";
}

if (true)
{
std::cout << " hello!\n";
}
else
{
std::cout << " not hello.\n";
}

if (true)
{
std::cout << " hello!\n";
}
else
{
std::cout << " not hello.\n";
}

but I also find people who worry too much about the style are a little off-putting.

Yes, there are plenty of styles. I would rather write the above like this:


if (true)
printf(" hello!\n");
else
printf("not hello!\n);
If I suspect that one of the branches might become more complicated at some point, then I put { } around them. If there is no else branch and the condition is simple, then I just write it all on one line.

I like to avoid wasting vertical space, so I can fit more code on my screen :)
 
Back
Top