« first day (442 days earlier)      last day (4495 days later) » 

8:00 PM
@MrShinyandNew安宇 Why?
 
@Cerberus you are too fixated on your little script. Imagine if your program had 1000 lines of code.
@Cerberus because indexing data is hard. TL;WGII.
 
@MrShinyandNew安宇 No: what you said here is really not true. If you want to look up whether a single variable contains data or not, all you need to do it access that single variable, which was created in the beginning of the script.
@MrShinyandNew安宇 What?
 
@Cerberus to long; wont' get into it
 
OK.
 
@Cerberus No, I mean, it's not a valid argument to say "programming practice X is fine, because I promise to do it only once in my tiny program".
 
8:04 PM
@MrShinyandNew安宇 I didn't say that.
 
good, I didn't think you did
 
@MrShinyandNew安宇 You supposed that I needed to check a single variable.
 
No, you're saying you can inspect your program and then say "this variable isn't used" and that's fine because you initialize your data up front.
No, what I said was "let's say in your source code there is a variable with that name. How can you tell if the code still uses it"
 
@MrShinyandNew安宇 I didn't say it was fine; I just said that, once the script was running, I could easily check the variable.
@MrShinyandNew安宇 Tell when?
I can't tell just by looking at the code.
I need to run it.
 
@Cerberus right. And that's a flaw.
I can tell by looking at my code which variables are in use.
(within certain restrictions)
 
8:08 PM
How? And why does it matter?
 
In fact, my compiler tells me when I have unused code or variables, because that could be a mistake.
@Cerberus how? by inspection. variables have names and namespaces and scope, and I can inspect the code and see when the variable exists, and who uses it during that time.
 
@MrShinyandNew安宇 I doubt you can tell when the garbage collector is about to run by reading your code
 
I can text-search
@MattЭллен GC has nothing to do with it
 
Inspecting means reading the text document that is your code?
 
8:09 PM
@MrShinyandNew安宇 I don't see why cerberus can't tell what variable is in use by reading his code the same way you would
 
@MattЭллен because his variable names are variable.
And it doesn't matter if he can do it for really short programs. All short programs can be inspected, even the IOCCC ones.
 
@MrShinyandNew安宇 he must be able to follow it, otherwise it would never make sense
 
IOCCC ?
 
@Cerberus International obfuscated C code competition
 
I mean - a dictionary is no different to variable variable names.
 
8:12 PM
@MattЭллен It is. you have a pointer to the dictionary. All he has is a global scope.
 
Ah.
@MrShinyandNew安宇 By the way, I can easily change my script such that I create no empty or useless variables at all!
 
My code base right now has 1.3 million lines of java code (including blank lines and comments, etc).
 
No global ones at any rate.
In fact that is a good idea: why not do it.
 
@MrShinyandNew安宇 but that has nothing to do with knowing if you've assigned to it or not.
@Cerberus it is. do it!
 
It takes a certain amount of discipline to keep that size of codebase tidy. But part of that discipline comes from using data structures that make sense, instead of piles of variables everywhere.
@MattЭллен You mean, if the dictionary has a particular key? or if the dictionary variable has a value at all?
Either way, I can find all references to the dictionary instance, and inspect how it is used.
 
8:14 PM
@MrShinyandNew安宇 if there is a particular key
 
@MattЭллен Done!
This has halves my number of variables, probably.
 
@MattЭллен I can inspect how the dictionary is used. In most cases I can determine what the possible keys are for a dictionary, or else I don't care.
 
@MrShinyandNew安宇 I don't have piles; they make perfect sense.
 
@Cerberus how many lines of code in your script?
 
@MrShinyandNew安宇 I still don't see how that is different to variable variables. You can either check what is there, or you don't care
 
8:16 PM
@MrShinyandNew安宇 The addition to prevent empty variables from being created?
9 lines.
 
No, the whole script
 
182.
 
@MattЭллен When a program relies on variable variables, every variable can potentially be accessed any time. How can you be sure? You have to inspect every direct use of the variable and every use of indirect variables.
 
@MrShinyandNew安宇 which is different to the dictionary because...
 
@Cerberus Any not-intentionally-obfuscated program that small is going to be easy to understand, such that it doesn't matter HOW badly written it might be.
@MattЭллен because only the contents of the dictionary are subject to this? And they can't be accessed directly?
 
8:18 PM
@MrShinyandNew安宇 No doubt. But your point was about having empty valuables, which I don't any more now.
 
