Esoteric programming languages for an esoteric mind?

A place to discuss the implementation and style of computer programs.

Moderators: phlip, Moderators General, Prelates

Moniker Pending
Posts: 39
Joined: Tue Jul 28, 2015 12:59 pm UTC

Re: Esoteric programming languages for an esoteric mind?

Postby Moniker Pending » Sun Aug 02, 2015 6:08 pm UTC

ahammel wrote:So start over with some fresh exercises and ask for help when you get stuck.


I could try that, since I still have the textbook for the course, but I don't know how much longer the webpage for the course will still be accessible (though there were sessions on campus, assignments were listed and submitted online, via a temporary "course module" on a site used by the school system for online course work). In other words, the stuff I get stuck on might not be the same stuff I got stuck on during the course.

Your language appears to have conditional branching and variable assignment and thus is already Turing complete. Turing completeness is a very low bar for a programming language.


...Really? Huh... I kind of thought I'd need to make more code commands and such for that. Unless you're just assuming what the rest of those commands would be like, based on what you see already... I'd imagine that would be more likely, but I really don't know what you meant.

Actually, I just thought of another thing to consider about my psychology for this thread's purpose, after typing "I really don't know what you meant." I mean, it may have been implied already (with the mention of Jungian symbolism, though I don't think you'd get this much just from me mentioning that), but I was able to get a pretty good sense of another person's general life story after an informal (non-professional; I don't have a license, which I stated clearly on the thread) dream analysis on another forum. Granted, I used an expanded form of Jungian psychoanalysis I had come up with only a couple of months into my research of Jung's methods, to accommodate the dreamer's perception of others' perceptions of the dreamer (Jungian psychoanalysis doesn't normally consider much more than the dreamer's perception of their own self, and even perception of others is pretty marginal); also, this person has had experiences which I'm familiar with (he's very much like a younger version of myself, even with much of the same traits that the doctors who work with me can't explain), and he's confirmed my interpretations to be accurate, and even helpful.

I don't know if anyone here knows enough about both programming and psychoanalysis to use that information to help me find a programming language, or otherwise learn how to program, but if anyone here does know enough about both of those things... (Again, this is somewhat tongue-in-cheek, but hey, you never know!)

I believe the purpose of the exercise was to determine what features you want in a programming language so that we could suggest a language that has those features. As it turns out, you don't know exactly (which is hardly surprising, as you don't have a lot of programming experience). Your best bet is therefore to just try a language and see if you get along with it.


I've tried a small few already; the best I did so far was actually with Java, since it was easy for a while, before it became extremely hard almost instantly.

schapel
Posts: 244
Joined: Fri Jun 13, 2014 1:33 am UTC

Re: Esoteric programming languages for an esoteric mind?

Postby schapel » Sun Aug 02, 2015 6:51 pm UTC

Moniker Pending wrote:I've tried a small few already; the best I did so far was actually with Java, since it was easy for a while, before it became extremely hard almost instantly.

I think you ran into trouble because you had an inaccurate mental model of what your Java code was doing. Maybe it was more subtle than that... perhaps you just needed more experience with the features you had learned so that you found it easier to understand what was going on before you learned more features.

I think Java is a great language to learn as a beginner, since it's relatively simple and explicit, and it's also quite expressive. It can be verbose and not quite as efficient as some other languages, but these are not drawbacks when learning a programming language. Could you post some code that you found extremely hard to understand? I'd be willing to go over it and see what's tripping you up.

I just happened to watch this video about misconceptions. Confusion is a sign that you're about to learn something.

User avatar
ahammel
My Little Cabbage
Posts: 2135
Joined: Mon Jan 30, 2012 12:46 am UTC
Location: Vancouver BC
Contact:

Re: Esoteric programming languages for an esoteric mind?

Postby ahammel » Sun Aug 02, 2015 7:49 pm UTC

Moniker Pending wrote:I could try that, since I still have the textbook for the course, but I don't know how much longer the webpage for the course will still be accessible
So...don't use the website for the course? It's hardly the only source of programming exercises in the world. I already mentioned Project Euler, but if you don't like that one there are dozens of others.

In other words, the stuff I get stuck on might not be the same stuff I got stuck on during the course.
Probably not. So what?

...Really? Huh... I kind of thought I'd need to make more code commands and such for that. Unless you're just assuming what the rest of those commands would be like, based on what you see already... I'd imagine that would be more likely, but I really don't know what you meant.
I meant what I said. Any imperative language with conditional branching and the ability to assign data to variables is, Turing complete (actually, I think you need a GOTO instruction as well). Writing a non-trivial program in a language with only those features would be difficult, to say the least, but it could be done. Any additional features provided by the language are there for the convenience of the programmer.
He/Him/His/Alex
God damn these electric sex pants!

Moniker Pending
Posts: 39
Joined: Tue Jul 28, 2015 12:59 pm UTC

Re: Esoteric programming languages for an esoteric mind?

Postby Moniker Pending » Sun Aug 02, 2015 8:08 pm UTC

schapel wrote:I think you ran into trouble because you had an inaccurate mental model of what your Java code was doing. Maybe it was more subtle than that... perhaps you just needed more experience with the features you had learned so that you found it easier to understand what was going on before you learned more features.

I think Java is a great language to learn as a beginner, since it's relatively simple and explicit, and it's also quite expressive. It can be verbose and not quite as efficient as some other languages, but these are not drawbacks when learning a programming language. Could you post some code that you found extremely hard to understand? I'd be willing to go over it and see what's tripping you up.

I just happened to watch this video about misconceptions. Confusion is a sign that you're about to learn something.


I suppose, for now, I could post my final project; I'd have tried to find something more specific to work on already, but I'm dealing with a huge headache right now, which is bad enough to keep me from thinking too much about things I'm not used to thinking about, and I'm actually typing this post up a lot slower than normal, typing a small amount for a few seconds, then resting for a few seconds after that ("headaches" elaborated in spoiler box at bottom; might be useful for the "psychological" part of this thread, might just get a chuckle out of the reader). I might have to just rest for a while, after I get this posted.

To quote myself on the assignment's purpose, and where I got stuck:
I was trying to make a contact list manager, which would write first names, last names, phone numbers, and email addresses to a file; the final project would have included that, as well as a program to load the file into a program with a GUI, as part of a contact manager. I was able to design the methods in which the information would be entered, and even check to make sure that the information was entered properly; I had done this previously in other assignments, so I knew how it would work, but I couldn't test it with this assignment, since I had to do everything differently from the start in order to accommodate the need to write to a file after the information was entered. Unlike before, I couldn't even get the part where the user entered the information to work. I had no idea how to do this; I tried whatever I could think of for at least a week, and eventually I tried putting some of the methods into another class, and I've already gone over how that went. The class ended while I was still working on that. I tried getting help from the professor, but by the time I had even gotten to the point I had gotten to, the course was basically over, and the only time I had left was the time between the last in-class session and the time the grades would be entered.


In this file, I think I tried making the main method for the whole thing, with the intention that the other file would include all the non-static methods, which were partially made by the professor himself, and given to students to complete; this file would then call the methods during user input. I had no idea how to do that, which is why there are a bunch of unused imports, and only a couple of lines typed in the main method itself.
https://drive.google.com/file/d/0B8ZFw0cXnCctcU5hNEljd3h4eUE/view?usp=sharing

NetBeans tells me there's no errors in this file, but I have no idea if any of it would work, since this class just contains a bunch of methods to be called by the above file. As such, I can't really test any of this.
https://drive.google.com/file/d/0B8ZFw0cXnCctXy1JcFNnYVNjWG8/view?usp=sharing

And finally, details about the headaches, as mentioned earlier. The text is copied and pasted from a PM I sent, aside from some formatting I needed to re-do, and the "[try to]" I inserted in there; it's not exactly a secret on other sites, and I don't see any rules about copying from PM's on this forum, so...
Spoiler:
See, whenever I say I have a headache, what I really mean is that I have a worse headache than I normally do. My head is always in pain, and always overheating (no matter how cold the rest of my body is). Given some more specific details, my Buddhist friend has told me that the pain and heat is yet another sign that I have an extremely powerful "crown chakra," which is itself a sign of supreme divine enlightenment. Flattering though that may be, I'm not a Buddhist, and so I see it as more of a sign that I need to somehow install a CPU heatsink or something similar in my head, and buy a bunch of large hats so I can cover it up when I'm in public. I can only imagine how much the Buddha would have appreciated some ice packs or painkillers...

Maybe it's because I'm used to it. Maybe it's because I like to think. Maybe it's because of my reverence for Theodore Roosevelt. Either way, I [try to] work through the pain as much as I can.

schapel
Posts: 244
Joined: Fri Jun 13, 2014 1:33 am UTC

Re: Esoteric programming languages for an esoteric mind?

Postby schapel » Sun Aug 02, 2015 8:26 pm UTC

Moniker Pending wrote:I suppose, for now, I could post my final project...

I suspect that this code is far beyond where you first got confused, if you had no idea what to do and just started typing import statements. It sounds like you were completely lost at that point. Could you back up to where you first had trouble? If possible, could you post only code that you wrote? In the code you showed, it wasn't clear which you wrote and which the professor wrote. Feel free to wait until your headache passes.

Or, if you like, we could continue with the code you started with, the JD_Contact class. Take the import statements out (you never need import statements in Java) and just write some code that uses the Scanner class to read a line of input and print out that line. That's a start at least.

Moniker Pending
Posts: 39
Joined: Tue Jul 28, 2015 12:59 pm UTC

Re: Esoteric programming languages for an esoteric mind?

Postby Moniker Pending » Mon Aug 03, 2015 5:09 am UTC

schapel wrote:I suspect that this code is far beyond where you first got confused, if you had no idea what to do and just started typing import statements. It sounds like you were completely lost at that point. Could you back up to where you first had trouble?


