Announcement

Collapse
No announcement yet.

Programming question

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • #31
    Originally posted by Hauldren Collider View Post
    The difference here is that the arrays are actually a literal and a crucial feature and the fact that they've been deprecated for something with astonishingly uglier syntax is obnoxious.
    Well, going from Algol/Pascal strings to the C representation was also a real bad experience
    With or without religion, you would have good people doing good things and evil people doing evil things. But for good people to do evil things, that takes religion.

    Steven Weinberg

    Comment


    • #32
      Originally posted by Hauldren Collider View Post
      The difference here is that the arrays are actually a literal and a crucial feature and the fact that they've been deprecated for something with astonishingly uglier syntax is obnoxious.
      Actually, arrays kind of suck. It's hard to come up with a case where I'd actually want to use them if a halfway decent collections library is available.

      Comment


      • #33
        Originally posted by Kuciwalker View Post
        Actually, arrays kind of suck.
        Uhm, no. They only suck if you don't know the limitations. If you know those and design by that, they are far more efficient.

        That said, modern languages has a far better way of handling unknown sizes, and that certainly is a plus - memory mangement is a pain in the ass.
        With or without religion, you would have good people doing good things and evil people doing evil things. But for good people to do evil things, that takes religion.

        Steven Weinberg

        Comment


        • #34
          They aren't more efficient at handling arrays of unknown sizes, they just hide the ickiness of it all behind a veneer of convenient syntax.
          If there is no sound in space, how come you can hear the lasers?
          ){ :|:& };:

          Comment


          • #35
            Originally posted by BlackCat View Post
            Uhm, no. They only suck if you don't know the limitations. If you know those and design by that, they are far more efficient.
            Bzzzt. They are syntactically awkward, especially if you are ever planning on changing your data structure, and aren't actually more efficient in a managed code language like Java or .NET, let alone an interpreted language. The syntactic awkwardness goes 1000x for Java because of type erasure.

            Comment


            • #36
              No doubt, you must be brothers/DL's

              I said that if you know the limits then arrays are more efficient - knowing the limits mean that you don't expect them to change.

              I don't use fixed arrays today because CPU speed easily can handle it, but my first "PC" was a 2 MHz 64 kb (OS took a third) and if anyone had suggested using dynamic versus static arrays, they would probably be fired.

              That said, arrays can still be an issue if you have to deal with large amounts of data and heavy computing.
              With or without religion, you would have good people doing good things and evil people doing evil things. But for good people to do evil things, that takes religion.

              Steven Weinberg

              Comment


              • #37
                I said that if you know the limits then arrays are more efficient - knowing the limits mean that you don't expect them to change.


                Dude, we're talking about ****ing managed code. ArrayList<> and equivalents are not going to be measurably "less efficient" in any plausible use case.

                Do we really have to play the "BlackCat defends some dumb comment he made long past the point that it's obvious to everyone else that he's wrong" game again?

                I don't use fixed arrays today because CPU speed easily can handle it, but my first "PC" was a 2 MHz 64 kb (OS took a third) and if anyone had suggested using dynamic versus static arrays, they would probably be fired.


                asd;lfkjdsaf;
                the only performance difference between a "dynamic array" and a regular array is the overhead of a method call.

                Comment


                • #38
                  Originally posted by Kuciwalker View Post
                  I said that if you know the limits then arrays are more efficient - knowing the limits mean that you don't expect them to change.


                  Dude, we're talking about ****ing managed code. ArrayList<> and equivalents are not going to be measurably "less efficient" in any plausible use case.

                  Do we really have to play the "BlackCat defends some dumb comment he made long past the point that it's obvious to everyone else that he's wrong" game again?

                  I don't use fixed arrays today because CPU speed easily can handle it, but my first "PC" was a 2 MHz 64 kb (OS took a third) and if anyone had suggested using dynamic versus static arrays, they would probably be fired.


                  asd;lfkjdsaf;
                  the only performance difference between a "dynamic array" and a regular array is the overhead of a method call.
                  Linked lists and sparse arrays (I think that's the proper name for java's arraylists) use a lot more memory though. And it is obviously much slower to get random access from a linked list.

                  But that's separate from the method call issue and is just related to what data structure you pick.
                  If there is no sound in space, how come you can hear the lasers?
                  ){ :|:& };:

                  Comment


                  • #39
                    Originally posted by Kuciwalker View Post

                    asd;lfkjdsaf;
                    the only performance difference between a "dynamic array" and a regular array is the overhead of a method call.
                    Please tell me that you are joking, please
                    With or without religion, you would have good people doing good things and evil people doing evil things. But for good people to do evil things, that takes religion.

                    Steven Weinberg

                    Comment


                    • #40
                      Holy ****, you are dumb.

                      HERE ARE THE RELEVANT PIECES OF CODE FROM ARRAYLIST.JAVA IN THE ACTUAL ****ING JDK VERSION 6.18:

                      Code:
                      /*
                      * @(#)ArrayList.java    1.56 06/04/21
                      *
                      * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
                      * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
                      */
                      
                      package java.util;
                      
                      public class ArrayList<E>
                      {
                          private Object[] elementData;
                      
                          private int size;
                      
                          public ArrayList(int initialCapacity) {
                              this.elementData = new Object[initialCapacity];
                          }
                      
                          public E get(int index) {
                              return (E) elementData[index];
                          }
                      
                          public void set(int index, E element) {
                              elementData[index] = element;
                          }
                      
                          public boolean add(E e) {
                              ensureCapacity(size + 1);
                              elementData[size++] = e;
                              return true;
                          }
                      
                          public void ensureCapacity(int minCapacity) {
                              int oldCapacity = elementData.length;
                              if (minCapacity > oldCapacity) {
                                  int newCapacity = (oldCapacity * 3)/2 + 1;
                                  if (newCapacity < minCapacity) newCapacity = minCapacity;
                                  // minCapacity is usually close to size, so this is a win:
                                  elementData = Arrays.copyOf(elementData, newCapacity);
                              }
                          }
                      
                          public E remove(int index) {
                              E oldValue = (E) elementData[index];
                      
                              int numMoved = size - index - 1;
                              if (numMoved > 0) System.arraycopy(elementData, index+1, elementData, index, numMoved);
                              elementData[--size] = null; // Let gc do its work
                              return oldValue;
                          }
                      }
                      It is literally a thin shim over a Java array.
                      Last edited by Kuciwalker; October 19, 2010, 21:12.

                      Comment


                      • #41
                        Simple array, yes, but aren't we discusing multidimensional arrays ? Strings ?
                        With or without religion, you would have good people doing good things and evil people doing evil things. But for good people to do evil things, that takes religion.

                        Steven Weinberg

                        Comment


                        • #42
                          Those would not be any different.

                          Strings are a bit special actually, as I recall. They aren't like C's char* arrays. But Java string literals are adequate.
                          If there is no sound in space, how come you can hear the lasers?
                          ){ :|:& };:

                          Comment


                          • #43
                            .

                            Comment


                            • #44
                              Oh, and overhead can actually be an issue .
                              With or without religion, you would have good people doing good things and evil people doing evil things. But for good people to do evil things, that takes religion.

                              Steven Weinberg

                              Comment


                              • #45
                                Originally posted by Kuciwalker View Post
                                It is literally a thin shim over a Java array.
                                Really? Okay, I was under the false impression that they were some special structure or whatnot.

                                The most annoying thing about string arrays is Java's refusal to overload == to test string equality as opposed to just comparing the references. I don't know, I feel like they should have just made an exception for strings.
                                If there is no sound in space, how come you can hear the lasers?
                                ){ :|:& };:

                                Comment

                                Working...