Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #31540

Re: Return of the Applets?

From Kevin McMurtrie <mcmurtrie@pixelmemory.us>
Newsgroups comp.lang.java.programmer
Subject Re: Return of the Applets?
References <Applets-20150405060326@ram.dialup.fu-berlin.de> <mcmurtrie-EF858B.21310806042015@news.sonic.net> <applets-20150407183812@ram.dialup.fu-berlin.de> <55242050$0$2821$e4fe514c@news2.news.xs4all.nl>
Date 2015-04-08 22:17 -0700
Message-ID <mcmurtrie-BF8419.22172308042015@news.sonic.net> (permalink)
Organization Sonic.Net

Show all headers | View raw


In article <55242050$0$2821$e4fe514c@news2.news.xs4all.nl>,
 Silvio <silvio@internet.com> wrote:

> On 04/07/2015 06:38 PM, Stefan Ram wrote:
> > Kevin McMurtrie <mcmurtrie@pixelmemory.us> writes:
> >> Applets died because their API and packaging is a complete wreck.
> >
> >    Yet the quite recent Java EE 7 tutorial at Oracle says:
> >                                ===
> >        ť1.3.2 Java EE ComponentsŤ ... ť
> >
> >        The Java EE specification defines the following Java EE
> >        components:
> >
> >        ˇ Application clients and applets are components that
> >        run on the client.        =======
> >
> >        ˇ Java Servlet, JavaServer Faces, and JavaServer Pages
> >        (JSP) technology components are web components that run
> >        on the server.
> >
> >        ˇ EJB components (enterprise beans) are business
> >        components that run on the server.Ť
> >
> >> number and pixel crunching difficult.  (Java sucks at arrays of objects
> >> but arrays of primitives work well.)
> >
> >    Really! Herb Sutter reported how someone just put all his
> >    objects of the same class into a single array (for 3 key
> >    classes) and his game ran 50 times faster (compared to
> >    scattered heap allocation).
> >
> >    Today, not only do we have cache, but we have prefetchers.
> >
> >    Oracle could define an annotation for classes that means
> >    that all objects of this class should reside within a
> >    single array.
> >
> 
> How does an array of objects help prevent scattered heap allocation?

The opposite.

Rather than creating an array of objects, it's turning each field of an 
object into an array.  Sadly, I've done this too.

------------

//Clean but extremely slow Java
class Pixel
{
   byte r, g, b, a;
   
   void setRGB (byte red, byte green, byte blue, byte alpha)
   {
      r = red;
      g = green;
      b = blue;
      a = alpha;
   }
}

Pixel bitmap[][] = new Pixel[1080][1920];
for (int y = 0; y < bitmap.length; ++y)
{
   Pixel row[] = bitmap[y];
   for (int x = 0; x < row.length; ++x)
   {
      Pixel p = new Pixel();
      p.setRGB ((byte) x, (byte) y,
         (byte) (x + y), (byte) 255);  //Colors!
      row[x] = p;
   }
}

------------

//Fast Java but ugly
class Pixels
{
   byte rgba[][][] = new byte[4][1080][1920];

   void setRGB (byte red, byte green, byte blue,
      byte alpha, int x, int y)
   {
      rgba[0][y][x] = red;
      rgba[1][y][x] = green;
      rgba[2][y][x] = blue;
      rgba[3][y][x] = alpha;
   }
}

Pixels bitmap = new Pixels();
for (int y = 0; y < 1080; ++y)
   for (int x = 0; x < 1920; ++x)
      bitmap.setRGB ((byte) x, (byte) y,
         (byte) (x + y), (byte) 255, x, y); //Colors!

------------

// Very fast C++
struct Pixel
{
   uint8_t r, g, b, a;
   
   void setRGB (uint8_t red, uint8_t green,
         uint8_t blue, uint8_t alpha)
   {
      r= red;
      g= green;
      b= blue;
      a= alpha;
   }
};


Pixel bitmap[1080][1920];

for (int y= 0; y < 1080; ++y)
   for (int x= 0; x < 1920; ++x)
      bitmap[y][x].setRGB(x, y, x+y, 255);   //Colors!

-- 
I will not see posts from astraweb, theremailer, dizum, or google
because they host Usenet flooders.

Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Re: Return of the Applets? Kevin McMurtrie <mcmurtrie@pixelmemory.us> - 2015-04-06 21:31 -0700
  Re: Return of the Applets? Silvio <silvio@internet.com> - 2015-04-07 20:22 +0200
    Re: Return of the Applets? Kevin McMurtrie <mcmurtrie@pixelmemory.us> - 2015-04-08 22:17 -0700
      Re: Return of the Applets? Silvio <silvio@internet.com> - 2015-04-10 17:11 +0200
  Re: Return of the Applets? Kevin McMurtrie <mcmurtrie@pixelmemory.us> - 2015-04-08 22:22 -0700

csiph-web