Tinkering with new languages is fun and worthwhile to a point, but I honestly feel that my time is now better spent learning new problem domains. Languages matter, but the less tangible skills I've developed working across different domains have been more valuable and fundamental. The things I've learned while studying Machine Learning and DSP over the last year are much more broadly applicable than I would have gues…
Perlis Languages
21–30 of 36 posts
Re: Perlis Languages
#22Tinkering with new languages is fun and worthwhile to a point, but I honestly feel that my time is now better spent learning new problem domains. Languages matter, but the less tangible skills I've developed working across different domains have been more valuable and fundamental. The things I've learned while studying Machine Learning and DSP over the last year are much more broadly applicable than I would have gues…
What are some broadly applicable things you learned from DSP?
Re: Perlis Languages
#23I would strongly favor Forth over Joy, but either way concatenative languages are really worth exploring. It seems fair to compare Forth with C, as both deal with hardware and memory rather intimately. Compare a C implementation of a Fisher-Yates shuffle: void shuffle(int *array, int n) { int i, j, tmp; for (i = n - 1; i > 0; i--) { j = rand_int(i + 1); tmp = array[j]; array[j] = array[i]; array[i] = tmp; } } With th…
Re: Perlis Languages
#24Earlier quoted context omitted.
What are some broadly applicable things you learned from DSP?
When you start to think of any stream of numbers as a digital signal, a lot of the techniques become useful. For example, user interfaces provide a fairly high-resolution stream of quantifiable user events, like touch positions. Often you want to smooth these in specific ways. If you understand how a low-pass filter works, this is easy.
Re: Perlis Languages
#25I would strongly favor Forth over Joy, but either way concatenative languages are really worth exploring. It seems fair to compare Forth with C, as both deal with hardware and memory rather intimately. Compare a C implementation of a Fisher-Yates shuffle: void shuffle(int *array, int n) { int i, j, tmp; for (i = n - 1; i > 0; i--) { j = rand_int(i + 1); tmp = array[j]; array[j] = array[i]; array[i] = tmp; } } With th…
Could you please explain the Forth sample? For instance, which variable is the array?
Re: Perlis Languages
#26Re: Perlis Languages
#27Earlier quoted context omitted.
When you start to think of any stream of numbers as a digital signal, a lot of the techniques become useful. For example, user interfaces provide a fairly high-resolution stream of quantifiable user events, like touch positions. Often you want to smooth these in specific ways. If you understand how a low-pass filter works, this is easy.
Does one need a background in electronics to understand DSP?
Re: Perlis Languages
#28PerlisLanguage(Prolog).
Re: Perlis Languages
#29I would strongly favor Forth over Joy, but either way concatenative languages are really worth exploring. It seems fair to compare Forth with C, as both deal with hardware and memory rather intimately. Compare a C implementation of a Fisher-Yates shuffle: void shuffle(int *array, int n) { int i, j, tmp; for (i = n - 1; i > 0; i--) { j = rand_int(i + 1); tmp = array[j]; array[j] = array[i]; array[i] = tmp; } } With th…
Could you please explain the Forth sample? For instance, which variable is the array?
: shuffle
This starts a declaration for our word 'shuffle'. This implementation expects the address of the array on the stack with the length of the array on top. Some Forth programmers would leave a comment to this effect like so: ( addr len -- addr )
Anything in parentheses is a comment, and this shows the contents of the stack we want as input (read from right to left) before the '--' followed by the contents of the stack we'll get as output. (We leave the array address on the stack. If we want to be void like the C example, add a drop to the end of this definition to discard it.) 1- for
Subtract one from the length given and begin a for...next loop. This will take the length value off the stack and repeat everything up to the matching next n+1 times. Equivalent to: for(int z=n; z >= 0; z--) {}
Our stack now looks like this: ( addr )
While we're in the loop, a copy of the loop index can be pushed onto the stack via the word i. This actually accesses a secondary stack, so if you nest loops you can obtain progressive indices by using i' and j (or j and k, depending on your Forth dialect.) i 1+ random
Add one to the loop index and generate a random number between 0 and this value, exclusive. Our stack now looks like: ( addr rand_int(i+1) )
over +
Over pushes a copy of the second element of our stack. This sequence adds the address of the array to the random index, leaving the address of that cell of the array. Our stack now looks like this: ( addr (rand_int(i+1)+addr) )
over i +
Make another copy of the array address and add the loop index to it. The stack now looks like this: ( addr (rand_int(i+1)+addr) (i+addr) )
swap@
This is a helper word which swaps the contents of two memory addresses. It should be easy to see that this will swap array indices for us in exactly the same way the C code did. next ;
Close the loop and terminate the word definition, respectively.Re: Perlis Languages
#30Earlier quoted context omitted.
Does one need a background in electronics to understand DSP?
Not at all. In fact I'd say most DSP these days is done entirely in software.