Java-Gaming.org    
Featured games (79)
games approved by the League of Dukes
Games in Showcase (475)
Games in Android Showcase (105)
games submitted by our members
Games in WIP (524)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Oracle not about to sue anybody over Javascript  (Read 3224 times)
0 Members and 1 Guest are viewing this topic.
Offline VeaR

Junior Member





« Posted 2010-08-17 15:40:05 »

Split from thread 'Oracle sues Google over use of Java in Android'


JEE isn't going anywhere, let's not forget that Oracle has a lot of business there. And also let's not forget that this is about Android/Dalvik.
I'm concerned too, but I think a lot of people here are waaaay too panicy about the whole thing.

JEE could be much better, it is holding back invention. All those stacks of libraries around and on top of each other, its a mess. Restart ~ 2 minutes, patching ~ 1 hour... Its as messy as Windows apps were with OLE and ODBC.

And Oracle's own software isn't that pretty either.

Not a fan of it, but Node.js could go a long way.
Online Riven
« League of Dukes »

JGO Overlord


Medals: 730
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #1 - Posted 2010-08-17 16:22:39 »

The problem is js is that it's very hard to keep it maintainable, even for small projects.

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social rankings
Offline kappa
« League of Dukes »

JGO Kernel


Medals: 74
Projects: 15


★★★★★


« Reply #2 - Posted 2010-08-17 20:04:15 »

while I can't comment if javascript is hard to maintain, it does look good with support for it in technologies like Unity3d.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline oNyx

JGO Coder


Medals: 1


pixels! :x


« Reply #3 - Posted 2010-08-18 03:19:55 »

IME it's actually not that bad. With the help of JSLint everyone can reach a pretty decent level of code quality. There are good editors and excellent resources (books & videos), you can generate documentation, and there are many patterns to chose from.

If you are a fan of mixins and traits you can tack that on with libraries/frameworks like Joose.

Personally, I'm still surprised that JavaScript is actually a pretty decent language. Well, it surely got its quirks, but below all that mess and all that awful code out there, there is actually a very expressive and compact language.

Right now it's my favorite language. I'm having lots of fun with it for some reason. My past self would be surely disgusted. Smiley

弾幕 ☆ @mahonnaiseblog
Online Riven
« League of Dukes »

JGO Overlord


Medals: 730
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #4 - Posted 2010-08-18 03:28:32 »

IME it's actually not that bad. With the help of JSLint everyone can reach a pretty decent level of code quality. There are good editors and excellent resources (books & videos), you can generate documentation, and there are many patterns to chose from.

If you are a fan of mixins and traits you can tack that on with libraries/frameworks like Joose.

Personally, I'm still surprised that JavaScript is actually a pretty decent language. Well, it surely got its quirks, but below all that mess and all that awful code out there, there is actually a very expressive and compact language.

Well doh Smiley JS is an excellent language, with nearly infinite freedom to the programmer -- that's where the maintainability issue comes in! How many javascripters know about the crucial '===' operator? Oh well, let's not get in a language discussion, because I think we both love it, yet wouldn't want to work with somebody elses JS.

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social rankings
Offline kaffiene
« Reply #5 - Posted 2010-08-18 03:49:13 »

No, JS is *not* a good language for anything over and above trivial scripts.  For applications, its appalling.  Strict static typing was developed for a reason, and it doesn't take long dealing with any large JS codebase before you find out why - it saves you from doing stupid shit that a compiler can trap for you.

JS doesn't have any include / import function.  It doesn't have modules / namespaces.  It doesn't have file-scoped variables (It's all global baby!!).  The foreach iterator is borked for arrays (it returns strings, not index numbers and if you have extended the array prototype, it returns prototype functions as well as indicies!).  It was explicitly designed for small tasks and on top of that it runs very slowly compared to Java/C/C++.

Javascript makes sense for in-page HTML scripting.  For large apps it's a PITA.  An JSLint is a piece of shit.  Half the things it reports as errors aren't (e.g.: preferring === to == can be wrong depending on input but JSLint will always recommend the former)
Offline oNyx

