Author Topic: Java stuffs  (Read 498 times)

Bonknuts

  • Hero Member
  • *****
  • Posts: 3292
Java stuffs
« on: June 06, 2016, 12:34:32 PM »
So I got to write Java code for the first time, today. The class I'm taking is Java oriented. So far it's pretty easy to pick up, but we haven't done too much yet. Having experience with C makes picking up other languages' syntax fairly easy (well, the related ones anyway). Java's a little word-y, but that doesn't bother me.

 In the spring, they're replacing all their Java related classes with Python. I though that weird. I'm little bit glad that I'm not coding with python (I can always do that on my own, if need be).

 What are your guys thoughts on Java? Using the Eclipse IDE with it, is kinda nice.

Punch

  • Hero Member
  • *****
  • Posts: 3278
Re: Java stuffs
« Reply #1 on: June 06, 2016, 02:31:37 PM »
I used it a lot to do concurrent programming stuff. Way easier to use than C or C++ for that purpose. It's a pretty handy tool all things considered, even though it's not suited to solve some specific problems.

Being able to deploy to android, PC, linux, etc. with minimal adjustments is a nice bonus.

Sadler

  • Hero Member
  • *****
  • Posts: 1065
Re: Java stuffs
« Reply #2 on: June 07, 2016, 04:14:51 AM »
My first experience with Java was making a game sponsored by Sun as my senior project in college. I knew C/C++ and some assembly going in to it and I knew that Java ran on a virtual machine and had garbage collection. I was pretty biased against Java, I wanted to be as close to the hardware as possible. Fortunately Sun had been working on JOGL, which allowed us to use shaders to do some effects that were neat at the time (normal mapping, environment mapping, procedural textures on terrain, etc).

After I graduated I got a job working on software that basically amounted to a game editor. I convinced them to let me redo the 2D graphics in it with 3D graphics using JOGL. That code is still in use 10 years later. :D I'm still at the same place now, still using Java (and some C#). In the years since college I've come to appreciate the ease that Java allows you to do things, but I do think it's significantly behind C#. I guess I'm a bit out of the loop with how features are handled behind the scenes in 1.8, but generics were pretty hacky in Java 1.5 (the type didn't exist at run time). 1.8 added lambda expressions and concurrent programming is a lot easier than it used to be thanks to parallel streams. I still prefer C# to Java, but Java is slowly catching up. I'd rather use Java or C# than C or C++ nowadays.

EDIT: God, I really need to proofread what I write.
« Last Edit: June 08, 2016, 03:25:38 AM by Sadler »

xelement5x

  • Hero Member
  • *****
  • Posts: 3921
Re: Java stuffs
« Reply #3 on: June 07, 2016, 07:03:58 AM »
I'm personally pretty amazed with how efficient Java has become over the years of refinement.  I took some introductory CS courses using it when I was in school, but C/C++ was used for the core of the curriculum so any Java use was purely for side projects. 

At this point I mainly use C# for a lot of what I do.  It's fast to code in, pretty quick, and easy to rapidly prototype projects. 
Gredler: spread her legs and push her down to make her more lively<br>***<br>majors: You used to be the great man, this icon we all looked up to and now your just a pico collecting 'tard...oh, how the mighty have fallen...<br>***<br>_joshuaTurbo: Sex, Lies, Rape and Arkhan. A TurboGrafx love story

bartre

  • Guest
Re: Java stuffs
« Reply #4 on: June 07, 2016, 07:16:52 PM »
Eclipse is actually really great.
NetBeans is also pretty solid for java.

I've been dealing with Java since I was in high school, so I'd like to think I'm pretty familiar with it.
kinda hard to believe that it's almost time to replace it

Gentlegamer

  • Hero Member
  • *****
  • Posts: 1459
Re: Java stuffs
« Reply #5 on: June 08, 2016, 01:21:21 AM »
Nerds.

bartre

  • Guest
Re: Java stuffs
« Reply #6 on: June 11, 2016, 10:56:14 AM »

Bonknuts

  • Hero Member
  • *****
  • Posts: 3292
Re: Java stuffs
« Reply #7 on: June 11, 2016, 03:41:53 PM »
Java seems alright. The cross platform thing intrigues me. If GUI frameworks are as easy as people make them out to be, I'll probably try my hand at some.

spenoza

  • Hero Member
  • *****
  • Posts: 2751
Re: Java stuffs
« Reply #8 on: June 12, 2016, 12:09:02 PM »
Java can pretty much do whatever you want it to, short of a AAA graphics showcase game. But it's VERY good for secure networked applications. Being able to roll out a client application to almost any platform is a godsend. Python's great, too, and might even be better for introductory programming, but it's not a good replacement for much of what Java can do.
<a href="http://www.pcedaisakusen.net/2/34/103/show-collection.htm" class="bbc_link" target="_blank">My meager PC Engine Collection so far.</a><br><a href="https://www.pcenginefx.com/forums/" class="bbc_link" target="_blank">PC Engine Software Bible</a><br><a href="http://www.racketboy.com/forum/" c

Bonknuts

  • Hero Member
  • *****
  • Posts: 3292
Re: Java stuffs
« Reply #9 on: June 16, 2016, 10:22:45 AM »
OK you Java jockeys... can you do this exercise without any if statements?
http://codingbat.com/prob/p174254

Sadler

  • Hero Member
  • *****
  • Posts: 1065
Re: Java stuffs
« Reply #10 on: June 16, 2016, 11:15:24 AM »
Is this cheating?

public String withouEnd2(String str) {
  int len = str.length();
  int start =Math.max(0,Math.min(1, len - 1));
  int end =Math.max(0, len -1);
  return str.substring(start, end);
}

Edit: first time I've written code on my phone. That's kinda awesome!  :D

Edit 2: the obvious solution is to abuse exceptions. Please don't abuse exceptions. You could also use a Map or polymorphism.
« Last Edit: June 16, 2016, 11:30:30 AM by Sadler »

Bonknuts

  • Hero Member
  • *****
  • Posts: 3292
Re: Java stuffs
« Reply #11 on: June 16, 2016, 11:43:46 AM »
That's not cheating. That works!

 Mine was less elegant:

public String withouEnd2(String str) {
      int n = str.length();
      int nPower3 = n * n * n;
      int nPower2 = n * n;
      int middleLen = ( (nPower3 + 1) / (nPower2 + 1) ) -1 ;
      
      
      int startPoint =  (int) ((double) middleLen / (n - 2.001));
      int endPoint = middleLen + startPoint;
   
      
      return str.substring(startPoint, endPoint);

}

Sadler

  • Hero Member
  • *****
  • Posts: 1065
Re: Java stuffs
« Reply #12 on: June 16, 2016, 11:59:38 AM »
Heh, that's pretty creative!

Edit: Because this forum hates double posts.


public String withouEnd2(String str) {
  Map<Boolean,Integer> scalar = new HashMap <Boolean,Integer>();
  scalar.put(true,0);
  scalar.put(false,1);
  int len = str.length();
  int scale = scalar.get(len < 3);
 
  int start = 1 * scale;
  int end = (len -1) * scale;
  return str.substring(start, end);
}

The editor on that page is a bit weird. It doesn't support the diamond operator and it really dislikes static.
« Last Edit: June 16, 2016, 12:44:29 PM by Sadler »