Announcement

Collapse
No announcement yet.

Java JDK 8 Developer Preview Released

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

  • #16
    Originally posted by johnc View Post
    Well I agree you wouldn't use Java to write a simple Hello World type application.
    But, e.g., a Java app on my Android phone doesn't use that much RAM.
    Java on Android is probably memory optimized unlike stupid Java on Linux.

    Comment


    • #17
      one of the c# niceties I'd like to see are those async constructs. They're also available in Vala if I'm not mistaken. Microsoft forces developers to use async method calls in the RT API so that apps are more responsive. I believe it's the right decision.

      Comment


      • #18
        Originally posted by JS987 View Post
        Some sharing doesn't work automatically. I have force it with -Xshare: on (without space). Now memory usage grows to 110 MB, which is still too much for Hello World class application.
        I think there is something wrong with your system. I don't see nearly that much RAM consumed.

        Code:
        public class HelloWorld {
        
            public HelloWorld () {
                System.out.println("Hello World!");
            }
        
            public static void main(final String[] args) {
                HelloWorld hw = new HelloWorld();
            }
        }
        Code:
        <?xml version="1.0" encoding="UTF-8"?>
        <project name="HelloWorld" default="dist" basedir=".">
            <description>
                Build file for the HelloWorld program.
            </description>
          <!-- set global properties for this build -->
          <property name="src" value="."/>
          <property name="build" value="build"/>
          <property name="jarfile" value="HelloWorld.jar"/>
        
          <target name="dist" description="Build the Java source files, and generate the jar file." >
            <!-- Create the necessary directory structure -->
            <mkdir dir="${build}"/>
            <!-- Create the time stamp -->
            <tstamp/>
            <!-- Compile the java code -->
            <javac srcdir="${src}" destdir="${build}" includeantruntime="false">
              <compilerarg value="-Xlint:unchecked,deprecation"/>
            </javac>
            <!-- Create the jar file -->
            <jar jarfile="${jarfile}" basedir="${build}">
              <manifest>
                <attribute name="Main-Class" value="HelloWorld"/>
              </manifest>
            </jar>
          </target>
        
          <target name="clean" description="Clean up." >
            <!-- Delete the ${build} directory tree -->
            <delete dir="${build}"/>
            <delete file="${jarfile}"/>
          </target>
        
        </project>
        Code:
        $ uname -a
        Linux whitney 3.8.0-30-generic #44-Ubuntu SMP Thu Aug 22 20:52:24 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux
        
        $ java -version
        java version "1.7.0_25"
        OpenJDK Runtime Environment (IcedTea 2.3.10) (7u25-2.3.10-1ubuntu0.13.04.2)
        OpenJDK 64-Bit Server VM (build 23.7-b01, mixed mode)
        
        $ ant
        Buildfile: build.xml
        
        dist:
        
        BUILD SUCCESSFUL
        Total time: 0 seconds
        
        $ /usr/bin/time --verbose java -Xshare:on -jar HelloWorld.jar
        Hello World!
        	Command being timed: "java -Xshare:on -jar HelloWorld.jar"
        	User time (seconds): 0.05
        	System time (seconds): 0.02
        	Percent of CPU this job got: 102%
        	Elapsed (wall clock) time (h:mm:ss or m:ss): 0:00.07
        	Average shared text size (kbytes): 0
        	Average unshared data size (kbytes): 0
        	Average stack size (kbytes): 0
        	Average total size (kbytes): 0
        	Maximum resident set size (kbytes): 17772
        	Average resident set size (kbytes): 0
        	Major (requiring I/O) page faults: 0
        	Minor (reclaiming a frame) page faults: 5124
        	Voluntary context switches: 75
        	Involuntary context switches: 11
        	Swaps: 0
        	File system inputs: 0
        	File system outputs: 0
        	Socket messages sent: 0
        	Socket messages received: 0
        	Signals delivered: 0
        	Page size (bytes): 4096
        	Exit status: 0
        Last edited by sandain; 09-11-2013, 11:56 PM.

        Comment


        • #19
          Originally posted by sandain View Post
          I think there is something wrong with your system. I don't see nearly that much RAM consumed.
          I compared simple GUI applications, not Hello World console examples.

          Comment


          • #20
            Originally posted by JS987 View Post
            I compared simple GUI applications, not Hello World console examples.
            Here is a Swing based Hello World then. I still don't see nearly the RAM usage that you claim.

            Code:
            import java.awt.BorderLayout;
            import java.awt.event.WindowEvent;
            import java.awt.event.WindowAdapter;
            import javax.swing.JFrame;
            import javax.swing.JTextArea;
            
            public class HelloWorld {
            
                public HelloWorld () {
                    JFrame gui = new JFrame();
                    JTextArea textArea = new JTextArea();
                    textArea.setColumns(20);
                    textArea.setRows(5);
                    textArea.append("Hello World");
                    gui.setTitle("Hello World");
                    gui.add(textArea, BorderLayout.CENTER);
                    gui.pack();
                    gui.addWindowListener(new WindowAdapter() {
                        public void windowClosing(WindowEvent we) {
                            System.exit(0);
                        }
                    });
                    gui.setVisible(true);
                }
            
                public static void main(final String[] args) {
                    HelloWorld hw = new HelloWorld();
                }
            }
            Code:
            $ /usr/bin/time --verbose java -Xshare:on -jar HelloWorld.jar
            	Command being timed: "java -Xshare:on -jar HelloWorld.jar"
            	User time (seconds): 0.51
            	System time (seconds): 0.07
            	Percent of CPU this job got: 15%
            	Elapsed (wall clock) time (h:mm:ss or m:ss): 0:03.83
            	Average shared text size (kbytes): 0
            	Average unshared data size (kbytes): 0
            	Average stack size (kbytes): 0
            	Average total size (kbytes): 0
            	Maximum resident set size (kbytes): 43256
            	Average resident set size (kbytes): 0
            	Major (requiring I/O) page faults: 0
            	Minor (reclaiming a frame) page faults: 12993
            	Voluntary context switches: 561
            	Involuntary context switches: 94
            	Swaps: 0
            	File system inputs: 0
            	File system outputs: 0
            	Socket messages sent: 0
            	Socket messages received: 0
            	Signals delivered: 0
            	Page size (bytes): 4096
            	Exit status: 0

            Comment


            • #21
              Originally posted by sandain View Post
              Here is a Swing based Hello World then. I still don't see nearly the RAM usage that you claim.
              demo/jfc/SwingSet2/SwingSet2.jar from jdk-7u40-linux-x64-demos.tar.gz is using 90 MB after startup and grows to 110 MB white testing according to "top"
              132 MB RES - 22 MB SHR = 110 MB of private memory

              Comment


              • #22
                After having tested java8 developer preview, I can say that I am a bit impressed with it.

                Great work!

                I mostly look forward to the HSA changes. There is a small version of it in java8 but the complete implementation will be in java9.

                Comment


                • #23
                  The Java 8 previews have been around in some naming or another since at least September 2011: http://wayback.archive.org/web/20111.../download.html

                  Comment


                  • #24
                    Regarding C# comments:

                    one of the c# niceties I'd like to see are those async constructs
                    Scala >>>>>>>>>>>>>>>>>>>>>> C#/Java.

                    Scala definitely has special async constructs. More importantly, Scala fixes so many major flaws with C/C#/Java. Look at basic "if"/"for", array syntax, generics, type inference, basic variable/function syntax, and properties. C# has all those things, and C++/Java have most, but Scala does all of them much, much better.

                    Scala runs on the Java VM. Java 8 has platform benefits and library benefits that benefit apps written in alternate languages like Scala/Clojure/Groovy/Kotlin.

                    In the Java world, the Java language is the simple option that has more stability, backward compatibility. Scala is the more elegant language with the fancier feature set, but doesn't give you the backwards compatibility or stability of Java.

                    For Android, you can use Scala, since it is JDK 6 compatible, but it's not that easy, so often if you're doing something simple, it isn't worth the effort. Secondly, lots of Android is written in C++. Thirdly, the Android Dalvik runtime is a completely different implementation than the Oracle desktop runtime.

                    Android is stuck at JDK 6, which is bad. Newer versions of Scala will have to move forward and target JDK 7/8, and Android will have to either update or switch to a non-Java option.

                    Comment


                    • #25
                      Originally posted by DanLamb View Post
                      Regarding C# comments:



                      Scala >>>>>>>>>>>>>>>>>>>>>> C#/Java.

                      Scala definitely has special async constructs. More importantly, Scala fixes so many major flaws with C/C#/Java. Look at basic "if"/"for", array syntax, generics, type inference, basic variable/function syntax, and properties. C# has all those things, and C++/Java have most, but Scala does all of them much, much better.

                      Scala runs on the Java VM. Java 8 has platform benefits and library benefits that benefit apps written in alternate languages like Scala/Clojure/Groovy/Kotlin.

                      In the Java world, the Java language is the simple option that has more stability, backward compatibility. Scala is the more elegant language with the fancier feature set, but doesn't give you the backwards compatibility or stability of Java.

                      For Android, you can use Scala, since it is JDK 6 compatible, but it's not that easy, so often if you're doing something simple, it isn't worth the effort. Secondly, lots of Android is written in C++. Thirdly, the Android Dalvik runtime is a completely different implementation than the Oracle desktop runtime.

                      Android is stuck at JDK 6, which is bad. Newer versions of Scala will have to move forward and target JDK 7/8, and Android will have to either update or switch to a non-Java option.
                      I'm curious if you're aware of LINQ, and if so your thoughts on that in combination with C# in comparison with Scala.

                      Comment


                      • #26
                        Originally posted by Luke_Wolf View Post
                        I'm curious if you're aware of LINQ, and if so your thoughts on that in combination with C# in comparison with Scala.
                        From what I've used LINQ is a custom syntax inside of C# that provides:

                        - Functional collections library. You can use this with normal C# syntax or the LINQ syntax. They changed the normal functional names to use SQL-like names. map->select, fold->aggregate, filter->where
                        - Database and XML integration. Also ORM functionality although I'm not sure if that is labeled LINQ or Entity Framework. The database stuff is Microsoft SQL Server only, but lets you write LINQ expressions that get generally efficient translations into database calls, and provide type safety and refactoring as opposed to completely string based SQL which can't be type checked or refactored with tools.

                        For functional collections, Scala clearly has had that stuff since the very beginning.

                        I like that Scala's core language is good enough that it doesn't need to bolt on an extra special case language syntax.

                        For SQL database integration, I'm __really__ skeptical about ORM. I've used Hibernate and NHibernate quite a bit, and while they look great and fancy at first, in hindsight they are more trouble than they are worth. I know the Rails guys are happier with ActiveRecord (which is the Rails ORM solution).

                        LINQ looks like a big step up over the old way of using text SQL strings all over your code in that you get compilation checks and type safety. The official Scala (Typesafe) parallel is called "slick" (http://slick.typesafe.com/). Honestly, I have never used either, so I really don't know how good they are at this. (I have used basic LINQ functional collections, just not the database integration). I'd like to try both, but the only SQL heavy projects I have done in the past several years were locked into older technology stacks.

                        Comment


                        • #27
                          Originally posted by Luke_Wolf View Post
                          I'm curious if you're aware of LINQ, and if so your thoughts on that in combination with C# in comparison with Scala.
                          Also, I'd like to add that Microsoft has C# as the easier, practical, low learning curve language and F# is the sophisticated language for people who can take the time to learn it. It's very similar to Java and Scala on the JVM. I don't think anyone who has learned Scala or F# would consider Java or C# in the same ballpark of sophisticated language design. But they are much easier to learn.

                          Learning Scala one feature at a time is really easy and amazing, but if you dive into advanced production Scala code with the fancier libraries, it is a real wall of complexity. There is a pay off, but there is a learning curve.

                          Personally, I think the big difference between .NET vs JVM is not the languages, it's the ecosystem. JVM has a much more decentralized open source community driven nature, while .NET is much more top down Microsoft centric. I've worked for lots of companies who are using and loving Office, SharePoint, SQL Server, and a full MS stack, and .NET is the best programming platform to perform various integration tasks.

                          Comment


                          • #28
                            Originally posted by DanLamb View Post
                            Also, I'd like to add that Microsoft has C# as the easier
                            C# doesn't even have same support on Linux as on Windows

                            Comment


                            • #29
                              Originally posted by JS987 View Post
                              C# doesn't even have same support on Linux as on Windows
                              Things change.

                              Comment

                              Working...
                              X