Programming, computers, etc. [Serious]

All things asdf (and anything else)
dewero
ASDF Prophet
ASDF Prophet
Posts: 3869
Joined: Mon Dec 07, 2009 11:06 pm
Location: Nowhere
Contact:

Re: Programming, computers, etc. [Serious]

Post by dewero » Wed Sep 05, 2012 1:09 am

Oh... Reading the context in the documentation makes it a little more clear.
public final Buffer clear()

Clears this buffer. The position is set to zero, the limit is set to the capacity, and the mark is discarded.

Invoke this method before using a sequence of channel-read or put operations to fill this buffer. For example:

buf.clear(); // Prepare buffer for reading
in.read(buf); // Read data

This method does not actually erase the data in the buffer, but it is named as if it did because it will most often be used in situations in which that might as well be the case.
buffer.clear simply "resets" the buffer, and doesn't actually "clear" the buffer in the sense that data in the buffer is deleted. From what I read, it doesn't seem like it would affect normal coding too much, but then again, programmers like to do funny things.
If two wrongs don't make a right, try three. - Laurence J. Peter

User avatar
Anonymously Famous
JKL; Assassin
JKL; Assassin
Posts: 11413
Joined: Thu Mar 03, 2011 6:52 pm
Location: Area ???, under Bermuda Triangle

Re: Programming, computers, etc. [Serious]

Post by Anonymously Famous » Wed Sep 05, 2012 2:36 pm

Sometimes resetting the buffer might be useful.
BOTTOM TEXT
ThingerDudes wrote:The only reasonable amount of Nutella is infinity. Everything else is too little.
Proud poster of the 300kth post in General

User avatar
atomtengeralattjaro
Site Admin
Site Admin
Posts: 35622
Joined: Wed May 23, 2007 3:43 pm
Location: green
Contact:

Re: Programming, computers, etc. [Serious]

Post by atomtengeralattjaro » Wed Sep 05, 2012 3:54 pm

meh. okay then.

today i continue fiddling around in java networking.
Ivokyuftaf6666 wrote:
Sun Oct 20, 2019 5:22 pm
Awesome Site, Delivering Fun
Image

User avatar
Anonymously Famous
JKL; Assassin
JKL; Assassin
Posts: 11413
Joined: Thu Mar 03, 2011 6:52 pm
Location: Area ???, under Bermuda Triangle

Re: Programming, computers, etc. [Serious]

Post by Anonymously Famous » Wed Sep 05, 2012 5:54 pm

I wish you luck.
BOTTOM TEXT
ThingerDudes wrote:The only reasonable amount of Nutella is infinity. Everything else is too little.
Proud poster of the 300kth post in General

dewero
ASDF Prophet
ASDF Prophet
Posts: 3869
Joined: Mon Dec 07, 2009 11:06 pm
Location: Nowhere
Contact:

Re: Programming, computers, etc. [Serious]

Post by dewero » Thu Sep 06, 2012 12:48 am

I strongly dislike networking. Maybe that's because I've never done anything with it before
If two wrongs don't make a right, try three. - Laurence J. Peter

User avatar
Anonymously Famous
JKL; Assassin
JKL; Assassin
Posts: 11413
Joined: Thu Mar 03, 2011 6:52 pm
Location: Area ???, under Bermuda Triangle

Re: Programming, computers, etc. [Serious]

Post by Anonymously Famous » Thu Sep 06, 2012 12:50 am

I really appreciate those who understand and use it in their programming, because I like to use the Internet, and that's all about networking.
BOTTOM TEXT
ThingerDudes wrote:The only reasonable amount of Nutella is infinity. Everything else is too little.
Proud poster of the 300kth post in General

User avatar
ThingerDudes
ASDF Warlord
ASDF Warlord
Posts: 20868
Joined: Sun Apr 12, 2009 4:12 am
Location: close enough.

Re: Programming, computers, etc. [Serious]

Post by ThingerDudes » Thu Sep 06, 2012 1:18 am

had to make a server thing with sockets and encryptions and forking and crap for a project last year. Really really annoying. But fun once you get it working.
Image

User avatar
Anonymously Famous
JKL; Assassin
JKL; Assassin
Posts: 11413
Joined: Thu Mar 03, 2011 6:52 pm
Location: Area ???, under Bermuda Triangle

Re: Programming, computers, etc. [Serious]

Post by Anonymously Famous » Thu Sep 06, 2012 2:22 am

Yeah. It sounds really annoying.
BOTTOM TEXT
ThingerDudes wrote:The only reasonable amount of Nutella is infinity. Everything else is too little.
Proud poster of the 300kth post in General

User avatar
atomtengeralattjaro
Site Admin
Site Admin
Posts: 35622
Joined: Wed May 23, 2007 3:43 pm
Location: green
Contact:

Re: Programming, computers, etc. [Serious]

Post by atomtengeralattjaro » Thu Sep 06, 2012 7:37 am

ThingerDudes wrote:had to make a server thing with sockets and encryptions and forking and crap for a project last year. Really really annoying. But fun once you get it working.
what language/platform did you make it in/on?
Ivokyuftaf6666 wrote:
Sun Oct 20, 2019 5:22 pm
Awesome Site, Delivering Fun
Image

User avatar
ThingerDudes
ASDF Warlord
ASDF Warlord
Posts: 20868
Joined: Sun Apr 12, 2009 4:12 am
Location: close enough.

Re: Programming, computers, etc. [Serious]

Post by ThingerDudes » Fri Sep 07, 2012 2:48 am

We had to do it in C. seg faults...so many seg faults...
and do documentation on it which was worth half the grade...
yeah...it was not a fun course.
Image

User avatar
Anonymously Famous
JKL; Assassin
JKL; Assassin
Posts: 11413
Joined: Thu Mar 03, 2011 6:52 pm
Location: Area ???, under Bermuda Triangle

Re: Programming, computers, etc. [Serious]

Post by Anonymously Famous » Fri Sep 07, 2012 2:56 pm

Writing documentation is a good skill to have.
BOTTOM TEXT
ThingerDudes wrote:The only reasonable amount of Nutella is infinity. Everything else is too little.
Proud poster of the 300kth post in General

User avatar
atomtengeralattjaro
Site Admin
Site Admin
Posts: 35622
Joined: Wed May 23, 2007 3:43 pm
Location: green
Contact:

Re: Programming, computers, etc. [Serious]

Post by atomtengeralattjaro » Mon Sep 17, 2012 4:50 pm

[continuing from the daily thread]

it occured to me that a 2-dimensional array is not the same as an array of arrays, because in the latter, you might be able to add arrays of varying size to an array of arrays, as opposed to a 2D array, which has only 2 dimensions.

a.)

Code: Select all

X X X X X X X X
X X X X X X X X
X X X X X X X X
X X X X X X X X
b.)

Code: Select all

X X X X
X
X X X X X X X X X X X
X X X X X X X X
i just checked, and it turns out java's syntax in arrays differs from C# in the following way:

java:

Code: Select all

        int[][] a = new int[3][2]; //okay (2D array, not an array of arrays)
        a[0][0] = 1; //cool
        a[0,0] = 1; //not cool
        
        int[,] c; //doesn't compile
        
        int[][] b = new int[3][]; //okay (a 3 sized array of integer arrays)
        b[0] = new int[2]; //okay (let the first element in the 3-sized array be a 2-sized int array)
        b[0][1] = 1; // let the second element of the first element of the b array be 1.

however, in C#:

Code: Select all

            int[,] a = new int[2, 2]; // okay
            a[0, 1] = 87; //okay
            a[0][1] = 44; //wrong

            int[][] c = new int[3][2]; //NOT okay

            int[][] b = new int[3][]; //okay (a 3 sized array of integer arrays)
            b[0] = new int[2]; //okay (let the first element in the 3-sized array be a 2-sized int array)
            b[0][1] = 1; // let the second element of the first element of the b array be 1.
Conclusion: double brackets like this: [][] are the only way to create a 2D array in Java, and are also able to create an array of arrays, but they only mean an array of arrays in C#.
also, accessing 2D arrays in Java is not possible with the C# syntax [,] and [2,3]
and accessing 2D arrays in C# is not possible with the Java syntax [2][3].


it's not all that complicated, i just kinda overcomplicated it, but i wanted to see how they really differ, because i've always thought the syntax of C# and Java are very similar on this basic level. Apparently not.
Ivokyuftaf6666 wrote:
Sun Oct 20, 2019 5:22 pm
Awesome Site, Delivering Fun
Image

User avatar
Anonymously Famous
JKL; Assassin
JKL; Assassin
Posts: 11413
Joined: Thu Mar 03, 2011 6:52 pm
Location: Area ???, under Bermuda Triangle

Re: Programming, computers, etc. [Serious]

Post by Anonymously Famous » Mon Sep 17, 2012 7:23 pm

Oh, they're similar, just not exactly the same. On a conceptual level, a 2d array is just an array of arrays with the lengths enforced. There are several languages where 2d arrays aren't explicitly possible - You have to enforce the lengths yourself. This can be tricky in languages that have arrays of modifiable length, like the Python list. Just do a myGrid.append(x) and you've messed up your 2d array.

Of note: Last week, for the first time in my memory, I had a problem in which a 3d array made sense (more accurately, a Python dictionary (named array) of lists of lists).
BOTTOM TEXT
ThingerDudes wrote:The only reasonable amount of Nutella is infinity. Everything else is too little.
Proud poster of the 300kth post in General