JGO Coder


Medals: 1


pixels! :x


« Reply #6 - Posted 2010-08-18 04:19:06 »

@Riven

>How many javascripters know about the crucial '===' operator?

JSLint. Wink


@kaffiene

>It doesn't have file-scoped variables (It's all global baby!!).

There should be at most one global variable. Also, Java isn't file-scoped - it's block-scoped. JavaScript on the other hand uses function scope. Unfortunately it defaults to the global object, but JSLint will point this out if necessary.

>The foreach iterator is borked for arrays [...]

Why would you use foreach? It's too much to type (requires a guarding hasOwnProperty check). Also, do you mean for-in or the new forEach?

>[foreach] returns strings, not index numbers [...]

For-in gives you the keys. You are supposed to use it to iterate over the properties of some object. Either way yourArray['0'] will give you the first item.

>if you have extended the array prototype

Don't modify objects you don't own.

>it returns prototype functions as well as indicies

Hence the hasOwnProperty guarding condition. Again, JSLint points this out.

>It was explicitly designed for small tasks and on top of that it runs very slowly compared to Java/C/C++.

Well, it's faster than Python, Ruby, Lua, etc. So, it's really not that slow.

>An JSLint is a piece of shit.  Half the things it reports as errors aren't
>(e.g.: preferring === to == can be wrong depending on input but JSLint
>will always recommend the former)

Well, if you write something like if (foo == null) and you aren't actually looking for null here, but for undefined, then replacing the == with === will break the program. It only worked initially, because those two errors canceled each other out.

If you want to check if some variable is truthy or falsy you should use if (foo) or if (!foo) and similar constructs.

You shouldn't use == or != ever (and there really is no need to use them), since it won't be clear what your real intention was.

弾幕 ☆ @mahonnaiseblog
Offline zammbi

JGO Coder


Medals: 4



« Reply #7 - Posted 2010-08-18 05:32:57 »

JSLint looks quite handy. That will help me when I need to do some small Javascript work.

Current project - Rename and Sort
Offline bjgil2

Senior Newbie




That's it Mr. Giraffe, get all the marmalade


« Reply #8 - Posted 2010-08-18 11:34:20 »

wow

*accompanied by the sounds of a camel's back breaking*
Offline oNyx

JGO Coder


Medals: 1


pixels! :x


« Reply #9 - Posted 2010-08-18 15:38:07 »

JSLint looks quite handy. That will help me when I need to do some small Javascript work.