Are you seriously advocating for variable variables as a good practice?
@Cerberus No... I wasn't talking about empty variables. I was talking about understanding the code.
 
Okay but you brought up checking empty variables.
 
And the reason people use arrays and objects, besides performance, is to understand the code.
 
@MrShinyandNew安宇 so you are using immutable keys. This is an important point.
 
@Cerberus No, I brought up unused variables
 
8:20 PM
@MrShinyandNew安宇 Okay, that makes sense.
 
@MattЭллен No, I'm not talking about immutable keys.
 
@MrShinyandNew安宇 then your keys can be changed willy nilly!
as can you contents
 
What I'm talking about is that when a programmer introduces a Dictionary or Map into his program he knows under what circumstances it is used.
 
@MrShinyandNew安宇 Do I have unused variables if no variables are created that I won't use?
I have a variable for each character I might use, like ʌ.
 
@Cerberus No, but again, you have to think bigger than your tiny script. 180 lines is much smaller than 1354363 lines.
 
8:21 PM
Sure.
 
user19161
Today is shiny teaches cerb programming day!
 
@MrShinyandNew安宇 so you're just saying dictionaries are better because they're easier to maintain?
 
He's saying his code is bigger. He has a really big code.
 
@Cerberus What happens when you're writing an AHK script that is expected to take over an hour to run, which combines several programs together into a marvelous search-engine and computation device, automating your entire thesis? And there are three people working on it.
@MattЭллен yes, among other things.
 
8:23 PM
For the record: I do not doubt that arrays and objects and maps are the best method in larger programs, or in general. But it is hard to understand why exactly. I can't say, "yes, I understand and agree, Mrs. H.", when in reality I don't quite understand the logic.
 
Easier to maintain, easier to understand, easier to improve the performance of, don't require naming conventions, etc.
 
@MrShinyandNew安宇 So it does come down to memory/performance?
 
user19161
@Cerberus Oh dear now you are using Mrs H too? It's a disease!
 
@WillHunting Always have.
 
@Cerberus Computer performance is one aspect. But programmer performance is another.
 
8:25 PM
What's that?
 
user19161
I will give Ubuntu one last try with 12.04.
 
Essentially, @Cerberus, programmers are forgetful.
 
@MattЭллен Now that's something Cerb can identify with!
 
@WillHunting I've been using Ubuntu Live to quickly create and destroy virtual machines, in order to fake I was on different computers to fool a program.
@MattЭллен They suddenly sound more human, err canine!
 
If you want to become a better programmer, practice at it. And I will keep hounding everyone to go practice at the Euler Project because it's a really, really good set of problems to practice on.
 
user19161
8:26 PM
@Cerberus Up to no good I see!
 
You'll learn about arrays when you need to.
 
@MetaEd So what is it about?
 
Here's an example. This is problem no. 1.: "Add all the natural numbers below one thousand that are multiples of 3 or 5."
 
Ah! Should be doable.
Tedious, but doable. At least in AHK, for me.
 
Your objective is to write a program which will return the correct answer after less than one minute of run time.
 
user19161
8:28 PM
@MetaEd So this can be done with say Python?
 
@Cerberus no, don't use AHK...
 
@MetaEd Should be easy enough?
 
use something else
use Javascript
 
@MrShinyandNew安宇 But but...why not?
I only know AHK.
 
or use python
 
8:29 PM
People are working through these problems using hundreds of languages.
 
@MrShinyandNew安宇 Can't.
 
@Cerberus that's why not
 
I do them in Perl.
 
@MrShinyandNew安宇 But Ed gets to use Perl!
 
user19161
I think I'll learn Python first! After all it is voted best programming lang and best scripting lang by Linux Journal 2011!
 
8:29 PM
@Cerberus I wouldn't use perl if I were you.
 
@MrShinyandNew安宇 Don't worry!
 
@Cerberus I would use Haskell if I were you :D
loves Haskell
 
@MattЭллен Ehh...
Who is he?
 
Start with python if you want, or maybe ruby, or VB.net, or C#, or Java.
 
sooooo functional
 
8:30 PM
And what does he charge?
 
or the new one from Google, what's it called?
Go?
 
But Javascript's advantage is that you have it already on any computer.
 
@Cerberus For you, a modest sum
 
@MattЭллен That's my boy.
 
user19161
Googol? Googolplex?
 
8:31 PM
I love the name of this language. It reminds me of the board game.
 
