Follow

you can't teach people programming with single letter variables

· · Web · 4 · 6 · 14

@dadegroot @SuricrasiaOnline unless perhaps you are an #MSX #BASIC coder where longer names take up more RAM, and you need to squeeze out every bit of space as possible. ;)

@SuricrasiaOnline ha, look at most of #SuperCollider tutorials, since single letters of alphabet are already declaired as "globals" so all tutorials start with pretty much:

a = {SinOsc.ar};
a.play;

I think it's a great point you made, but to intro somebody to a music making computer language it's also nice to be as brief as possible. Also it's often used as demonstration and proof of concept/prototype.

@SuricrasiaOnline I'm actually quite curious about proved and well tested methods how to make computer programming really interesting and enjoyable experience for people without any experience of programming. I think to a degree, Processing and its main handbook is l/was quite successful in this.

@luka @SuricrasiaOnline

I try to discourage students from using the a-z variables, but knowing about them is the only way to make sense of the help files.

IMO, the ~ variables are worse, because nothing will ever catch a misspelled name.

@celesteh

this second issue you mentioned... something i don't know nothing about. can you elaborate?

@SuricrasiaOnline

@luka @SuricrasiaOnline

the environment variables either start or end with a tilda. You don't need to declare them and they have a particular set of behaviours if you are using Tdefs and other parts of the JIT or pattern library.

The problem is that i get null pointer exceptions all the time because I'm sloppy at spelling.

Anyway, I like environments, but I want to keep them contained within patterns rather than running wild through my code.

@celesteh

so errors when tilde-variables are involved are less descriptive/trackable than with non-tilde (locally scoped) variables? Am I understanding this correctly?

something like:

~number = 1;

(~number + 1).postln
(~nmber + 1).postln // error

(
var number = 1;
(number + 1).postln;
)

(
var number = 1;
(nmber + 1).postln;
)

btw, I didn't know that
variableName~ is also an environment var? is that what you meant by "start or end with a tilda". it doesn't work in my #SuperCollider

@luka

Sorry, they start with a tilda, I couldn't remember which it was because I never use them.

This is an example of sample code that doesn't produce an error, but does produce unexpected results:

s.waitForBoot ({
~number = 3;
~number = ~number +1;

(degree: ~number).play;

1.wait;

(degree: ~numer).play;
})

Obviously, if there were a variable declared called "number", this would generate syntax errors.

Environment variables are useful for live coding, but I'm generally suspicious of them.

@SuricrasiaOnline I learned with TRS-80 Level 1 BASIC (Tiny BASIC, more or less), and you absolutely can. It's fun!

@SuricrasiaOnline *furiously mocks up language where all variable names must be emoji*

Sign in to participate in the conversation
Cybrespace

cybrespace: the social hub of the information superhighway jack in to the mastodon fediverse today and surf the dataflow through our cybrepunk, slightly glitchy web portal support us on patreon or liberapay!