Komodo Edit + the kjslint addon (+on before save macro trigger if you don't like pressing another button or using a separate shortcut).

For pain/hassle free but still pretty good minificiation use the YUI Compressor. While the Closure compiler saves a few percent more, it does require lots of attention and hand-holding. Personally, I can't be arsed with that.

弾幕 ☆ @mahonnaiseblog
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline kaffiene
« Reply #10 - Posted 2010-08-19 01:37:14 »

@kaffiene

>if you have extended the array prototype

Don't modify objects you don't own.

[other opinions about which bits of the language to use snipped]

Sure.  And you're back into the C++ trap.  It's a fine language if everyone uses it the way you do.  f**king awful if their list of language features to use or avoid differs from yours.  And it *always* differs from yours.  Each programmer lives in a different cul-de-sac of the full language.

Languages that make it easy to blow your foot off (like C++, JS) are annoying.

And the lack of static typing is annoying beyond belief.  I read on slashdot recently someone saying why they gave up ruby programming - so much time writing tests where 90% of that was just checking that the parameters and types were correct.  That's what machines are for, for christ's sake.

And even when you have tests (as we do) the lack of typing still manages to bite you in the arse.  I lost a whole f**king day debugging an issue where something was broken but continued on silently due to a type change that a statically typed language would have told me about immediately.

You don't find these things in small hacks but when you start dealing with complex code bases in JS, it just creaks - it's not designed for it.  I mean, come on - you can't even include library code into another JS file FFS.  That's as basic as it gets.


Offline Nate

JGO Kernel


Medals: 144
Projects: 4
Exp: 14 years


Esoteric Software


« Reply #11 - Posted 2010-08-19 05:16:04 »

In somewhat related news, I gave Rhino a try a couple days ago. Wow it is bad, at least for my needs. The type system doesn't mesh well with Java at all. After a day of trying to convert between the types in my Java and JavaScript code, I finally trashed the whole idea. I'm now doing it in straight Java and I'll be able to tack on some scripting later. It certainly won't be Rhino though!

What are some JVM scripting languages that use the same type system as Java? Pnuts is one, but I wanted to try out something else. I really want something close to Java, but less verbose, as Java developers will be writing this script. I've looked at Beanshell, but I don't feel it is written particularly well. Nice looks interesting.

Offline oNyx

JGO Coder


Medals: 1


pixels! :x


« Reply #12 - Posted 2010-08-19 07:07:15 »

>And it *always* differs from yours.

All of our code must pass JSLint and modifying other objects is forbidden. Also, we don't use libraries which modify build-in objects (e.g. Prototype). We also got code and documentation conventions. Reading JavaScript: The Good Parts is also mandatory.

To be fair, I came up with those rules. I'm in charge of that stuff here.

Edit: Splitting the thread and adding that kind of headline is sorta silly. No one feared that Oracle might sue anyone over JavaScript.

弾幕 ☆ @mahonnaiseblog
Online Riven
« League of Dukes »

JGO Overlord


Medals: 730
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #13 - Posted 2010-08-19 07:52:01 »

Edit: Splitting the thread and adding that kind of headline is sorta silly. No one feared that Oracle might sue anyone over JavaScript.

...

Well doh. It was meant as a silly reference to the old thread, so that people would immediately know what happened. Feel free to suggest a new thread headline, if it's important to you.

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social rankings
Online Riven
« League of Dukes »

JGO Overlord


Medals: 730
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #14 - Posted 2010-08-19 07:54:31 »

In somewhat related news, I gave Rhino a try a couple days ago. Wow it is bad, at least for my needs. The type system doesn't mesh well with Java at all. After a day of trying to convert between the types in my Java and JavaScript code, I finally trashed the whole idea. I'm now doing it in straight Java and I'll be able to tack on some scripting later. It certainly won't be Rhino though!

Rhino can certainly be a PITA, but exactly what problems did you run into? I built a set of wrapper classes that (at least for me) solve all annoyances. If I know the problem, and my code fixes it, I can put some code in the public domain.

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social rankings
Offline zammbi

JGO Coder


Medals: 4



« Reply #15 - Posted 2010-08-19 08:18:50 »

What? Oracle is now going to sue over Javascript?! those b.... Roll Eyes

Current project - Rename and Sort
Online CommanderKeith
« Reply #16 - Posted 2010-08-19 10:21:48 »

In somewhat related news, I gave Rhino a try a couple days ago. Wow it is bad, at least for my needs. The type system doesn't mesh well with Java at all. After a day of trying to convert between the types in my Java and JavaScript code, I finally trashed the whole idea. I'm now doing it in straight Java and I'll be able to tack on some scripting later. It certainly won't be Rhino though!

What are some JVM scripting languages that use the same type system as Java? Pnuts is one, but I wanted to try out something else. I really want something close to Java, but less verbose, as Java developers will be writing this script. I've looked at Beanshell, but I don't feel it is written particularly well. Nice looks interesting.

Go for janino, it rocks. www.janino.net

It's compiled to byte code so it's fast and uses exactly the same syntax as java so it's cut-and-paste from java to janino. Beanshell is a poor man's janino.

The only problem with janino is that it's based on java 1.4 syntax, so it hasn't got generics and auto-boxing so it can't understand that code. It can run on java 1.5 and 6, it just can't use those new language features.

Offline erikd

JGO Ninja


Medals: 16
Projects: 4
Exp: 14 years


Maximumisness


« Reply #17 - Posted 2010-08-19 12:25:52 »

Quote
And the lack of static typing is annoying beyond belief.

Agree 100%
I can never understand why people would want to use a language with no static typing in a project larger than 10 lines of code.
No static typing to me just means that an important part of the code (typing) becomes invisible, obfuscating bugs, making the code less readable, and delaying compile time errors to runtime errors.

For scripting I've also done a lot with Groovy. I started out being quite enthousiastic about it, but the more I've used it, the more I detest it.
Too much 'magic' going on there under hood, too much focused on making things more readable for non-programmers but ending up less readable for developers (because for example a lot of code you write implies functionality and code Groovy hides from you). And it's soooo bloated a language it's not funny anymore. And oh yeah, it's slow too.
Well, at least it supports static typing and interoperates naturally with Java, but other than that I dislike it a lot. </rant>

Offline Nate

JGO Kernel


Medals: 144
Projects: 4
Exp: 14 years


Esoteric Software


« Reply #18 - Posted 2010-08-19 22:50:29 »

Hmm, Janino's site seems down... I'll try again later.

Rhino can certainly be a PITA, but exactly what problems did you run into? I built a set of wrapper classes that (at least for me) solve all annoyances. If I know the problem, and my code fixes it, I can put some code in the public domain.

I had a utility function written in Java that got uglier and uglier. It went something like this...
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
public Stuff getStuff (Object object) {
   if (object instanceof String)
      stuff
   else if (object instanceof NativeArray) {
      NativeArray array = ((NativeArray)object);
      for (int i = 0, n = (int)array.getLength(); i < n; i++)
         stuff
   } else if (object instanceof NativeJavaObject) {
      object = ((NativeJavaObject)object).unwrap();
      if (object instanceof ArrayList) {
         for (String dirPattern : (ArrayList<String>)object)
            stuff
      } else
         throw new RuntimeException("Unknown object type: " + object.getClass());
   } else
      throw new RuntimeException("Unknown object type: " + object.getClass());
   return stuff;
}

It wasn't clear why String was not wrapped -- if I wanted access to the JavaScript native string, I guess I can't. Anyway, writing that left a bad taste in my mouth. I imagine there would be a similar circus on the JavaScript side of things. A small library to handle conversions would help, but I imagine converting back and forth would become very tedious and error prone. I think it should be seamless to work well.

Groovy is really terrible. Crazy how much hype that steamy pile has gotten.

Online Riven
« League of Dukes »

JGO Overlord


Medals: 730
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #19 - Posted 2010-08-19 23:01:53 »

I don't have time right now, and I don't even know whether this answers your question -- my Rhino is a bit rusty. Will look into it tomorrow.

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
   public <T> T getVariable(String name, Class< T > type)
   {
      try
      {
         this.enterContext();

         return (T)Context.jsToJava(this.getJs(name), type);
      }
      finally
      {
         this.exitContext();
      }
   }

   public Object getJs(String name)
   {
      try
      {
         this.enterContext();

         return ScriptableObject.getProperty(this.rhinoScope, name);
      }
      finally
      {
         this.exitContext();
      }
   }

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social rankings
Online Riven
« League of Dukes »

JGO Overlord


Medals: 730
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #20 - Posted 2010-08-19 23:08:13 »

Here is my Rhino Wrapper, FWIW. (download)

From your example it's not exactly clear what you're trying to do, it's just a big mess Smiley I see how feeling to have to write such code can be demotivating.


Here is how I grab the results of File.list() from JS:
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
   public static void main(String[] args)
   {
      try
      {
         JsScope scope = new JsScope();

         System.out.println(scope.eval("importClass(Packages.java.io.File)"));
         System.out.println(scope.eval("var file = new File('M:/');"));
         System.out.println(scope.eval("var list = file.list();"));
         String[] list = scope.getVariable("list", String[].class);
         System.out.println(list);
         System.out.println(list.length);
      }
      catch (JavaScriptException exc)
      {
         System.err.println("Exception: Line " + exc.lineNumber() + ": " + exc.getMessage());
      }
      catch (EvaluatorException exc)
      {
         System.err.println("Line " + exc.lineNumber() + ": " + exc.getMessage());
      }
   }


Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social rankings
Online Riven
« League of Dukes »

JGO Overlord


Medals: 730
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #21 - Posted 2010-08-20 14:28:22 »

Did my code help to cleanup your accessor-code?

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social rankings
Offline Nate

JGO Kernel


Medals: 144
Projects: 4
Exp: 14 years


Esoteric Software


« Reply #22 - Posted 2010-08-28 23:38:22 »

Sorry Riven, I missed your post!

It looks like your class would handle a lot of what I was annoyed with. Hard to believe the Rhino API doesn't have something like that already. However, I decided to go ahead with my project (Scar) with just Java code, and I think that was a good move. It forced me to make the API simple and concise in Java, rather than relying on a scripting language to make it easy to use. This way the core of it is tight, and a scripting language can still be used later. Right now I'm just using the JDK6 compiler to compile and run Java snippets on the fly.

Offline Roquen
« Reply #23 - Posted 2010-08-29 10:25:25 »


As an aside. Dynamic typed language advocates will argue that strongly typed language are hard to maintain.  You have to keep rewritting the same pieces of code, over and over to provide a given functionality over a specific (potentially root) type.  This code duplication requires time to create and for any needed code modification (bug, optimization, etc) then all the copies have to be tracked down and modified.  All of these things decrease productivity and increase the probability of bugs.
Online CommanderKeith
« Reply #24 - Posted 2010-08-29 13:48:27 »

That's interesting.

Interfaces are meant to solve that problem though aren't they? If you code to an interface then anything can implement the interface and it works out.

I used to try and make interfaces everywhere but it just ended up very verbose to have an interface for everything, because effectively it's like writing code twice - once for the interface which has the method declarations and once for the implementing class. And it's not easy to modify things because you have to change the interface and all of the implementing types.

Online Riven
« League of Dukes »

JGO Overlord


Medals: 730
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #25 - Posted 2010-08-29 14:04:13 »

I think sorting is a good example here, check you the code in Arrays:

Arrays.sort(byte[])
Arrays.sort(short[])
Arrays.sort(char[])
Arrays.sort(int[])
Arrays.sort(long[])
Arrays.sort(float[])
Arrays.sort(double[])
Arrays.sort(Object[])


It's a lot of duplicated code. C has templates, C# has generics supporting primitives, but in the end, you either have to write the different implementations yourself (Java), or let them be generated (C/C++/C#), but you end up with duplicated code. In dynamically typed languages, you have this code exactly once, even in memory. It will figure out everything at runtime, as a huge performance cost, ofcourse.

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social rankings
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

SHC (32 views)
2014-07-12 17:50:04

Riven (32 views)
2014-07-10 20:20:18

CopyableCougar4 (31 views)
2014-07-10 02:26:14

CopyableCougar4 (32 views)
2014-07-09 02:55:38

Code Mage (33 views)
2014-07-08 23:57:00

Code Mage (21 views)
2014-07-08 23:49:08

AppleSauce (28 views)
2014-07-08 19:25:32

CopyableCougar4 (30 views)
2014-07-06 01:51:26

ipe369 (35 views)
2014-07-05 14:18:25

vastrolorde (44 views)
2014-07-04 18:45:44
HotSpot Options
by dleskov
2014-07-08 03:59:08

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:58:24

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:47:22

How do I start Java Game Development?
by ra4king
2014-05-17 11:13:37

HotSpot Options
by Roquen
2014-05-15 09:59:54

HotSpot Options
by Roquen
2014-05-06 15:03:10

Escape Analysis
by Roquen
2014-04-29 22:16:43

Experimental Toys
by Roquen
2014-04-28 13:24:22
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!