@MrShinyandNew安宇 I might theoretically get some use out of Javascript, because I use Greasemonkey.
But I hated it when I tried to get it to do stuff.
 
hv u tried jqry?
 
Nope.
 
@Cerberus The reason I hestitate to fully recommend javascript is because it needs to run in something like a browser, where the only thing you can do is manipulate an HTML document. so you have to know HTML too.
 
Can't do html either.
 
8:33 PM
@Cerberus it makes getting JavaScript to do stuff easier
 
@MattЭллен Hmm OK.
 
jquery, specifically, makes getting Javascript to do HTML stuff easier.
 
@Cerberus oh yes you can! just type the tags. it's not a programming langauge
 
@MattЭллен I failed when I tried.
 
What language interpreters do you have to hand, Cerb?
 
8:34 PM
I hate having to learn countless new conventions.
 
<script> alert('cerberus'); </script>
 
@MetaEd Interpreters?
 
@Cerberus There's even a Dutch Haskell compiler :)
 
You have an AHK interpreter installed
 
@MrShinyandNew安宇 I got the Hello World box when I tried, but I didn't get much farther. whining
 
8:35 PM
what other languages can you program your PC in?
 
I just gave you a sample HTML file with a javascript hello world.
just put all your code inside the <script> tag, and make your program do all its work, then have it alert() the response.
 