I had trouble with previous assignments, but I was able to figure out how to finish them in a couple of days, at most, per assignment. This was something in which I worked on the same step for over a week (possibly over two weeks; it's all hazy), and I had to stop when the class ended. I had failed to pass in four assignments overall, including the assignment I've posted, and the final project. Because of the grade values, I didn't even start the other two assignments.

If possible, could you post only code that you wrote? In the code you showed, it wasn't clear which you wrote and which the professor wrote.


Since the site module is still up, it would probably be easier for me to post the code that the professor wrote, instead of what I wrote.

Code: Select all

import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class Contact {
    //fields
    //Homework: Add field for email address
    private String _firstName;
    private String _lastName;
    private String _phoneNumber;
    //constructors
    //Homework: Add second constructor which takes the same parameters
    //as below plus and email address. So you could just copy this one
    //add email address parameter and call setEmailAddress mutator method
    //you create.
    public Contact(String firstName, String lastName,
            String phoneNumber) {
        setFirstName(firstName);
        setLastName(lastName);
        setPhoneNumber(phoneNumber);
    }
    //mutator methods
    //Homework: Add mutator to set the email address field. User regular
    //expressions to validate the data
    public void setFirstName(String firstName) {
        //check to see if all alpha characters
        for (char c : firstName.toCharArray()) {
            if (!Character.isAlphabetic(c)) {
                throw new IllegalArgumentException(firstName);
            }
        }
        _firstName = firstName;
    }
    //Homework: Make sure lastName is all characters and that it is at least
    //3 characters long. If not throw an Illegal argument exception. Check
    //my mutators for a hint on how to do this.
    private void setLastName(String lastName) {
        _lastName = lastName;
    }
    //Homework: add check to make sure phone number string is
    //correct length. I already did check to check for proper elements:
    //all numbers and one "-" in correct place.
    //Note the test i did could have been done using regular expressions instead
    //  Pattern pattern = Pattern.compile("\\d{3}-\\d{7}");
    //  Matcher matcher = pattern.matcher(phoneNumber);
    //  if (!matcher.matches()) {
    //     throw new IllegalArgumentException(phoneNumber);
    //   }
    private void setPhoneNumber(String phoneNumber) {
        for (int i = 0; i < phoneNumber.length(); i++) {
            char c = phoneNumber.charAt(i);
            if (!Character.isDigit(c)) {
                if (c != '-' || (c == '-' && i != 3)) {
                    throw new IllegalArgumentException(phoneNumber);
                }
            }
        }
 
        _phoneNumber = phoneNumber;
    }
    //accessor methods
    //Homework: Add accessor method for your email address field.
    public String getFirstName() {
        return _firstName;
    }
    public String getLastName() {
        return _lastName;
    }
    public String getPhoneNumber() {
        return _phoneNumber;
    }


Take the import statements out (you never need import statements in Java) and just write some code that uses the Scanner class to read a line of input and print out that line. That's a start at least.


I'm not sure what you mean by that. On the one hand, the libraries contain the code that is needed for some code to work in the program file, but on the other hand, if I can just remake that library code myself, I wouldn't need to import the libraries, and thus it would be unnecessary to import the libraries. I'm not entirely sure why you'd specify that I not import anything for the exercise, but then again, the way you've suggested that the exercise is simple even without imports, and what you've said about how import statements aren't necessary, suggests an ulterior motive of some kind. I'm not going to assume anything about that, right now, though given the trolls on the "moral objectivity" thread, I'm a little "wary" right now...

In the course, importing libraries was what we always did. The course material covered libraries enough to suggest that those libraries could be remade in the program's code, but we never learned how to do that.

schapel
Posts: 244
Joined: Fri Jun 13, 2014 1:33 am UTC

Re: Esoteric programming languages for an esoteric mind?

Postby schapel » Mon Aug 03, 2015 10:48 am UTC

Moniker Pending wrote:I'm not sure what you mean by that. On the one hand, the libraries contain the code that is needed for some code to work in the program file...

Ah, this is the first inaccurate mental model we've found. You do not need to use import to use the libraries. What the import statement does is allow you to leave off the package name when you refer to a class or interface. The import statement is not needed to make a library available. You can refer to the Scanner class with the name java.util.Scanner, or you can import all the classes in the java.util package using import java.util.* and refer to the Scanner class, or you can import only the Scanner class using import java.util.Scanner. All the import statement does is save a bit of typing for you.

To make sure you understand what import is doing, use the Scanner class to read in a line from System.in, and then print the line to System.out, without importing anything. Then you can use the import statement and shorten the rest of your program.

There's no ulterior motive. You were having problems because you didn't know what you were doing. Now that you are learning what the code you were typing was doing, you should find it much easier to type in the appropriate code.

Here's my solution (please don't peek until you've tried yourself):
Spoiler:

Code: Select all

public class JD_Contact {
    public static void main(String[] args) {
        java.util.Scanner input = new java.util.Scanner(System.in);
        String line = input.nextLine();
        System.out.println(line);
    }
}

Moniker Pending
Posts: 39
Joined: Tue Jul 28, 2015 12:59 pm UTC

Re: Esoteric programming languages for an esoteric mind?

Postby Moniker Pending » Mon Aug 03, 2015 2:55 pm UTC

schapel wrote:Ah, this is the first inaccurate mental model we've found. You do not need to use import to use the libraries. What the import statement does is allow you to leave off the package name when you refer to a class or interface. The import statement is not needed to make a library available. You can refer to the Scanner class with the name java.util.Scanner, or you can import all the classes in the java.util package using import java.util.* and refer to the Scanner class, or you can import only the Scanner class using import java.util.Scanner. All the import statement does is save a bit of typing for you.


Huh... we never went over referring to the class in the method code itself, or if we did, I don't remember it. Although, all things considered, it was probably mentioned at some point, and somehow, I couldn't find any code for any of that stuff while searching for a way to call methods from other classes in the time I searched for any way to do the assignment. I know I didn't see anything like what you've provided; using java.util.Scanner anywhere other than in an import statement is something I hadn't seen before, and you're giving me an explanation for what it's doing in that context.

So... once I got the class and the main method set up, given what you've told me, I would probably type something like the following into the main method:

Code: Select all

java.util.Scanner input = new Scanner(System.in);

String textToPrint = input.nextLine();

System.out.println(textToPrint);


Now, I wasn't sure if I'd need to repeat the whole "java.util.Scanner" after the equal sign, since this is the first I had heard of doing such a thing at all; I figured I'd just type "Scanner" for my code, and then see if it was correct after I was finished. Once I finished it, I looked at your code, and saw that I'd need to repeat the whole thing after the equal sign. Given how important syntax is in a programming language (especially in Java, from what I've been told so far) typing code doesn't seem to involve a lot of concepts, and so I can't really figure out how the code would work without someone to explain what the code means/does. Without an explanation that I'd need to type "java.util.Scanner" every time (although, the idea does make a lot more sense that way), I'd have to rely on trial -and-error to figure out how that works, which is why I went with the less sensible option at first, to try to understand it. Granted, it's not the same without a compiler, but still...

Now, would that same technique be useful for calling methods between the files I linked to?
Last edited by Moniker Pending on Mon Aug 03, 2015 6:58 pm UTC, edited 1 time in total.

User avatar
ahammel
My Little Cabbage
Posts: 2135
Joined: Mon Jan 30, 2012 12:46 am UTC
Location: Vancouver BC
Contact:

Re: Esoteric programming languages for an esoteric mind?

Postby ahammel » Mon Aug 03, 2015 3:27 pm UTC

What happens when you compile your code and run it?

Re java.util.Scanner: what you are trying to do here is access a class provided by the library "java.util" which is named "Scanner". The compiler needs to know which library provides the code for "Scanner". You can either provide a qualified name every time (java.util.Scanner), or you can use an import statement which, in essence, tells the compiler "every time I make reference to a 'Scanner' in this file, I mean the 'Scanner' class provided by the 'java.util' library." If you do neither of those things, the compiler will panic and say "Scanner? What Scanner? What's a Scanner?" and refuse to compile the program.
He/Him/His/Alex
God damn these electric sex pants!

Moniker Pending
Posts: 39
Joined: Tue Jul 28, 2015 12:59 pm UTC

Re: Esoteric programming languages for an esoteric mind?

Postby Moniker Pending » Mon Aug 03, 2015 5:45 pm UTC

ahammel wrote:What happens when you compile your code and run it?

Re java.util.Scanner: what you are trying to do here is access a class provided by the library "java.util" which is named "Scanner". The compiler needs to know which library provides the code for "Scanner". You can either provide a qualified name every time (java.util.Scanner), or you can use an import statement which, in essence, tells the compiler "every time I make reference to a 'Scanner' in this file, I mean the 'Scanner' class provided by the 'java.util' library." If you do neither of those things, the compiler will panic and say "Scanner? What Scanner? What's a Scanner?" and refuse to compile the program.


As I said, that made sense before I started typing. Since I had never heard of doing what schapel described, and he didn't explicitly rule out what I had ended up doing in his description, I figured I'd try to "simulate" the trial-and-error learning process I had to use in the course when I couldn't find a more thorough explanation. That's why I clarified what I was doing underneath, and then pointed out that the code schapel posted included what my code was missing, and noted (in a rather implicit manner, I admit) that his code was probably going to work where mine wasn't (remember, his instruction was to not peek at his code until I made my own attempt).

After copying it to Netbeans, I am alerted that the code has problems, even before attempting to compile it.

Demki
Posts: 199
Joined: Fri Nov 30, 2012 9:29 pm UTC

Re: Esoteric programming languages for an esoteric mind?

Postby Demki » Mon Aug 03, 2015 6:13 pm UTC

Moniker Pending wrote:
ahammel wrote:What happens when you compile your code and run it?

Re java.util.Scanner: what you are trying to do here is access a class provided by the library "java.util" which is named "Scanner". The compiler needs to know which library provides the code for "Scanner". You can either provide a qualified name every time (java.util.Scanner), or you can use an import statement which, in essence, tells the compiler "every time I make reference to a 'Scanner' in this file, I mean the 'Scanner' class provided by the 'java.util' library." If you do neither of those things, the compiler will panic and say "Scanner? What Scanner? What's a Scanner?" and refuse to compile the program.


As I said, that made sense before I started typing. Since I had never heard of doing what schapel described, and he didn't explicitly rule out what I had ended up doing in his description, I figured I'd try to "simulate" the trial-and-error learning process I had to use in the course when I couldn't find a more thorough explanation. That's why I clarified what I was doing underneath, and then pointed out that the code schapel posted included what my code was missing, and noted (in a rather implicit manner, I admit) that his code was probably going to work where mine wasn't (remember, his instruction was to not peek at his code until I made my own attempt).

After copying it to Netbeans, I am alerted that the code has problems, even before attempting to compile it.

That's one of the reasons I linked to oracle's Java tutorial, since they explain everything slowly and quite thoroughly along with example code and chapter specific assignments. Also because that, unlike a course, you can read it at your own pace, you can backtrack to previous chapters and so on.
Unlike a course, though, it does not have a teacher you can ask for explanation, which is quite an important part of a learning process(my physics teacher in high school always said that those that don't ask questions in class either don't learn or already know the stuff from other sources).

From reading this thread I am lead to think that your problem wasn't with the syntax of Java or some other language, but with the speed you were taught and the relative time between subjects(some things that seem obvious to most students might be difficult for others, but since no one asked questions the teacher assumed it was understood.)

User avatar
ahammel
My Little Cabbage
Posts: 2135
Joined: Mon Jan 30, 2012 12:46 am UTC
Location: Vancouver BC
Contact:

Re: Esoteric programming languages for an esoteric mind?

Postby ahammel » Mon Aug 03, 2015 6:30 pm UTC

Moniker Pending wrote:After copying it to Netbeans, I am alerted that the code has problems, even before attempting to compile it.

What error messages do you get? Do they suggest to you a way to fix your code, or are you completely lost at this point?
He/Him/His/Alex
God damn these electric sex pants!

Moniker Pending
Posts: 39
Joined: Tue Jul 28, 2015 12:59 pm UTC

Re: Esoteric programming languages for an esoteric mind?

Postby Moniker Pending » Mon Aug 03, 2015 7:10 pm UTC

Demki wrote:From reading this thread I am lead to think that your problem wasn't with the syntax of Java or some other language, but with the speed you were taught and the relative time between subjects(some things that seem obvious to most students might be difficult for others, but since no one asked questions the teacher assumed it was understood.)


Obviously, the pace of the course was a problem that contributed to my lack of an understanding, given the fact that I didn't even have the time necessary to come up with the right questions to ask during the course (I still asked plenty of questions) but it's not the only problem. I've been trying to learn how to program for a longer period of time than I've been studying some other topics.

It took me a couple of months to go all the way from "You know, maybe I should give psychoanalysis a chance, since Carl Jung's ideas seem quite different from those of that hack, Sigmund Freud, who had kept me away from psychoanalysis for so long" to "Jung should have tried accounting for his patients' perception of how others perceive themselves; he could have done a lot more with his work if he had accounted for that sort of awareness in one's subconscious." In a couple of months, I have gone from being introduced to Jungian psychoanalysis, all the way to improving on the techniques that have been used since Carl Jung first came up with them, and even using my improvements in some informal experimentation, which so far shows that my improvements actually work, enabling the techniques to account for various psychological anomalies (such as supposedly "impossible" anomalies that I have, observed in one other person I've informally analyzed so far) that Jung had apparently given up on trying to account for, and that licensed Jungian psychoanalysts often avoid working with today, because their training doesn't teach them how.

I've been trying to learn how to program for at least a decade, and I'm still struggling with the syntax.

ahammel wrote:What error messages do you get? Do they suggest to you a way to fix your code, or are you completely lost at this point?


You know, after getting a chance to wake up a little bit since I typed it up, and testing the code in NetBeans again, I've noticed another error in my code, that I've forgotten to type "nextLine();" on the line for the user input. I've edited the post, to fix that entirely careless error; the error being discussed remains.

Anyway, the "fixed" code only gives one error now, and the program suggests importing java.util.Scanner as the first suggestion. There are five other suggestions: two to import other libraries; two to make a "Scanner" class (one option involved making it with a constructor; and one option that's always included whenever there's an error in declaring something, to split the line into two lines, the first with the declaration, and the second with the assignment. Each of these options can also be automated. None of these options for fixing the error include doing what schapel was talking about.

User avatar
ahammel
My Little Cabbage
Posts: 2135
Joined: Mon Jan 30, 2012 12:46 am UTC
Location: Vancouver BC
Contact:

Re: Esoteric programming languages for an esoteric mind?

Postby ahammel » Mon Aug 03, 2015 7:30 pm UTC

Moniker Pending wrote:Anyway, the "fixed" code only gives one error now, and the program suggests importing java.util.Scanner as the first suggestion. There are five other suggestions: two to import other libraries; two to make a "Scanner" class (one option involved making it with a constructor; and one option that's always included whenever there's an error in declaring something, to split the line into two lines, the first with the declaration, and the second with the assignment. Each of these options can also be automated. None of these options for fixing the error include doing what schapel was talking about.

Does doing what shapel said, in fact, make NetBeans happy? Can you explain, in your own words, what the problem is?
He/Him/His/Alex
God damn these electric sex pants!

Moniker Pending
Posts: 39
Joined: Tue Jul 28, 2015 12:59 pm UTC

Re: Esoteric programming languages for an esoteric mind?

Postby Moniker Pending » Mon Aug 03, 2015 9:19 pm UTC

ahammel wrote:Does doing what shapel said, in fact, make NetBeans happy? Can you explain, in your own words, what the problem is?


Oh! Sorry, I didn't quite get that you wanted me to test the code made with schapel's advice applied properly. Admittedly, I was being a bit vague myself; I didn't specify that I had copied my own code as displayed in the code box, which we all knew wouldn't work right. Going back, it's kind of hard to figure out exactly where my confusion about your question began.

Anyway, yes, it works, now that it's fixed; there are no error flags in the "code display" screen, and it all compiles and runs fine.

schapel
Posts: 244
Joined: Fri Jun 13, 2014 1:33 am UTC

Re: Esoteric programming languages for an esoteric mind?

Postby schapel » Mon Aug 03, 2015 11:04 pm UTC

I don't see you having a problem with syntax. When I asked you to do something simple and specific, get a line from System.in and output it to System.out, you had no problem at all that I can see, not even with syntax. You were unused to putting the package name before the class name, but I think that was something you just didn't understand yet, and I think you do understand it now. Now you can use import statements and really know what they're doing... I think many Java programmers don't really understand what import does.

Let's try the next step, which would probably be using the Scanner to read the information for one contact, and store that information into an object. To let you know where this is going, this is an approach I often take -- get the program to do something that is a part of the ultimate goal. At some point, you may use this Scanner to read the information from a file rather than from System.in. This is kind of a way around writer's block, in that you may be stuck figuring out how to write the code in the final version, and as a result not getting anywhere. I certainly had that problem before. It even has a name: analysis paralysis.

Moniker Pending
Posts: 39
Joined: Tue Jul 28, 2015 12:59 pm UTC

Re: Esoteric programming languages for an esoteric mind?

Postby Moniker Pending » Tue Aug 04, 2015 2:49 pm UTC

schapel wrote:I don't see you having a problem with syntax.


I wouldn't say that syntax isn't an issue just yet. The program I just made was hardly profound, and the obscure technique you've taught me is just a matter of typing in the class the code is from at each instant the code is used - basically, like telling the program to go and take that particular code from that class and use it at that moment, instead of importing the code and having it stand by for use throughout the whole program. I wouldn't have been able to figure that out, if you hadn't held my hand the whole time. I even had doubts about something obvious, to the point where I had to go out of my way to bring up the question, and "test" the idea that made little sense, just to be sure. I'm not going to fault myself for being careful, but the fact is, the syntax of Java code doesn't really give me much of an idea of what the code does or does not do, or how the code can be used.

Effectively, what's really important is semantics, because like my first post said, my mind works with concepts, not words, and in order for me to work with anything, there has to be a connection between what I perceive and what's there (the words I read/hear and the concepts I read/hear about, for example, since the words are "what I perceive," but the concepts are "what's there," and I need to be able to tell what those concepts are by reading/hearing the words representing the concepts). I know that what I perceive is depends what's there, and ultimately, my mind works by understanding everything that's there to produce what is perceived, as opposed to taking anything at face value. I go through many different possibilities for what could possibly produce what I perceive, figuring out how what's there produces individual aspects of what I perceive, and this is a lot more natural to me than just taking what I perceive at face value. This is actually the true difference between an introvert and an extrovert, contrary to what's commonly believed; an extrovert examines the face value that they perceive on the exterior of what's there, whereas an introvert isn't content to merely examine the face value, instead getting into the questions of what's actually there, and how and why it produces what's perceived. Introverts would actually love to associate with others, but most of the time, when we try to associate with others, what happens is the same thing that happened when I posted on the thread about morality that ucim linked to.

Anyway, the fact that semantics is important for me means that the syntax of programming languages, which hardly describes what the code is actually doing, will be hard for me to understand.

Let's try the next step, which would probably be using the Scanner to read the information for one contact, and store that information into an object.


I'm not sure I understand what you want me to do, here. I would have had some specific questions, here, if I had posted this last night, but a storm had come, and I had to disconnect everything to prevent a lightning strike from damaging my computer or the networking components at my house (modem, router, etc.). Most of what I had typed above had to be saved in a draft. Now, my mind is still trying to wake up, and my body wants to go back to sleep. I'm trying to go through how objects were described to me earlier, and identify what part of the Java code would constitute an object, but given that I had slept long enough last night for the sleep apnea to effect me, if I try to figure that out during the next few hours, it'll just end with me staring blankly at the screen, daydreaming about something else entirely.

User avatar
ucim
Posts: 6859
Joined: Fri Sep 28, 2012 3:23 pm UTC
Location: The One True Thread

Re: Esoteric programming languages for an esoteric mind?

Postby ucim » Tue Aug 04, 2015 3:55 pm UTC

Moniker Pending wrote:...and in order for me to work with anything, there has to be a connection between what I perceive and what's there...
Yes. That's called "learning". Programming computers is one of the things in life that is not obvious - in fact, it's actually quite arbitrary (in the choice of how to represent ideas and concepts to the machine). You can't just look at a problem and "know" how to tell the computer to solve it. You have to learn the chosen language.

Once you have learned the syntax, you can grasp the semantics being expressed. But if you mess up the syntax, you won't know whether the problem in your understanding is the syntax or the semantics.

But, you can separate the two out in another way - using (do people still do this?) a flowchart. This is a graphical form of the pseudocode we played with earlier, but even more abstracted so that it's language independent. You should be able to flowchart any program you are about to write; if you can't do that (assuming you know how to flowchart in the first place!) then you don't understand the program and you shouldn't write it (yet).

You can flowchart on any scale you like; each box represents an operation that's as simple or complex as necessary for your understanding. It might be worthwhile for you to give it a shot, and let us know what you think, what problems you have with it, and where it seems to help or not.

Jose
Order of the Sillies, Honoris Causam - bestowed by charlie_grumbles on NP 859 * OTTscar winner: Wordsmith - bestowed by yappobiscuts and the OTT on NP 1832 * Ecclesiastical Calendar of the Order of the Holy Contradiction * Heartfelt thanks from addams and from me - you really made a difference.

User avatar
ahammel
My Little Cabbage
Posts: 2135
Joined: Mon Jan 30, 2012 12:46 am UTC
Location: Vancouver BC
Contact:

Re: Esoteric programming languages for an esoteric mind?

Postby ahammel » Tue Aug 04, 2015 4:08 pm UTC

I'm trying to go through how objects were described to me earlier, and identify what part of the Java code would constitute an object[...]
In this snippet:

Code: Select all

java.util.Scanner input = new java.util.Scanner(System.in);
String textToPrint = input.nextLine();
System.out.println(textToPrint);

'java.util.Scanner' is a class, and 'input' is an object (specifically, it's an instance of Scanner). Scanner objects know (presumably among other things) how to grab lines of text from user input. The statement 'input.nextLine()' calls the 'nextLine' method on the Scanner object named 'input', which returns a string. (Some people like to think of this as sending the message 'nextLine' to the object called 'input' and getting a string as a response.)

Moniker Pending wrote:I'm not sure I understand what you want me to do, here.

I think the ask is to modify your program such that it:
1. Takes several lines of text from user input corresponding to the first name, last name, email address, and phone number. of a new contact
2. Uses those data to create a new instance of JD_ContactClass (this will use syntax similar to making a new instance of Scanner)
3. Prints out the name and contact info of the new contact

ucim wrote:But, you can separate the two out in another way - using (do people still do this?) a flowchart.
People do that all the time. I can see four of them from where I'm sitting right now. Excellent suggestion.
He/Him/His/Alex
God damn these electric sex pants!

Moniker Pending
Posts: 39
Joined: Tue Jul 28, 2015 12:59 pm UTC

Re: Esoteric programming languages for an esoteric mind?

Postby Moniker Pending » Tue Aug 04, 2015 4:49 pm UTC

ucim wrote:Yes. That's called "learning". Programming computers is one of the things in life that is not obvious - in fact, it's actually quite arbitrary (in the choice of how to represent ideas and concepts to the machine). You can't just look at a problem and "know" how to tell the computer to solve it. You have to learn the chosen language.


Now that my mind is slightly more awake, and my memory of last night is more "present," I remember that if I was able to finish the whole post last night, I would have typed that point more clearly, instead of having to sum it all up in the single sentence I had typed at the end of my addressing of the first quote. Basically, with other things that I don't understand yet, I still have leads that I can investigate, and during my investigation, I can understand what I'm investigating in terms of what I already know. For example, the improvements I made on Jung's methods, which I mentioned earlier, were easy for me, because I already had experience with that sort of thinking, and adapting it to Jung's methods once I knew them was as natural to me as breathing. The reasons for which my improvements weren't already being used are harder to figure out; honestly, the reasons seem pretty arbitrary.

With code, there's not much to investigate. Like you said, I have to learn the language, but even when looking at text in other non-programming languages, I can still make an easy connection, because it's pretty easy for me to figure out how the whole thing translates when I have access to dictionaries that can translate individual terms into English, and grammatical guides that allow me to re-arrange the whole thing, until I basically have the text in English. When I look at guides to programming languages, the "translation" that they offer isn't complete; I often have to understand more advanced code in terms of abstractions of simpler code, and even when I can get an explanation in English words, it's often in jargon that I can't link directly to a concept I already understand. The fact that the jargon is mostly explained in terms of other jargon is why I couldn't understand what an "object" was for so long; I could come up with multiple possible definitions, but they were mutually exclusive with each other, and I couldn't find any leads with which I could figure out what was the right definition, if any.

Even terms like "stack and heap" are things I could only understand by connecting them to "base ID's and reference ID's" in the Gamebryo Engine used by Bethesda, and I still have to see the terms being used to remember which is which, since when I think of the terms "stack and heap," I think of a "stack" as being just a more orderly form of a "heap," using the terms as they mean in basic English, which doesn't really connect well with what they mean in programming.

But, you can separate the two out in another way - using (do people still do this?) a flowchart. This is a graphical form of the pseudocode we played with earlier, but even more abstracted so that it's language independent.


I can grasp the operations being performed just fine - those are like the concepts that my mind works with. I just can't figure out what code relates to which operation, or how to write the code to fit the operation, when actually working with a language.

EDIT: Because the code is so hard to understand, I have to adjust the operations in ways that my mind would normally consider arbitrary and inefficient, just so I can try to get the code to perform the function I need it to perform. The code doesn't handle operations in the same way my mind does, so it's even harder. I understand that that's how it needs to work, but still...

..........

ahammel wrote:In this snippet:

Code: Select all

java.util.Scanner input = new java.util.Scanner(System.in);
String textToPrint = input.nextLine();
System.out.println(textToPrint);

'java.util.Scanner' is a class, and 'input' is an object (specifically, it's an instance of Scanner). Scanner objects know (presumably among other things) how to grab lines of text from user input. The statement 'input.nextLine()' calls the 'nextLine' method on the Scanner object named 'input', which returns a string. (Some people like to think of this as sending the message 'nextLine' to the object called 'input' and getting a string as a response.)

I think the ask is to modify your program such that it:
1. Takes several lines of text from user input corresponding to the first name, last name, email address, and phone number. of a new contact
2. Uses those data to create a new instance of JD_ContactClass (this will use syntax similar to making a new instance of Scanner)
3. Prints out the name and contact info of the new contact


Okay... so, I'm thinking I should take the input in the main method of JD_Contact, and store it in an object, then use schapel's technique to get that variable from JD_Contact to JD_ContactClass, and have JD_ContactClass do the rest of the work at that point... would that be correct? Anyway, it'll take me a while, for aforementioned reasons, and because I've gotten out-of-practice since the class ended.

User avatar
ucim
Posts: 6859
Joined: Fri Sep 28, 2012 3:23 pm UTC
Location: The One True Thread

Re: Esoteric programming languages for an esoteric mind?

Postby ucim » Tue Aug 04, 2015 6:03 pm UTC

Moniker Pending wrote:When I look at guides to programming languages, the "translation" that they offer isn't complete; I often have to understand more advanced code in terms of abstractions of simpler code...
Yes. Like math, programming needs to be learned in order. If you try to learn an advanced topic before the basics, you'll end up needing to learn the basics (badly) in order to understand the advanced topic you're applying yourself to, so it's usually better to learn the basics (well) first. Then the advanced topics become just as easy to learn, because you have the basics down.

(This is also a problem with learning math from wikipedia instead of from a textbook.)

Moniker Pending wrote:I think of a "stack" as being just a more orderly form of a "heap," using the terms as they mean in basic English, which doesn't really connect well with what they mean in programming.
Actually, they do. The "heap" is just a bunch of storage which the programmer gets to manage (typically by asking for a bunch and remembering exactly where it is), the "stack" is a specific (linearly) ordered part of memory which is accessed on one end only. You "push" something into that end and it pushes everything else back.... the last thing pushed is the only thing you can access, until you "pop" it out so what's behind it becomes available.

Moniker Pending wrote:EDIT: Because the code is so hard to understand, I have to adjust the operations in ways that my mind would normally consider arbitrary and inefficient, just so I can try to get the code to perform the function I need it to perform. The code doesn't handle operations in the same way my mind does, so it's even harder. I understand that that's how it needs to work, but still...
Using a flowchart, how does the code work? Using a flowchart, how does your mind envision the same task?

Jose
Order of the Sillies, Honoris Causam - bestowed by charlie_grumbles on NP 859 * OTTscar winner: Wordsmith - bestowed by yappobiscuts and the OTT on NP 1832 * Ecclesiastical Calendar of the Order of the Holy Contradiction * Heartfelt thanks from addams and from me - you really made a difference.

Moniker Pending
Posts: 39
Joined: Tue Jul 28, 2015 12:59 pm UTC

Re: Esoteric programming languages for an esoteric mind?

Postby Moniker Pending » Wed Aug 05, 2015 1:39 am UTC

Sorry for the delay; I had a doctor's appointment that I had forgotten, and had to scramble to meet, at 2:30 (UTC -05:00), and soon after I got back, a storm came, and knocked out the power to my house. It was restored not too long ago. As such, much of my "fully-awake" time today has been made unavailable for the purposes of this thread.

ucim wrote:Yes. Like math, programming needs to be learned in order. If you try to learn an advanced topic before the basics, you'll end up needing to learn the basics (badly) in order to understand the advanced topic you're applying yourself to, so it's usually better to learn the basics (well) first. Then the advanced topics become just as easy to learn, because you have the basics down.

(This is also a problem with learning math from wikipedia instead of from a textbook.)


Well, I've read a bunch from both the internet and from textbooks. Actually, the textbook for the course didn't help me that much. I couldn't get much of the information I needed in the chapters I had to read, even for the assignments in those chapters, and so the textbook was only useful to me for the required assignments; most of the information I got had to be from various online sources. You'd think a book that thick and expensive would have had a better explanation of the concepts within, but nope - it was an extra $173 I had to spend at the college bookstore at the last minute (the school site didn't say anything about the textbook until two days before the course began), and without having any better way to store the book, it's now in quite poor condition from being repeatedly stuffed into a worn backpack, and so that's $173 I'm not getting back.

I have a bunch of textbooks that I've gathered over the years, but I've gotten similar results from all of them. I have a "C++ for Dummies" book lying around somewhere, and the book contained more unfunny jokes than any useful information. The textbook I got when I tried learning X86 Assembly with the therapist, as mentioned before, went through general concepts for several chapters, but as far as I had gotten in the book, there wasn't adequate instruction for me to make even the simplest of programs (though I'm not sure how simple that would be, given the low-level nature of the language).

Another reason I can't rely too much on textbooks, and also information that might be useful for this thread:
Spoiler:
Given my income of $300 a month from my disability check, plus whatever my parents pay for bills and most of the groceries (thus keeping that burden off of myself), and the regular expenses for gas (living out in the country, it's not a small expense), medicine, whatever food my parents don't buy, etc., I don't have a lot of money with which to buy much of anything else, including textbooks. I'd get a job, but given my psychological differences, my lack of charisma, my poor coordination, the fact that I have to use frequent adrenaline rushes of various strength to make up for my severely atrophied, aching muscles every time I need strength (which can easily make me into something like The Incredible Hulk for a short while, but doesn't help with extended manual labor) and so on, I'm not going to be able to get employment in any field that doesn't need a college degree, which I don't have yet, and I'm still not sure which degree I want (the reason I went into computer science in the first place was to learn how to program a video game I've had an idea for for a long time, and want to make so I can pay for a more meaningful second trip to college; right now, it looks like the game will be a PnPRPG instead).

Without that paper saying that I'm qualified to do something more advanced, I won't be able to get a job. It doesn't matter that my IQ would have qualified me for MENSA membership back when it was still being held down by religious fanaticism; it doesn't matter that the psychological doctors and social workers have taken on a purely supportive role in all of the work on analyzing my mind, handing it to the one person they know of who is competent enough to lead the study and have a chance of figuring me out (that would be myself), or that I've been able to impress some of them with my own ability to psychoanalyze them (the more stubborn ones just get mad when I point out their cognitive dissonance and other errors); it doesn't matter that I've understood and worked with many advanced concepts before I had ever even heard of them. It doesn't matter what I can prove by showing people what I can do; I need a college degree to do it for me, before I can get a job.


Actually, they do. The "heap" is just a bunch of storage which the programmer gets to manage (typically by asking for a bunch and remembering exactly where it is), the "stack" is a specific (linearly) ordered part of memory which is accessed on one end only. You "push" something into that end and it pushes everything else back.... the last thing pushed is the only thing you can access, until you "pop" it out so what's behind it becomes available.


Huh... the way it was explained in the course and elsewhere, I thought that the difference was that one stored data with which to generate references, and the other stored references to that data during use. The professor explained it by telling students to imagine monsters fought in a computer game; one would store the data for the monster type, and that data would be used to generate copies of the monsters, whereas the other would store the data for already-generated copies of the monsters, such as current HP, status changes, location, and so on.

Then again, it could be that I'm thinking of something other than "stack and heap" this whole time. Like I said, terminology is hard for me.

Moniker Pending wrote:Using a flowchart, how does the code work? Using a flowchart, how does your mind envision the same task?


Is there a way for me to make flowcharts that can be displayed here? Right now, it won't be too hard, but with something more advanced, I'll have trouble.

With the code typed so far, I can't see much of a significant difference in efficiency or usefulness; my process has one less step, but that's it. For this purpose, assume that my own process is independent of computer code; it could be during a conversation, for example. Also, assume that the task is performed on its own, isolated from any other task; for example, the steps I list wouldn't cover making the Xanatos Gambits I often make with my questions in debates, my internal questioning of why someone would be asking me to repeat what they say if unclear, accounting for any need to change the information in output from what it was in input, or the processes I go through anyway in translating from words to concepts and back (described in the first post).

(Why I make Xanatos Gambits with my questions in debates)
Spoiler:
As an extreme introvert, my positions aren't my claims, but my reasoning, and the claim is just a product of that reasoning; I treat my opponents' positions in debates the same way, which is why I focus more on why my opponents are making their claims, and less on the claims themselves. The Xanatos Gambit in the question, therefore, could lead either to exposing the opponents' flawed reasoning, or showing me that my opponent is actually reasoning properly, perhaps even better than I am; with the former result, I can win the debate, but with the latter result, I will have found someone worthy of the more intelligent and challenging discussions that I long for, perhaps even learning something myself. Either way, I win in some way, thus making the question a Xanatos Gambit.

I haven't done it in this thread so far, since this isn't a debate, and I don't really have enough confidence in my understanding of what I'm working with at this point to engage in a debate.


Code:
Step 1: Set up a way of getting the data to use.
Step 2: Declare a String variable
Step 3: Wait for the user to enter data.
Step 4: Store the data entered by the user into the variable declared in step 2.
Step 5: Print out the data.

My idea:

Step 1: Become aware of the task, that I'm to repeat information back to whoever gives
Step 2: Wait for information to be presented.
Step 3: Mentally acknowledge the information that is presented.
Step 4: Repeat the information that was presented.

Like I said, I understand that the code has to include steps that wouldn't be necessary for me. In a Discrete Mathematics course, I heard about how the hardware needed to add numbers like a human would was extremely expensive in the early days of digital computing, so the hardware was designed to work around that by using a rather complex process involving subtraction (I don't remember exactly what that process was), just to add numbers together at the binary level (or equivalent, for experimental or obsolete systems). As far as I'm aware, that workaround is still used in computers today.

User avatar
ahammel
My Little Cabbage
Posts: 2135
Joined: Mon Jan 30, 2012 12:46 am UTC
Location: Vancouver BC
Contact:

Re: Esoteric programming languages for an esoteric mind?

Postby ahammel » Wed Aug 05, 2015 1:46 am UTC

Moniker Pending wrote:Is there a way for me to make flowcharts that can be displayed here?
draw.io or the Google drive drawing program whose name I forget just now.
He/Him/His/Alex
God damn these electric sex pants!

User avatar
ucim
Posts: 6859
Joined: Fri Sep 28, 2012 3:23 pm UTC
Location: The One True Thread

Re: Esoteric programming languages for an esoteric mind?

Postby ucim » Wed Aug 05, 2015 2:46 am UTC

The public library is a great resource. At least in the United States, most places have a public library; it's free, and even if it's tiny it can get you books from anywhere in the country (on loan, of course). And if it's a decent sized town, there is nothing better than the public library. Not even the internet. (And public libraries often have internet.)

A flowchart is just a drawing - you can create one in any drawing program. Windows and Mac both come with simple ones that will do the trick. Windows has Paint, dunno the name of the Mac one. There are more sophisticated tools, but for now, KISS. You can then upload the files to xkcd in .jpg format.

KISS to the Xanatos gambits too. Focus just on the task. No need for Xanatos here.

Moniker Pending wrote:My idea:

Step 1: Become aware of the task, that I'm to repeat information back to whoever gives
Step 2: Wait for information to be presented.
Step 3: Mentally acknowledge the information that is presented.
Step 4: Repeat the information that was presented.
Ok, good start. Now think of it from the computer's point of view.

"Becoming aware of the task" is essentially the "start" condition. The user runs the program (or the program calls your subroutine).

Between step 2 and step 3, the information has to make it into the computer. So, the "wait for..." step needs to include (or be followed by) an "accept the input" step. It also needs to include (or be preceded by) a "display input form" step. It's your choice whether to make these implicit or explicit; this depends on how detailed you want your flowchart to be. Part of the reason for doing it is the abstraction it provides - so each of these boxes hides the nitty gritty and lets you see the overall flow. And the other part of the reason is to visually show you the program flow so that you don't forget stuff.

Step 3 would correspond to the computer storing the input somewhere (and perhaps informing the user that the input was accepted).

You should have a step 5: End.

There are special shapes that are standard in flowcharts you can use if you like (a diamond indicates a decision branch (with lines coming out the vertices), a rectangle indicates an ordinary task, a parallelogram indicates IO, an oval indicates start/end) - you might as well use the standard symbols. You only need a few - the ones I mentioned should be sufficient.

So... once you have your flowchart laid out, step through it and think of what is happening to your data at each step. Make sure it's what you want.

Then, in your chosen language, you can replace each of these shapes with the appropriate computer code. And that is the mapping between your idea and the actual program.

Jose
Order of the Sillies, Honoris Causam - bestowed by charlie_grumbles on NP 859 * OTTscar winner: Wordsmith - bestowed by yappobiscuts and the OTT on NP 1832 * Ecclesiastical Calendar of the Order of the Holy Contradiction * Heartfelt thanks from addams and from me - you really made a difference.

Moniker Pending
Posts: 39
Joined: Tue Jul 28, 2015 12:59 pm UTC

Re: Esoteric programming languages for an esoteric mind?

Postby Moniker Pending » Wed Aug 05, 2015 3:41 pm UTC

ahammel wrote:draw.io or the Google drive drawing program whose name I forget just now.


Thanks for the suggestion. I'm not used to drawing on the computer; even with my coordination problems and atrophied muscles, I'm a lot better at controlling a pencil than a mouse cursor, especially for making visuals. Still, since I wouldn't be making artwork, so it wouldn't matter that much. It might cause me stress if the design isn't as "pleasing" as it would be on paper, given my artistic standards, but that's my problem, not yours, and my handwriting isn't as good as my drawing skills. For the purposes of this thread, an image made on a computer would be better.

..........

ucim wrote:The public library is a great resource. At least in the United States, most places have a public library; it's free, and even if it's tiny it can get you books from anywhere in the country (on loan, of course). And if it's a decent sized town, there is nothing better than the public library. Not even the internet. (And public libraries often have internet.)


The public library in my town is the size of a large shed, and doesn't have enough space for a computer science section; anything larger in the area would be at one of the public K-12 schools, and being that I'm not a student at any of them, I wouldn't have access to those libraries. I could drive into the city an hour away, and try to find parking within walking distance of the library (which, with my muscle problems mentioned in the first of the spoiler boxes in my previous post, isn't as far as it is for most people, unless I have something to stimulate an adrenaline rush long enough to get me where I'm going, and even the music in my head can't do that much), and even then, keeping the book in the same condition it was checked out in will be its own problem, given what I had available to store the Java textbook, which is still all I have for storing any similarly-sized books. I have a laptop bag, which could store smaller books, but that's about it.

A flowchart is just a drawing - you can create one in any drawing program. Windows and Mac both come with simple ones that will do the trick. Windows has Paint, dunno the name of the Mac one. There are more sophisticated tools, but for now, KISS. You can then upload the files to xkcd in .jpg format.

KISS to the Xanatos gambits too. Focus just on the task. No need for Xanatos here.


But... it's just so tempting!

Tongue-in-cheek aside, with the Xanatos Gambits, I was talking about how there are many different context-dependent steps I could be take while handling the task in question, or even as part of how I handle that same task. The code on the computer, on the other hand, would work the same no matter what the context was.

"Becoming aware of the task" is essentially the "start" condition. The user runs the program (or the program calls your subroutine).

...

You should have a step 5: End.


Not quite, given that this was a description of how my mind would handle things; since my mind is constantly running, "becoming aware of the task" would be more of an "if" statement. I suppose it might be hard to tell, though, given that the program itself (assuming it's on a personal computer) is being accessed via a computer that's already on, being accessed from an operating system that's already running, like my mind. Given how everything else is so interwoven with that "program" when it's actually happening, I wouldn't call the real "program" the equivalent of a separate program from the "OS" of my mind, but with the additional steps I had to leave out, I could probably account for all of that in a separate "program," anyway. That, of course, is just one of the ways in which it's hard to compare the processes of a digital computer and a human brain, let alone a brain whose processes, and even the existence of such processes, can't be explained by modern psychology.

Otherwise, I'm aware of the parallels; the same task is being done, after all, and there are only so many ways that such a simple task can be handled. If I were to describe a more complex task, I probably wouldn't know how exactly how the code would handle the task, though I'd recognize that the steps aren't what I would do.

There are special shapes that are standard in flowcharts you can use if you like (a diamond indicates a decision branch (with lines coming out the vertices), a rectangle indicates an ordinary task, a parallelogram indicates IO, an oval indicates start/end) - you might as well use the standard symbols. You only need a few - the ones I mentioned should be sufficient.


This will help... I think. I'm not accustomed to making flowcharts in a visual medium (The Xanatos Gambits are more like plotting out the path to every conceivable outcome on an individual basis, albeit somewhat simultaneously with my multi-threaded subconscious), let alone making flowcharts for this purpose, so I won't know until I start.

Then, in your chosen language, you can replace each of these shapes with the appropriate computer code. And that is the mapping between your idea and the actual program.


The problem is, I don't know what the appropriate computer code is. That's perhaps the biggest difficulty I have with computer science overall; in order to learn the code's "words," I have to try to work with the code's "concepts," but in order to understand how to work with the code's "concepts," I have to know how the code handles those "concepts" with its "words," so it's kind of a circular paradox in which I have to already know the code's "words" in order to learn the code's "words."

User avatar
ucim
Posts: 6859
Joined: Fri Sep 28, 2012 3:23 pm UTC
Location: The One True Thread

Re: Esoteric programming languages for an esoteric mind?

Postby ucim » Wed Aug 05, 2015 4:19 pm UTC

Moniker Pending wrote:I was talking about how there are many different context-dependent steps I could be take while handling the task in question, or even as part of how I handle that same task. The code on the computer, on the other hand, would work the same no matter what the context was.
Could you give an example? I'm not following.

Moniker Pending wrote:If I were to describe a more complex task, I probably wouldn't know how exactly how the code would handle the task, though I'd recognize that the steps aren't what I would do.
When designing the flowchart, you don't have to worry about the code, just the logic. And that logic would be roughly the same either way.
Spoiler:
1: <is there a product waiting to be shipped?> -->No? keep waiting and checking. ("go to 1")
|
v
yes? continue below

2: [identify the product]
3: [identify the customer]
4: [look up the address]
5: <Found it?> --> no? [send product to lost-and-found]
|
v
yes? continue below

6: [Write address on label]
7: [put product in box]
8: [seal box]
9: [send box down conveyer]
10: (go to 1 - wait for next product)

In real life, as a shipping clerk, you might take many differnet approaches depending on your mood, and each of those approaches will work. Which means any of those approaches will work. Which means you can pick one and flowchart it and program it into the computer. The computer doesn't care - it has no moods.
Moniker Pending wrote:That's perhaps the biggest difficulty I have with computer science overall; in order to learn the code's "words," I have to try to work with the code's "concepts," but in order to understand how to work with the code's "concepts," I have to know how the code handles those "concepts" with its "words," so it's kind of a circular paradox in which I have to already know the code's "words" in order to learn the code's "words."
...which is why it's done a little at a time. You learn a few concepts and a few words to implement them. Then you learn a few more concpts and a few more words. Soon you realize that if you knew all this before, you could have done your first few exercises differently. (It's a problem that crops up when you try to teach yourself coding by working on a real problem.) But this was just an exercise, so it's ok that it was not as efficient as it could be if only you knew {whatever}. Future exercises will use it. :)

Jose
Order of the Sillies, Honoris Causam - bestowed by charlie_grumbles on NP 859 * OTTscar winner: Wordsmith - bestowed by yappobiscuts and the OTT on NP 1832 * Ecclesiastical Calendar of the Order of the Holy Contradiction * Heartfelt thanks from addams and from me - you really made a difference.

User avatar
ahammel
My Little Cabbage
Posts: 2135
Joined: Mon Jan 30, 2012 12:46 am UTC
Location: Vancouver BC
Contact:

Re: Esoteric programming languages for an esoteric mind?

Postby ahammel » Wed Aug 05, 2015 4:27 pm UTC

Moniker Pending wrote:
ahammel wrote:draw.io or the Google drive drawing program whose name I forget just now.


Thanks for the suggestion. I'm not used to drawing on the computer; even with my coordination problems and atrophied muscles, I'm a lot better at controlling a pencil than a mouse cursor, especially for making visuals. Still, since I wouldn't be making artwork, so it wouldn't matter that much. It might cause me stress if the design isn't as "pleasing" as it would be on paper, given my artistic standards, but that's my problem, not yours, and my handwriting isn't as good as my drawing skills. For the purposes of this thread, an image made on a computer would be better.
If you prefer to just draw on paper and take a picture of it if you want to share, that's fine with me. The diagrams are for your benefit, not ours.
He/Him/His/Alex
God damn these electric sex pants!

Moniker Pending
Posts: 39
Joined: Tue Jul 28, 2015 12:59 pm UTC

Re: Esoteric programming languages for an esoteric mind?

Postby Moniker Pending » Wed Aug 05, 2015 5:24 pm UTC

ucim wrote:Could you give an example? I'm not following.


I've already given some examples, such as wondering why I was being asked to repeat something (and where the person asking me was going with it; it could be a prank, or something like that), or the Xanatos Gambits... unless you want something specific?

Well, when I was first battling the infamous troll John Fontes on the Atheist Republic's Facebook page, he challenged me to come up with a moral system that didn't rely on a god of some kind (as per the debate), and I actually had a description of my moral system and its axioms typed up rather nicely (though it was informal, and since Fontes has been banned from that page, I can't access what I had typed anyway), but with one flaw intentionally inserted, being that I described using boolean variables for the whole thing, instead of using trinary logic variables where appropriate. I did this as a means of testing Fontes, in a similar manner in which I test many trolls, to see if he'd notice the flaw (I've done that with my description of Nietzsche to the pseudo-intellectual trolls on the thread you've linked to, as well; I'm certain I did so with the one who had PM'd me, but I don't recall if I did so on the thread itself. For all of the objections, they couldn't actually point out what the flaw was.). He didn't notice the flaw at all, until I actually told him about it, just to deal another blow to his ego, and after that, he still didn't seem to know quite what I had said, but he still kept insisting on an operational definition (which I had given already), and insisting that something objective can only be quantitatively measured, as opposed to qualitatively, despite the proof I had given him in several articles on reputable sites showing otherwise. Eventually, he gave up, and ran away like an indignant coward, weeks after everyone else had left, which had reduced the whole "debate" to him and myself until I had won.

Anyway, that was only one of the flaws I had intentionally inserted into my arguments against him, and he had failed to notice all of them.

When designing the flowchart, you don't have to worry about the code, just the logic. And that logic would be roughly the same either way.


Unfortunately, I have to make sure the code can handle the logic. The fact that the code's logic is different from my own means that I'll have to change my own logic into something that the code can handle, and I'm not sure what it can handle when it comes to more advanced tasks.

...which is why it's done a little at a time. You learn a few concepts and a few words to implement them. Then you learn a few more concpts and a few more words. Soon you realize that if you knew all this before, you could have done your first few exercises differently. (It's a problem that crops up when you try to teach yourself coding by working on a real problem.) But this was just an exercise, so it's ok that it was not as efficient as it could be if only you knew {whatever}. Future exercises will use it. :)


That's good advice for learning in general, but if my pace is too slow, my grades will suffer in whatever courses I take, and therefore, my GPA will suffer. My GPA for the Summer semester, in which I only had the Java course, was about 1.6 or so, compared to my overall GPA before that, which was about twice as high. Furthermore, with that course being an introductory course, I'm thinking that my performance in future courses will depend on the knowledge gained in that one course, even if the languages are different. I'm already signed up for another course with the same professor, but I'm not sure if I should continue with that; I've actually sent him an email with a link to this thread, so hopefully he'll be able to give me advice before the next semester begins.

..........

ahammel wrote:If you prefer to just draw on paper and take a picture of it if you want to share, that's fine with me. The diagrams are for your benefit, not ours.


I dunno. It's like a phobia for me; when I'm making a diagram on a computer, I worry about having uniformity in the diagram's format, down to the pixel. I get less obsessive when I'm making artwork, but I think it's because there's the option to make the format uniform down to the pixel that I get obsessed with actually doing so.

Anyway, my scanner doesn't work very well. The scanning area is covered in scratches, I'm not sure if it has compatible drivers with my laptop's OS, and the desktop it's connected to has been unusable for at least a month or two, since it got infected with almost 70 high-severity viruses from loading a single page (speaking of which, DO NOT go to the website called "Science 2.0." It was linked to by a troll who couldn't make his own argument, and so I had to go there to see what I'd be refuting. I already knew the site was illegitimate, given the garbage I had seen on the articles before, but I had no idea it was that illegitimate.). I'm still trying to find the time to start fixing that computer; in the meantime, I don't think I'd want to use my laptop's low-quality webcam to take a picture; the image was extremely low-res and grainy, to the point where it might even mess up a diagram.

User avatar
PolakoVoador
Posts: 1028
Joined: Fri Jun 10, 2011 11:11 pm UTC
Location: Brazil

Re: Esoteric programming languages for an esoteric mind?

Postby PolakoVoador » Wed Aug 05, 2015 7:30 pm UTC

Moniker Pending wrote:
When designing the flowchart, you don't have to worry about the code, just the logic. And that logic would be roughly the same either way.
Unfortunately, I have to make sure the code can handle the logic. The fact that the code's logic is different from my own means that I'll have to change my own logic into something that the code can handle, and I'm not sure what it can handle when it comes to more advanced tasks.


If you can put the logic into a flowchart, you can put it in code. How easy (or how hard) it will be to translate the flowchart to code will depend on the language and the complexity of the task you are trying to perform. Since you're trying to write introductory programs, you can rest assured that the code will handle just fine whatever you put into the flowchart.

User avatar
ucim
Posts: 6859
Joined: Fri Sep 28, 2012 3:23 pm UTC
Location: The One True Thread

Re: Esoteric programming languages for an esoteric mind?

Postby ucim » Wed Aug 05, 2015 9:34 pm UTC

Moniker Pending wrote:Well, when I was first battling the infamous troll...
The infamous troll is irrelevant here. But the computer takeaway is that in this context you are testing your input (in real life) by putting in that flaw. Testing the input is (sometimes) a good thing to do when creating a function - a function that adds two integers might want to check to see if it's actually being fed integers and not strings.

In some cases you can trust the input, and the extra testing only slows the program down. In other cases (interactive web programming!) you can never trust the input. So, if you were writing a function to take input from the web, you'd certainly test the values before using them. But if you were writing a function to take input from an isolated database you had created and populated, you might not need to.

However, for the purpose of learning to code, only one of these situations will be of interest, and you know what it is. You have your context, so you can make those decisions (be it "real life" or computer code). Just create your flowchart to it, and then code the flowchart.

Moniker Pending wrote:Unfortunately, I have to make sure the code can handle the logic.
No, you just have to make sure that your logic (your flowchart) is... er... logical. If it covers all the bases that it's supposed to (without worrying about other things - KISS, remember!) As you work on the flowchart, you may discover logical flaws in it - correct them in the flowchart until it all makes logical sense, (e.g. all the information is available at the step where it is needed). Then you can write the code that actually makes it work.

Moniker Pending wrote:but if my pace is too slow, my grades will suffer...
If that is the case, then study on your own before you take the course, even if it means doing it for a full semester, a semester before. It's like auditing. (Maybe you can even audit a course before taking it for real). That way things will at least be familiar.

Moniker Pending wrote:I dunno. It's like a phobia for me; when I'm making a diagram on a computer, I worry about having uniformity in the diagram's format...
Good... you know what it is that you have to overcome. This will help you overcome it. (But it is you that has to do the overcoming!) Do what you can, post what you do, and you'll get better at it.

Jose
Order of the Sillies, Honoris Causam - bestowed by charlie_grumbles on NP 859 * OTTscar winner: Wordsmith - bestowed by yappobiscuts and the OTT on NP 1832 * Ecclesiastical Calendar of the Order of the Holy Contradiction * Heartfelt thanks from addams and from me - you really made a difference.

Moniker Pending
Posts: 39
Joined: Tue Jul 28, 2015 12:59 pm UTC

Re: Esoteric programming languages for an esoteric mind?

Postby Moniker Pending » Wed Aug 05, 2015 9:48 pm UTC

Sorry, everyone, but I wasn't able to get much done today... I've had the second notably painful (that is, more so than the usual) migraine to last the whole day this week. I'm not sure what's going on; at first, I thought the pain was from resting my head on the uncomfortably hard arm of a new couch, and even hitting my head on it when I lay down, but the pain would have started earlier if it was caused by that. So many problems to deal with, lately...

I'm not saying I'm giving up, but it'll probably take a while for things to get going.

BedderDanu
Posts: 39
Joined: Tue Jan 14, 2014 6:18 am UTC

Re: Esoteric programming languages for an esoteric mind?

Postby BedderDanu » Thu Aug 06, 2015 10:02 pm UTC

Moniker Pending wrote:Sorry, everyone, but I wasn't able to get much done today... I've had the second notably painful (that is, more so than the usual) migraine to last the whole day this week. I'm not sure what's going on; at first, I thought the pain was from resting my head on the uncomfortably hard arm of a new couch, and even hitting my head on it when I lay down, but the pain would have started earlier if it was caused by that. So many problems to deal with, lately...

I'm not saying I'm giving up, but it'll probably take a while for things to get going.


Spoiling, because off topic.
Spoiler:
For whatever it is worth, when I get a headache I try to imagine a line around where the headache is "located". Then I imagine that the pain is caused by there being water in that area. Once I've "converted" the pain into water, I slowly have it drip down the back of my neck, shrinking the water in my head until it is all gone.

I find it works really well on stress headaches, or from ones caused by dehydration/hunger that stick around after water or food has been consumed. It feels mentally relaxing to me, which is sometimes the little kick in the pants some headache medicines need to start working (it makes you notice the fact that they are working)

Moniker Pending
Posts: 39
Joined: Tue Jul 28, 2015 12:59 pm UTC

Re: Esoteric programming languages for an esoteric mind?

Postby Moniker Pending » Mon Aug 17, 2015 1:58 am UTC

(Another tangent, unfortunately; this post will be more of another meta-post about the thread itself, rather than the topic being discussed within the thread.)

You're probably wondering why I haven't posted in 11 days... I had instructed my mother to post a message about it here, but it seems she typed it up in a PM to ucim, rather than in a post on this thread, despite my instructions. Ah, well... At least ucim knew that I'd be absent.

The thing is, I've been hospitalized, and I was only recently allowed access to a computer. Without getting into too many personal details, I have absolutely no idea how much longer I will be able to access this site; the hospital's policy typically bans social media and forum access. I could be absent for days, weeks, months, or longer, depending on how things are handled from this point onward, and the possibility of a legal battle may complicate things even further. Needless to say, I've dropped the C# course next semester... For now, I'm not sure how much longer my access to this site will last; the hospital's policy is to ban access to social media and forums while patients are accessing the internet. Right now, though, I will have to put this thread on hiatus.

Tyndmyr
Posts: 11443
Joined: Wed Jul 25, 2012 8:38 pm UTC

Re: Esoteric programming languages for an esoteric mind?

Postby Tyndmyr » Fri Aug 21, 2015 7:53 pm UTC

Wish I'd seen this earlier. Replying anyway. I've grabbed a couple of quotes that seem to sort of summarize the difficulty you are currently experiencing. I do hope you'll be feeling better soonly, and will be able to read this again reasonably soon, but if not, well...whenever you get back, I'm sure I'll still be here.

Moniker Pending wrote:In terms of programming, I suppose I couldn't successfully make a program with ambiguous code anyway, but to me, the code I've worked with is ambiguous. My mind doesn't work with words; my mind works with concepts, and while concepts can't really be worked with in any direct form while programming, there are several steps in between that would also work better for me than working with words. I'm hoping there's a programming language out there that doesn't use the same semantics that other languages use. Perhaps the idea of a language involving Jungian symbolism is a stretch, even if it still displays the symbols with words. If the words have a clearer connection to the concepts, that would probably help, at least somewhat.


Moniker Pending wrote:Even in the aforementioned game I'm designing, in which the setting is kind of an "anachronistic high/epic fantasy" setting, I like to have a general idea of how the fantastical parts of the setting work. For example, wizards in my game are basically scientists who can apply their knowledge using "energetic plasma" that responds to mental "commands" (basically, it reacts to biochemical processes in the brain, which are activated by various thoughts in a purely mental language), as an alternative to more conventional technology; fantasy materials, such as mythril or adamantium, in addition to many of the aforementioned "energetic plasmas," are allowed in addition to the real-world elements and other stuff (speaking of which, the magic college of "elementalism" is more about chemistry than it is about the classical elements of earth, fire, etc.) by having them exist in parallel spaces that can "overlap" with the "core" space; the deities worshiped in by clerics and similar characters are generally just really powerful wizards, who cast spells for the clerics as favors, to reward them for their service (though the clerics are almost always ignorant of their deities' true natures), and a few entities exist that are more powerful than the worshiped deities, and these entities really don't want to be distracted by the prayers of an army of followers, which is why they try to keep their own existence hidden; etc.. At that point, I'm not sure if my game's setting is really "fantasy," or "sci-fi that looks like fantasy."


It looks as if the difficulty here is a fairly ambitious set of goals for your programs, and having had a fairly fast-paced java class. Java is...probably not an ideal first language. I quite like the language overall, and it's pretty powerful, but it's not terribly intuitive for a first timer. However, as you've got some experience, it likely doesn't hurt to stick with that.

What you're experiencing is very normal, and it's not *necessarily* specific to the language, but rather to the process of getting from setting goals to coding the application. Usually they're decent about teaching the theory, but the actual craft is often learned largely through practice.

I suggest handling this by setting very modest goals. For instance a "guess the number" game makes for a fairly reasonable project. Look for something along those lines for whichever eventual goal you're pursuing. Pick a single thing that you expect your program to do, not a class of things, and code that. Test it, make sure it works, all that good stuff. Once that works, add a single additional goal, and add that. There is no need to associate this with any specific language, or course...getting experience at chunking things into manageable bits is an experience that will apply to pretty much any development. Once you get good enough at the craft of programming, swapping languages really is pretty easy...but that comes later, after you've gotten your first one down. First one's the hardest, simply because it requires learning the craft itself in addition to the language-specific terminology.

Keeping your chunks small will also help a great deal in learning, as it reduces the amount of unknowns you have to deal with at a specific time to a manageable amount.

User avatar
phillip1882
Posts: 145
Joined: Fri Jun 14, 2013 9:11 pm UTC
Location: geogia
Contact:

Re: Esoteric programming languages for an esoteric mind?

Postby phillip1882 » Thu Oct 01, 2015 3:28 am UTC

my personal suggestion for programming language for what you're trying to do would be ruby.
good luck have fun

Moniker Pending
Posts: 39
Joined: Tue Jul 28, 2015 12:59 pm UTC

Re: Esoteric programming languages for an esoteric mind?

Postby Moniker Pending » Thu Oct 01, 2015 3:49 am UTC

phillip1882 wrote:my personal suggestion for programming language for what you're trying to do would be ruby.


I'll check it out... thanks for the tip!

Also, I'm back from the hospital... have been back for about a month, actually. I'm not sure if I'm still going to pursue the Computer Science degree, or what I'd pursue instead if I end up changing programs. Still, programming will probably be a useful skill to learn at some point.

User avatar
ucim
Posts: 6859
Joined: Fri Sep 28, 2012 3:23 pm UTC
Location: The One True Thread

Re: Esoteric programming languages for an esoteric mind?

Postby ucim » Thu Oct 01, 2015 2:23 pm UTC

Moniker Pending wrote:Also, I'm back from the hospital... have been back for about a month, actually.
Welcome back, whether you end up in programming, or decide that other fields are a better match.

Jose
Order of the Sillies, Honoris Causam - bestowed by charlie_grumbles on NP 859 * OTTscar winner: Wordsmith - bestowed by yappobiscuts and the OTT on NP 1832 * Ecclesiastical Calendar of the Order of the Holy Contradiction * Heartfelt thanks from addams and from me - you really made a difference.

douglasm
Posts: 630
Joined: Mon Apr 21, 2008 4:53 am UTC

Re: Esoteric programming languages for an esoteric mind?

Postby douglasm » Sun Oct 04, 2015 11:12 am UTC

If I understand correctly, a big part of your problem is confusion over the basic concepts of object oriented programming, and I don't think anyone's really tried to clear those up for you yet. So, here goes a highly conceptual overview of how object oriented programming works. Some of this explanation will be specific to Java.

First, classes. Think of a "class" as a machine with a bunch of buttons on it that do things when you press them. The "methods" (also commonly called "functions", but in Java the official name is "method") of a class are these buttons. The program as a whole is just a big collection of these class machines, with one of them designated as the main class. When you start a Java program, the operating system pushes the button labeled "public static void main" on the main class, and that's how everything gets started.

Now, the special thing about object oriented programming is that each of these class machines has a button that makes a new machine - an "object". Object machines have buttons that do things too, just like class machines, but they don't have a "make an object" button and none of them exist at program startup like class machines do.

Now that we've got those two concepts, it's time to explain the "static" keyword. Inside a class, anything that is "static" is part of the class machine. Anything that is not "static" is part of the object machines that the class machine can make. Whenever you push a button (official term: "call a method"), you have to say both which button and which machine you're pushing it on. For non-static things you have to have an object machine that you made somewhere after the program started. For static things, you just write out the name of the class and call the method from there.

Now let's examine those buttons more fully. Beside each button is some number of slots for input and one for output. When you push a button, you first fill all the input slots, then push it, and then take whatever came out. You can't push the button without filling its input slots, the language just won't allow it.

Each input slot will only take one kind of thing as its input, and nothing else will fit in that slot. There are two very broad categories for what kinds of things an input slot will take, and these affect how they work. First, there's "primitive" values. This is things like numbers, true or false, a single character, and so on. When you fill a primitive input slot, you make a copy of the number/character/whatever and put the copy in. The method that receives the copy has no access to the original, and whatever it does to the copy will not affect the original. Second, there's "reference" values. A reference value is an object machine. Except not really - it's more like a magic portal that leads to an object machine. When you fill a reference input slot, you have a magic portal to an object machine, you make a copy of the portal, and you put the portal copy in the slot. The method that receives the copy has no access to the original portal, so it can't change where that portal goes, but the original and the copy both lead to the same object machine, so anything the method does by reaching through that portal to push a button will affect the original machine because they are in fact the same machine.

Output slots works pretty much the same way, except for there being only one (or zero) of them per button.

Variables that you declare inside a class or method have the same "primitive" vs "reference" distinction that I just described, and they work much the same way. When you assign something to a primitive variable (using the "=" operator) you are copying the value and putting a copy in the variable. When you assign something to a reference variable, you are copying a magic portal to an object machine and putting that copy of a portal in the variable. How do you get these portals in the first place? By using the "new" operator. If you have a class named "Foo", the expression "new Foo()" means "push the 'make a new object' button on the Foo class, and output a portal to the object machine created". You're never really dealing with an object except when you're pushing buttons on it. At all other times, you're using the magic portals instead.

The primitive variable types are byte, short, int, long, float, double, boolean, and char. Everything else is object references. Note that this includes Strings. For reference types, note that there is a special value called "null". "null" is a magic portal that leads to an empty void instead of an object machine, and if you try to reach through the null portal to push any buttons you'll get an error instead - this is what causes a "null pointer exception". Obviously no one would deliberately do that, but with all the copying of magic object portals that commonly goes on in most programs it can be very easy to have a portal that you don't know whether it's null or not.

Both class and object machines can also have data slots not associated with any button, where they're just holding information that can be used elsewhere. Each machine has its own separate data slots, which can hold different values from the data slots in other machines. There is only ever one class machine for each class, but there can be any number of object machines created by a class machine, and all of those individual object machines can have their own different data.

Now, about that "make a new object" button that's so critical to the object oriented concept: Any method in a class that has exactly the same name as the class is called a "constructor", and defines a "make a new object" button. You can have any number of constructors in a class, each with a different list of input slots. Constructors are not called the same way other methods are, they are called only with the "new" operator. You type "new", followed by the name of the class, parentheses, and the inputs, and this command will create a new object machine, fill all of its data slots with default values (0 or some equivalent for primitive types, null for reference types), and then call whichever constructor matches the list of inputs you gave, and then return a portal to the newly created object machine as the output. Even though a constructor defines a button on the class machine, once it is executing it operates as if it were on the object machine, which means it has access to that object machine's data slots and other buttons.

Moniker Pending wrote:Since the site module is still up, it would probably be easier for me to post the code that the professor wrote, instead of what I wrote.

Code: Select all

import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class Contact {
    //fields
    //Homework: Add field for email address
    private String _firstName;
    private String _lastName;
    private String _phoneNumber;
    //constructors
    //Homework: Add second constructor which takes the same parameters
    //as below plus and email address. So you could just copy this one
    //add email address parameter and call setEmailAddress mutator method
    //you create.
    public Contact(String firstName, String lastName,
            String phoneNumber) {
        setFirstName(firstName);
        setLastName(lastName);
        setPhoneNumber(phoneNumber);
    }
    //mutator methods
    //Homework: Add mutator to set the email address field. User regular
    //expressions to validate the data
    public void setFirstName(String firstName) {
        //check to see if all alpha characters
        for (char c : firstName.toCharArray()) {
            if (!Character.isAlphabetic(c)) {
                throw new IllegalArgumentException(firstName);
            }
        }
        _firstName = firstName;
    }
    //Homework: Make sure lastName is all characters and that it is at least
    //3 characters long. If not throw an Illegal argument exception. Check
    //my mutators for a hint on how to do this.
    private void setLastName(String lastName) {
        _lastName = lastName;
    }
    //Homework: add check to make sure phone number string is
    //correct length. I already did check to check for proper elements:
    //all numbers and one "-" in correct place.
    //Note the test i did could have been done using regular expressions instead
    //  Pattern pattern = Pattern.compile("\\d{3}-\\d{7}");
    //  Matcher matcher = pattern.matcher(phoneNumber);
    //  if (!matcher.matches()) {
    //     throw new IllegalArgumentException(phoneNumber);
    //   }
    private void setPhoneNumber(String phoneNumber) {
        for (int i = 0; i < phoneNumber.length(); i++) {
            char c = phoneNumber.charAt(i);
            if (!Character.isDigit(c)) {
                if (c != '-' || (c == '-' && i != 3)) {
                    throw new IllegalArgumentException(phoneNumber);
                }
            }
        }
 
        _phoneNumber = phoneNumber;
    }
    //accessor methods
    //Homework: Add accessor method for your email address field.
    public String getFirstName() {
        return _firstName;
    }
    public String getLastName() {
        return _lastName;
    }
    public String getPhoneNumber() {
        return _phoneNumber;
    }

Let's see if I can help explain this for you a bit. Starting at the top, with the import statements:
All Java classes are grouped in "packages", which are organized hierarchically. Think of a package as a big box that can contain other packages and class machines. There are a very large number of classes pre-defined that come with the Java language. The line "import java.util.regex.Matcher;" means "Find the package named 'java', open it and find the package inside called 'util', open it and find the package inside called 'regex', and open that and find the class machine inside called 'Matcher'. I'll be using that class in this file and don't feel like typing all that out every time, so when I say just 'Matcher' this is what I mean." In code, not import statements, you can identify a class by just the class name when either the class you're referring to is in the same package as the class the code is in or when the class you're referring to has been imported. You can always identify a class by its full package hierarchy plus name, called its "fully qualified name", regardless.

Now, that class as a whole: I think you noticed that absolutely everything in it is not static. That means the "make a new object" button is the only one the class machine has, and this class is all about making and using object machines instead. This is really quite common in typical Java programs, so it's very important that you understand how this works and how it is useful.

In well written and documented Java code, there is supposed to be a conceptual description of what the class is for, located at the top of the file right before the class declaration (the "public class Contact {" line). That conceptual description is missing here, so I'll try to fill it in for you. Each object machine created from this class machine represents one entry in a list of contacts, containing all the information that describes a contact. Furthermore, the data hidden inside the machine (and accessible only by pushing the "get this data" buttons, not by direct access) is guaranteed to be valid.

The first three non-comment lines inside the class define the data that each object will hold. The entire rest of the class is all about fulfilling that guarantee of validity. This is done by having the only way to change each bit of data perform a validity check first.

Does that help? Is there any part of it you still don't understand?

Moniker Pending wrote:Even terms like "stack and heap" are things I could only understand by connecting them to "base ID's and reference ID's" in the Gamebryo Engine used by Bethesda, and I still have to see the terms being used to remember which is which, since when I think of the terms "stack and heap," I think of a "stack" as being just a more orderly form of a "heap," using the terms as they mean in basic English, which doesn't really connect well with what they mean in programming.

The terms "stack" and "heap" have meaning dependent on context. When referred to together like that, they typically refer to the two different kinds of places in computer memory that data can be stored, and "a more orderly form of a heap" isn't that far off from what "stack" means in this context. In this context, "the heap" is the big jumbled mess of most of the storage area available to a computer. Data stored in the heap could be anywhere, in any amount, next to anything else, and you can grab more space from the heap whenever and wherever you like. In some languages, if you lose track of where something is in the heap there may be no guarantee that anything will ever notice you're not using it any more. Data stored on the stack is in one compact specific location, new stack data storage comes strictly from the next block in the reserved-for-the-stack area, it's kept for a specific time, and released when you're done. In Java, objects ("object machines" in my conceptual overview) are stored in the heap, including their per-object data, while primitive values and references to objects (the "magic portals" in my conceptual overview) that are not part of per-object data are stored on the stack.

In other contexts, "stack" and "heap" are two particular kinds of data structures, with different principles for how the data they hold is organized and interacted with. A stack is, well, very much like a real world stack of books - a highly orderly one, only one book wide. There is no particular relation between bits of data in a stack, but their order is tracked and you can only put things on or takes things off of the top of the stack. Just as you would not, usually, insert or remove a book into or from the middle of a stack of books, you can't insert or remove data into or from the middle of a stack.

A heap is more like a jumbled pile of stuff - it has a lot more restricted access than a real world pile of stuff does, but the only organization it has for its data is that bigger stuff is on the broad bottom. A heap guarantees that the item on the top is the smallest one in the entire heap. Most heaps will only allow you to remove the top item, not any other, though you can add any item you like. You can't control where any item in the heap goes, though - the heap will automatically rearrange itself whenever you add or remove an item, to maintain its own internal organization. From an external perspective, all you really need to know is that the heap's top piece of data is the smallest one. For how it works internally, the top piece in a heap is "on top of" each of two other heaps, each of which has its own smallest piece on its top (and its own sub-heaps, etc.). A slightly more general form of a heap can have the largest on top instead, or earliest, or latest, or brightest, or any other "farthest in one direction in an order-defining relationship" term that makes sense for the type of data that's in the heap.


Return to “Coding”

Who is online

Users browsing this forum: No registered users and 11 guests