|
Thread Rules 1. This is not a "do my homework for me" thread. If you have specific questions, ask, but don't post an assignment or homework problem and expect an exact solution. 2. No recruiting for your cockamamie projects (you won't replace facebook with 3 dudes you found on the internet and $20) 3. If you can't articulate why a language is bad, don't start slinging shit about it. Just remember that nothing is worse than making CSS IE6 compatible. 4. Use [code] tags to format code blocks. |
On November 26 2016 05:50 RoomOfMush wrote:Show nested quote +On November 26 2016 05:35 travis wrote: ah solved my own problem
but I am left with a question
are objects that have been declared but not initialized set as "null" in java?
I am reading they are but then why does eclipse give me errors when I don't initialize them (it makes me explicitly say that they = null) You never declare objects. You declare variables; they are not the same thing as an object. An object is only created when the "new" keyword is used. That is the only way for an object to ever be. (if we ignore black voodoo magic like TheUnsafe and compiler magic like Boxing / Strings)
ah.. yeah.. makes sense
For example: String a = new String("Hello World"); String b = a; String c; String d = null; new String("Test");
The above code has 4 variables but only 2 Objects. 2 Variables (a, b) point to the same object. One variable (c) was declared but not initialized; it points to no object at all. This variable is not usable until it is initialized. The last variable (d) is pointing to null which is "no object" in java. Our second Object is created but has no variable pointing to it. We can not do anything with it anymore because we have no reference to work with. Its different with member variables (attributes) though. These are ALWAYS initialized because the Compiler enforces that. A member variable of object type is always initialized with null unless you initialize it with something else.
okay so it's only local variables that have this problem?
do you know why?? I guess it doesn't *really* matter though it caused me a minor inconvenience, and I don't see the benefit.
|
|
On November 26 2016 05:51 Acrofales wrote:Show nested quote +On November 26 2016 05:35 travis wrote: ah solved my own problem
but I am left with a question
are objects that have been declared but not initialized set as "null" in java?
I am reading they are but then why does eclipse give me errors when I don't initialize them (it makes me explicitly say that they = null) Was about to answer, but you did it yourself. Not quite sure about the rest. Java changed that shit at some point. It used to be undefined (and effectively initialized to null), and good practice was to initialize them explicitly to null. Then it became explicit for fields (I think in Java 6), and it was unnecessary to initialize fields to null (and you got a warning that that code did nothing... thank you). I have no idea whether variables follow the former or the latter initialization rules. Clearly you are being told to initialize it to null, so it's probably the former. Or you're working with a really old version of Java. It has always been the way I described above since version 1.0. You can look up the version history on wikipedia and read the updates yourself: https://en.wikipedia.org/wiki/Java_version_history
Here is a link to the java documentation were default initialization is talked about: https://docs.oracle.com/javase/tutorial/java/nutsandbolts/variablesummary.html with the important part being:
[...] The compiler will assign a reasonable default value for fields of the above types; for local variables, a default value is never assigned. [...] And here is the part where the default values are listed: https://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html The important part is:
byte 0 short 0 int 0 long 0L float 0.0f double 0.0d char '\u0000' String (or any object) null boolean false
And here is an article talking about it a little bit more in depth (notice the date being 1998 which means the article was written with java version 1.2) http://www.javaworld.com/article/2076614/core-java/object-initialization-in-java.html
Edit:
On November 26 2016 05:55 travis wrote:Show nested quote +On November 26 2016 05:50 RoomOfMush wrote:On November 26 2016 05:35 travis wrote: ah solved my own problem
but I am left with a question
are objects that have been declared but not initialized set as "null" in java?
I am reading they are but then why does eclipse give me errors when I don't initialize them (it makes me explicitly say that they = null) You never declare objects. You declare variables; they are not the same thing as an object. An object is only created when the "new" keyword is used. That is the only way for an object to ever be. (if we ignore black voodoo magic like TheUnsafe and compiler magic like Boxing / Strings) ah.. yeah.. makes sense Show nested quote +For example: String a = new String("Hello World"); String b = a; String c; String d = null; new String("Test");
The above code has 4 variables but only 2 Objects. 2 Variables (a, b) point to the same object. One variable (c) was declared but not initialized; it points to no object at all. This variable is not usable until it is initialized. The last variable (d) is pointing to null which is "no object" in java. Our second Object is created but has no variable pointing to it. We can not do anything with it anymore because we have no reference to work with. Its different with member variables (attributes) though. These are ALWAYS initialized because the Compiler enforces that. A member variable of object type is always initialized with null unless you initialize it with something else. okay so it's only local variables that have this problem? do you know why?? I guess it doesn't *really* matter though it caused me a minor inconvenience, and I don't see the benefit. Its for performance and security reasons. The JVM would have to push a default value for each variable and parameter on the stack only for it to be overwritten by the developer 99% of the time. If the JVM would not initialize local variables but would also not force local variables to be explicitly initialized then malicious software written in java could freely read your stack which poses a security risk.
|
On November 26 2016 04:34 RoomOfMush wrote:Show nested quote +On November 26 2016 03:31 tofucake wrote: Technically everything on a computer is binary... No that doesnt make any sense. Binary is a representation of numbers. A computer is a complex physical machine. Everything inside it is currents of electricity. Binary is how we humans decided to interprete it as. Its just a number format that is convenient to use. Binary doesnt happen until you enter the software-level. It makes quite a lot of sense. From the hardware perspective, things were quite specifically implemented to give binary signals. When designing a CPU, the people don't put together the pieces and later decide that binary is a good representation. The entire process revolves around being able to isolate a signal as one of two states - binary.
It makes even more sense when we talk about this in the context of the original discussion - data in a computer is most certainly binary under the hood. Your RAM, SSD, or HDD are explicitly storing binary data. Sure it gets a little muddled when you're talking about e.g. tlc flash, which uses 2^3 distinct signal levels to store 3 bits of data... but for all intents and purposes it's binary all the way down, by design.
|
On November 26 2016 06:28 phar wrote:Show nested quote +On November 26 2016 04:34 RoomOfMush wrote:On November 26 2016 03:31 tofucake wrote: Technically everything on a computer is binary... No that doesnt make any sense. Binary is a representation of numbers. A computer is a complex physical machine. Everything inside it is currents of electricity. Binary is how we humans decided to interprete it as. Its just a number format that is convenient to use. Binary doesnt happen until you enter the software-level. It makes quite a lot of sense. From the hardware perspective, things were quite specifically implemented to give binary signals. When designing a CPU, the people don't put together the pieces and later decide that binary is a good representation. The entire process revolves around being able to isolate a signal as one of two states - binary. It makes even more sense when we talk about this in the context of the original discussion - data in a computer is most certainly binary under the hood. Your RAM, SSD, or HDD are explicitly storing binary data. Sure it gets a little muddled when you're talking about e.g. tlc flash, which uses 2^3 distinct signal levels to store 3 bits of data... but for all intents and purposes it's binary all the way down, by design. And I still disagree. Binary is a data representation. It is a way of looking at data but it is not an natural property of the data itself. The representation of the data depends on who is looking at it and for what purpose. A software developer might look at data and see it in terms of objects. A programmer might look at the data and see it in terms of numbers, be it in binary or decimal or whatever. The hardware designer might laugh at this and say the data is all booleans. There is no arithmetics, its all boolean operations on the bit level. The mechanic might see it as voltages or light signals going through a tube or what have you. What it really is is just data. Its all a whole lot of data. It is binary numbers if you want it to be binary numbers. It is boolean sets if you want it to be boolean sets. But it only is these things as long as there is a human being around to interprete it that way. By its nature its neither.
|
Russian Federation4235 Posts
On November 26 2016 06:44 RoomOfMush wrote:Show nested quote +On November 26 2016 06:28 phar wrote:On November 26 2016 04:34 RoomOfMush wrote:On November 26 2016 03:31 tofucake wrote: Technically everything on a computer is binary... No that doesnt make any sense. Binary is a representation of numbers. A computer is a complex physical machine. Everything inside it is currents of electricity. Binary is how we humans decided to interprete it as. Its just a number format that is convenient to use. Binary doesnt happen until you enter the software-level. It makes quite a lot of sense. From the hardware perspective, things were quite specifically implemented to give binary signals. When designing a CPU, the people don't put together the pieces and later decide that binary is a good representation. The entire process revolves around being able to isolate a signal as one of two states - binary. It makes even more sense when we talk about this in the context of the original discussion - data in a computer is most certainly binary under the hood. Your RAM, SSD, or HDD are explicitly storing binary data. Sure it gets a little muddled when you're talking about e.g. tlc flash, which uses 2^3 distinct signal levels to store 3 bits of data... but for all intents and purposes it's binary all the way down, by design. And I still disagree. Binary is a data representation. It is a way of looking at data but it is not an natural property of the data itself. The representation of the data depends on who is looking at it and for what purpose. A software developer might look at data and see it in terms of objects. A programmer might look at the data and see it in terms of numbers, be it in binary or decimal or whatever. The hardware designer might laugh at this and say the data is all booleans. There is no arithmetics, its all boolean operations on the bit level. The mechanic might see it as voltages or light signals going through a tube or what have you. What it really is is just data. Its all a whole lot of data. It is binary numbers if you want it to be binary numbers. It is boolean sets if you want it to be boolean sets. But it only is these things as long as there is a human being around to interprete it that way. By its nature its neither.
I'd say that in the common meaning of the word, binary signifies a lack of representation. The original question was about IO I think. There binary is just raw data, opposed by text which implies at least some formatting.
|
You're talking about abstractions. The original statement is about the foundations.
Binary is the basic property of everything in a computer system.
We define electric signals by high or low voltage, which we define as 1 or 0. This binary system is the building block of every single thing in a computer. Every abstraction we build is a layer on top of high and low electric signals, a binary system we defined.
|
Russian Federation4235 Posts
On November 26 2016 07:35 Blisse wrote: You're talking about abstractions. The original statement is about the foundations.
Binary is the basic property of everything in a computer system.
We define electric signals by high or low voltage, which we define as 1 or 0. This binary system is the building block of every single thing in a computer. Every abstraction we build is a layer on top of high and low electric signals, a binary system we defined.
This is a correct but useless definition, the worst of them all.
|
On November 26 2016 07:58 BluzMan wrote:Show nested quote +On November 26 2016 07:35 Blisse wrote: You're talking about abstractions. The original statement is about the foundations.
Binary is the basic property of everything in a computer system.
We define electric signals by high or low voltage, which we define as 1 or 0. This binary system is the building block of every single thing in a computer. Every abstraction we build is a layer on top of high and low electric signals, a binary system we defined. This is a correct but useless definition, the worst of them all.
How is this useless when this is literally how everything works.
|
The original context here is shields asking about integer storage read as bytes. Binary is the name of the game here.
If we want to be more specific for shields, the things they need to jog their memory are probably 1) 2s complement 2) maybe, big vs little endian, depending on what level this reading of data is being done at.
|
Russian Federation4235 Posts
On November 26 2016 08:04 Blisse wrote:Show nested quote +On November 26 2016 07:58 BluzMan wrote:On November 26 2016 07:35 Blisse wrote: You're talking about abstractions. The original statement is about the foundations.
Binary is the basic property of everything in a computer system.
We define electric signals by high or low voltage, which we define as 1 or 0. This binary system is the building block of every single thing in a computer. Every abstraction we build is a layer on top of high and low electric signals, a binary system we defined. This is a correct but useless definition, the worst of them all. How is this useless when this is literally how everything works. You answered your question with your question. Definitions are useful when they are specific. "How everything works" is the opposite of specific and hence horribly useless.
|
On November 26 2016 08:29 BluzMan wrote:Show nested quote +On November 26 2016 08:04 Blisse wrote:On November 26 2016 07:58 BluzMan wrote:On November 26 2016 07:35 Blisse wrote: You're talking about abstractions. The original statement is about the foundations.
Binary is the basic property of everything in a computer system.
We define electric signals by high or low voltage, which we define as 1 or 0. This binary system is the building block of every single thing in a computer. Every abstraction we build is a layer on top of high and low electric signals, a binary system we defined. This is a correct but useless definition, the worst of them all. How is this useless when this is literally how everything works. You answered your question with your question. Definitions are useful when they are specific. "How everything works" is the opposite of specific and hence horribly useless.
"Definitions are useful when they are specific."
This is neither self-evident nor meaningful, no clue why you're saying random abstract stuff like this.
Definitions are useful when they define something. We defined binary based on high and low voltages. High and low voltages is the basic component of every part in a computer. I don't know what point you're trying to make here. I was responding to RoomOfMush's disagreement.
|
Hyrule18968 Posts
On November 26 2016 04:34 RoomOfMush wrote:Show nested quote +On November 26 2016 03:31 tofucake wrote: Technically everything on a computer is binary... No that doesnt make any sense. Binary is a representation of numbers. A computer is a complex physical machine. Everything inside it is currents of electricity. Binary is how we humans decided to interprete it as. Its just a number format that is convenient to use. Binary doesnt happen until you enter the software-level. No, 1 is low current and 0 is high current. The hardware level is very much binary
|
On November 26 2016 22:15 tofucake wrote:Show nested quote +On November 26 2016 04:34 RoomOfMush wrote:On November 26 2016 03:31 tofucake wrote: Technically everything on a computer is binary... No that doesnt make any sense. Binary is a representation of numbers. A computer is a complex physical machine. Everything inside it is currents of electricity. Binary is how we humans decided to interprete it as. Its just a number format that is convenient to use. Binary doesnt happen until you enter the software-level. No, 1 is low voltage and 0 is high voltage. The hardware level is very much binary FTFY. Also, please know that it might very well be the opposite.
|
Anyways, how about that bike shed?
|
Hyrule18968 Posts
On November 27 2016 02:33 Djagulingu wrote:Show nested quote +On November 26 2016 22:15 tofucake wrote:On November 26 2016 04:34 RoomOfMush wrote:On November 26 2016 03:31 tofucake wrote: Technically everything on a computer is binary... No that doesnt make any sense. Binary is a representation of numbers. A computer is a complex physical machine. Everything inside it is currents of electricity. Binary is how we humans decided to interprete it as. Its just a number format that is convenient to use. Binary doesnt happen until you enter the software-level. No, 1 is low voltage and 0 is high voltage. The hardware level is very much binary FTFY. Also, please know that it might very well be the opposite. Yeah it's been a while since my architecture classes...
|
|
On November 27 2016 03:44 Nesserev wrote:First quality post in a while EDIT: Anyone got any recommended reads that really blew them away recently? Just read "Story of Your Life" by Ted Chiang (short story on which Arrival was based) which was really great.
JK but I actually read https://learnpythonthehardway.org/book/nopython3.html recently, and found it pretty interesting since I generally like python 3. I was blown away as I really felt some of his concerns were over, uh, blown, and didn't realize it was that big of an issue (is python actually a dying language)? Not sure whence this rant came, tbh. What do you guys think?
I don't feel like I'm experienced enough to have an informed opinion, but other than better error messages and what I've heard was rather bungled handling of the transition from python 2 to 3, I don't really feel like there's that much doom and gloom to be had regarding python 3.
|
On November 27 2016 03:44 Nesserev wrote:First quality post in a while EDIT: Anyone got any recommended reads that really blew them away recently?
http://evilbydesign.info/
|
edit: there is something magical about asking a question and then instantly figuring out the answer
|
|
|
|