Also, there's one called
Hugs (Haskell User's Gofer System), also Hugs 98, is a bytecode interpreter for the functional programming language Haskell. Hugs is the successor to Gofer, and was originally derived from Gofer version 2.30b. Hugs and Gofer were originally developed by Mark P. Jones, now a professor at Portland State University. Hugs comes with a simple graphics library. As a complete Haskell implementation that is portable and simple to install, Hugs is sometimes recommended for new Haskell users. Hugs deviates from the Haskell 98 specification in several minor ways. For example, Hugs does not suppor...
 
@aediaλ Oh! I have a BA from that uni.
 
You don't need anything else in HTML, so that's a valid file.
 
@MetaEd None.
@MrShinyandNew安宇 Well, Javascript would be useless if I couldn't use it to manipulate web pages.
 
8:37 PM
@Cerberus you should crawl before you walk
<script>
var x = 0;
for (var i = 0; i < 10; i++) {
x = x + 1;
}
alert('cerberus ' + x);
</script>
 
@MrShinyandNew安宇 Or I could just get a taxi.
 
Can you understand the program I just pasted?
 
@MrShinyandNew安宇 Nooo not the magic!
holds hands over head
 
The five most popular languages at Project Euler are C/C++/C#, Python, Java, Haskell, and Ruby.
 
@MrShinyandNew安宇 That i sounds vaguely familiar from when I tried, but I don't know.
@MetaEd Is AHK in/on it too?
 
8:39 PM
I couldn't find it.
 
var x = 0;
for (var i = 0; i < 10; i++) {
  x = x + 1;
  if (x%2 == 0) { // % is modulus operator
    alert('X is even');
  } else {
    alert('X is odd');
  }
}
alert('cerberus ' + x);
There are lots of useful bits in a tiny sample like that.
 
The second five are Perl, PHP, Matlab, BASIC, Mathematica, and LISP. Also, I can't count.
 
@MrShinyandNew安宇 Ahhh no more witchcraft! I surrender!
 
user19161
What programming language is used to make our desktop calculators work for example?
 
@MetaEd You're only 20 % off, no worries.
 
8:42 PM
Your basic tiny calculator? May not have a CPU at all.
 
@MrShinyandNew安宇 I already see 6 things in there that I don't understand.
 
But don't let me dissuade you from using AHK. Any decent scripting language should be rich enough to write some Project Euler solutions.
I've written one or two in that MIT language, what was it?
 
@MetaEd Aww, you've made me nostalgic for TI-BASIC.
@MetaEd Scratch?
 
Scratch.
 
Jinx!
 
8:44 PM
@MetaEd Indeed it is! AHK 2 has arrays and objects too, I think.
 
@Cerberus what are those?
 
@Cerberus it's a very simple program. it loops from 0 to 9, adding 1 to x each time, and checks the modulus of X,2 to see if X is even or odd, and alerts the result.
In javascript code blocks are enclosed in {} and statements are terminated in ;
 
@MattЭллен Ehh... what is i and what does it do (iteration or something?)? Why do there appear to be several overlapping conditions for the "for" thingie? What is ++? What is ==? What is a modulus (or was that some mathematical thing?)? What is the + in the alert? What does the "for" thingie do exactly? But don't bother answering: it would probably be more efficient if I looked it up sometime.
 
user19161
@Cerberus Modulus is just the absolute value of a number.
 
@WillHunting not in this instance
 
8:49 PM
Ah, so |-3| is is the modulus of -3, i.e. 3?
 
modulus is the remainder of a division
 
user19161
@MattЭллен Pardon my ignorance in the language!
 
Ah.
 
so 4%5 is 1
I think
my maths is bad
 
Huh.
 
8:50 PM
4 ÷ 5 = 0.8 or 0 remainder 4
 
@Cerberus Well, in javascript (and other languages) a it is desired that a loop goes around a set number of times. i in this instance is the counter used to keep trackof the number of times the loop has gone around
 
So 4%5 means 4/5 rounded up? Or just rounded the regular way?
 
@Cerberus it's like clock maths
 
user19161
In math we say that a is congruent to b modulo c if a-b is divisible by c.
 
@MattЭллен Oh, I see. That is A_index (a variable) in AHK.
 
8:52 PM
yes
 
4%5 means 4 divided by 5, throw away the integer part, report the remainder
 
user19161
That is to say a and b share the same remainder upon division by c.
 
@MattЭллен What?
 
0%5=0, 1%5=1, 2%5=2, 3%5=3, 4%5=4, 5%5=0, 6%5=1, 7%5=2, ...
 
@Cerberus don't worry, MetaEd explained it better
clock maths is difficult for me to explain
 
8:53 PM
@MetaEd Ah, I see.
@MattЭллен Is it the i in regular maths?
I know that.
 
@Cerberus the + in the alert is used to concatenate the string "cerberus " with the number x (x gets transformed into a string)
 
i? You mean imaginary numbers?
 
In -1 = x^(0.5), x is something with i, right?
 
user19161
@Cerberus Nope, nothing to do with i at all!
 
@MattЭллен Ah OK.
 
8:54 PM
@Cerberus in Javascript, as in several other C-like languages, there are two commonly-used loops. a for-loop and a while loop. i++ means "read i, get its value, then add one to i". == is a comparison. the three embedded statements in the for loop are setup, loop condition, and what happens at the end of each loop iteration.
 
@Cerberus i++ is the same as i = i + 1
 
so for (i = 0; i < 10; i++) means "first, initialize i to 0. then loop while i is less than 10. then, after each loop iteration, add 1 to i.
 
It is like explaining something by intriducing another set of unknown words.
 
@MattЭллен yes, in this case.
 
@Cerberus Are you familiar with the notion of a function?
 
8:55 PM
@MattЭллен Yeah OK, I got Mr's explanation there ( i += 1 in AHK).
 
@Cerberus Ok, forget the % thing. I really wanted to show you the syntax for an if statement.
 
When I was in school, we had functions. They were explained pictorially. You dropped some values into a hopper, the function operated, and a value came out. It was exactly like making sausage.
This was in primary school.
 
@MetaEd That's what this whole day's chat session has been like. Shiny and New Cerberus sausage.
 
@Cerberus I've commented it for you but I have no idea if this is going to paste in well, so be prepared for something ugly in a second...
 
@MrShinyandNew安宇 OK, I saw it! Hehe.
 
8:57 PM
var x = 0; 			// start x with the value 0
for (var i = 0; i < 10; i++) {  // make a loop and do the stuff in {}.
				// start with the first thing;
				// while second thing is true;
				// do 3rd thing each time through the loop
				// i is just used to count the times we go through the loop
				// i is 0 at the beginning of the loop and we continue looping
				// while it is true that it is less than 10.
				// each time, increment i
  x = x + 1;			// make x the previous value of x plus 1 (same as if we said x++)
3
 
@MetaEd Oh, yes, we had those things too.
 
@Cerberus sorry you've gone over my head :D clock maths is like if you have a clock with only 4 numbers on it and you move it around 5 places from the start, what you are left with is like 4%5 or something.
 
@Cerberus Okay so I would explain the i++ syntax as a function. It takes i in, and its value is the value of i, plus 1. Also, as a side effect, it changes the value of i itself to i + 1.
of course I got that wrong.
 
Okay, anyway, I tried to make it less ugly.
 
It takes i in, and returns i out unchanged. But as a side effect, it changes the value of i itself to i+1.
 

« first day (442 days earlier)      last day (4495 days later) »