User avatar
atomtengeralattjaro
Site Admin
Site Admin
Posts: 35622
Joined: Wed May 23, 2007 3:43 pm
Location: green
Contact:

Re: Programming, computers, etc. [Serious]

Post by atomtengeralattjaro » Mon Sep 17, 2012 8:16 pm

ha, stacking dimensions is fun :)
are you saying that there are no real arrays in python?
It is my understanding that arrays (and i mean real arrays, forced and fixed) are good because it is extremely easy for the computer to index them in the memory. All it needs to do is get the address of the beginning, and then add the length of an item, times the index requested. If there are structs in the array, they all have the same length, and if there are objects, it's only their reference stored there anyway, and those are of the same length too. As opposed to lists, where you'd need to step through a bunch of them in different places just to get to the n'th element.
Ivokyuftaf6666 wrote:
Sun Oct 20, 2019 5:22 pm
Awesome Site, Delivering Fun
Image

User avatar
Anonymously Famous
JKL; Assassin
JKL; Assassin
Posts: 11413
Joined: Thu Mar 03, 2011 6:52 pm
Location: Area ???, under Bermuda Triangle

Re: Programming, computers, etc. [Serious]

Post by Anonymously Famous » Tue Sep 18, 2012 3:01 am

Python types can change on a whim, and Python lists don't enforce type. There is an array class that enforces type, and it's more memory efficient than lists, but it doesn't have fixed size.
BOTTOM TEXT
ThingerDudes wrote:The only reasonable amount of Nutella is infinity. Everything else is too little.
Proud poster of the 300kth post in General

dewero
ASDF Prophet
ASDF Prophet
Posts: 3869
Joined: Mon Dec 07, 2009 11:06 pm
Location: Nowhere
Contact:

Re: Programming, computers, etc. [Serious]

Post by dewero » Sat Sep 22, 2012 1:37 am

Oh the woos of a dynamic language...
If two wrongs don't make a right, try three. - Laurence J. Peter

User avatar
Anonymously Famous
JKL; Assassin
JKL; Assassin
Posts: 11413
Joined: Thu Mar 03, 2011 6:52 pm
Location: Area ???, under Bermuda Triangle

Re: Programming, computers, etc. [Serious]

Post by Anonymously Famous » Sat Sep 22, 2012 4:22 am

I like dynamic languages.
BOTTOM TEXT
ThingerDudes wrote:The only reasonable amount of Nutella is infinity. Everything else is too little.
Proud poster of the 300kth post in General

User avatar
klinscy
ASDF Worshipper
ASDF Worshipper
Posts: 445
Joined: Tue Jan 17, 2012 10:05 pm
Location: Morgues, graveyards, hospitals, post-apocalyptic L.A.

Re: Programming, computers, etc. [Serious]

Post by klinscy » Wed Sep 26, 2012 8:24 pm

Dynamic = more complicated???
Captain Kirk wrote:"Very funny, Scotty. Now beam down my clothes."
Zim wrote:Now, now, GIR. Movies don't create psychos. Movies make psychos more creative.
Best acronym EVER
atomtengeralattjaro wrote: Effectively removed. Again, simply, essentially deleted.

User avatar
Anonymously Famous
JKL; Assassin
JKL; Assassin
Posts: 11413
Joined: Thu Mar 03, 2011 6:52 pm
Location: Area ???, under Bermuda Triangle

Re: Programming, computers, etc. [Serious]

Post by Anonymously Famous » Wed Sep 26, 2012 9:02 pm

Nope. Not as efficient, but you don't need to declare types or initiate variables usually.

a = "2"
a = int(a)

No error, because the type can change.

Also, Python and some other related languages can have multiple return values from functions, which I think is cool.
BOTTOM TEXT
ThingerDudes wrote:The only reasonable amount of Nutella is infinity. Everything else is too little.
Proud poster of the 300kth post in General

User avatar
atomtengeralattjaro
Site Admin
Site Admin
Posts: 35622
Joined: Wed May 23, 2007 3:43 pm
Location: green
Contact:

Re: Programming, computers, etc. [Serious]

Post by atomtengeralattjaro » Thu Sep 27, 2012 10:40 am

Anonymously Famous wrote:multiple return values from functions
now THAT would be a good thing even in non-dynamic languages. Anytime I have to give multiple results, i need to use out parameters or wrap them in some class. How does it work in python? i mean how do you invoke a method that has multiple return parameters, where do you put the results?
Ivokyuftaf6666 wrote:
Sun Oct 20, 2019 5:22 pm
Awesome Site, Delivering Fun
Image

Post Reply