Well, depends what you mean.
Most notably, Jython has no Global Interpreter Lock (GIL) that famously plagues CPython. So it certainly can work well compared to CPython on multicore systems within one OS process.
Jython compiles python to JVM bytecode (CPython is also a kind of bytecode VM, though obviously not the same), and a typical JVM is very highly tuned, so in that sense it's not particularly slow either. But Python code is still typically going to wind up somewhat slower at run time (though widely considered easier to read and write at dev time) than Java, because of certain memory model design choices and of course the nature of the language - python is dynamically typed (with moves afoot for optional static) and particularly late binding even as dynamic languages go.
Android apps run in a custom Java Virtual Machine, Dalvik, which executes any virtual machine byte code. Though I haven't tried, you could use Jython.
Android of course is Linux, so technically it's possible, though probably very hard, to program native applications in C/C++.
I've seen an attempt to create .net apps with mono on Android, but I don't think it went very far.
So technically it could be possible to use python, although your safest bet for smooth development is Java.
Jython was dormant a few years ago. But it was just upgraded to Python 2.7 compatibility earlier this year, and their mailing lists are active. Next step is Python3 compatibility I believe.
Nashorn is Java 8 only but you can use the older JavaScript Engine; Rhino if the use is using an older version of Java with minimum fuss.
Something like this (you'd likely want to use a for loop mind you):
String[] engines = {"nashorn", "rhino"}; ScriptEngineManager engineManager = new ScriptEngineManager(); ScriptEngine engine = null; while(engine == null && i < engines.length) { engine = engineManager.getEngineByName(engines[i]); i ++; }
Nashorn is a lot better in many regards so hopefully they will have Java 8 but having a fallback is always a good idea.
I've yet to use them in a game but have really wanted to.
Something else that's worth mentioning is that you can use other languages with this scripting interface, although it is hard to find them, Jython is one if I recall correctly.
A good link on it is the technotes from Java 7 JSR-223 (I did research on this stuff a year or two ago for work).
> Jython (dead project but no GIL)
how is jython dead? a 2.7 compatible beta was just released according to wiki http://en.wikipedia.org/wiki/Jython#Status_and_roadmap
and sho nuff it's right there. http://www.jython.org/downloads.html
Theoretically (and the key here is theoretically), you could use Jython to write bukkit plugins. I've never done it, and I'm not familiar with Jython, but it does target the JVM so it might be usable.
It's not that the file won't be closed on GC, it's that some of the other Python implementations don't GC the reference immediately. Jython for instance:
> In CPython, an object is garbage collected when it goes out of scope or is no longer needed. This occurs automatically and rarely needs to be tracked by the developer. Behind the scenes, CPython uses a reference counting technique to maintain a count on each object which effectively determines if the object is still in use. Unlike CPython, Jython does not implement a reference counting technique for aging out or garbage collection unused objects. Instead, Jython makes use of the garbage collection mechanisms that the Java platform provides. ... Never code the close() method for a file into a finalizer because it may cause an issue if the finalizer is not invoked.
Leave it up to the GC and it may be arbitrarily long before the file handle is actually closed and recovered for use.
Even in CPython, it's not a safe idiom. In small sample code it looks perfectly fine, but in real code, if you're passing the file handle around at all it doesn't take much of a slip for the file to end up living a lot longer than you expected. (Oops, passed it into a library routine which also generated a closure and registered that closure somewhere persistent with my file handle in it...) Resources are best shielded with "with" when at all possible.
For loops (see the for x in range(10) ) example. and look up random.shuffle()
random module. To get access to random.shuffle, you need an import random statement at the top of your script.
So.
In all seriousness, Java's not a bad place to go. Definitely large syntax differences, but once you get the hang of that type of syntax (which I call C-like), you'll find it easy to jump around to JavaScript, C and the like. Java's got a good standard library, though, and tutorials abound all over the internet. I'm pretty sure Google even has courses on it to get people into Android.
Well, first of all, there are compilers for other languages to the JVM, for example jython or perljvm.
Also, Java bytecode is not the only bytecode format, there's also .NET, cpython, x86, x64, and ARM bytecode. The only difference between them are different storage architecture (number of registers / how memory is accessed) and instruction sets. In principle, the instruction set can contain really complicated operations, such as the addition of arbitrarily long integers in Python.
In the end, you need either an interpreter for your bytecode (expressed as a bytecode in another language) or hardware support. Just like you can run Java bytecode with a JVM, you can emulate x86 or ARM with qemu. The other way round, just like your processor can execute x86 or ARM code, a Jazelle processor can natively execute Java bytecode.
Thank you :), means a lot! As far as future support, it's hard to say really. I certainly hope development will continue but Cannoli is very much a research project in its current state. Quite a bit of work would need to be done to implement inheritance and especially exceptions (since there isn't really a direct translation into Rust). However, I think Cannoli would be well suited to function like Jython and IronPython whose goal is to integrate the Java and C# environments, respectively, into a language like Python.
Annotations are currently supported for classes. Annotating an object with it's respective class will yield performance improvements because optimizations were implemented for this case. Other type annotations were not supported due to time, but is left as future work. Third party packages are also unsupported for similar reasons.
While this is possible, I would not recommend it. It will complicate your project quite a bit. The best approach would be to use something like Jython.
If you're looking for extra speed then the first thing you should do is profile your python code and understand why it's slow. You can probably improve its performance without switching languages.
If optimising python isn't enough then you should reimplement the slowest parts in C. C is a much easier language to get python to interact with. Look into cffi and cython.
All programming paradigms are de facto "concepts", you don't see them implemented FULLY. Although at the same time they drive the ideology behind a given language. To allow or disallow side effects? To allow independent functions? Do we need polymorphism? If so then what kind?
> I think they said the languages were created by non OO
I hope that's not what they actually said and you are simplifying. Language is a set of rules and keywords, it's created on paper. You are thinking about it's implementation. It's like I told you rules to Game of Life and your job is to implement them inside a computer.
This is an important distinction because while it's true that many compilers and interpreters for languages (like C#, Java, Python) are de facto written in C (which predates popularity rise of OOP) it does not have to be the case. For instance look at Jython which is a Python code running inside Java Virtual Machine. So basically Python language implemented in Java. Wanna bet it uses OOP? :P
pi should be done like so if it's anything like python which I'm guessing it is. http://www.jython.org/docs/library/math.html#constants
import math #imports math module
math.pi #then you can use this to be able to use pi. You can do it the way below or you can do the import math before the function is defined if you plan on using it elsewhere in your code or before that function is called.
import math i = 0 k = 2 * math.pi / 40 while i < 41:
and so on. I'm new to programming though, but if you think the problem is with pi then this should help. Hopefully lol
I'm pretty sure App Engine is not considering adopting another implementation. It's already hard for them to keep both Python and Java virtual machines up-to-date and synched with the latest features... I would imagine if they choose another implementation it would be PHP given the amount of request for it. So I don't see Node.js in the foreseeable future on App Engine.
But I mean, who really cares about implementation? The JVM supports tons of runtimes and ApeJS itself is using Rhino which is extremely solid... why bother trying to use another implementation?
If it were for me I would also ditch native Python support in favor of Jython :) ... so the App Engine team can concentrate on one single implementation avoiding un-synched features across different implementations.
Sorry for repeating implementations that much :P
As far as I know there are 2 ways you can achieve this, you can call python scripts from java using Jython http://www.jython.org/index.html. Or you can run a separate backend api web-server in python using flask. If there is large amounts of computation that needs to be done I would build an API to work with but if not use Jython. Also maybe consider writing the code you want to use in python in java for convenience and simplicity of services. Good luck!
I'm not familiar with JES, but assuming that stands for "Jython Environment for Students", I found something that might guide you in the right direction: http://www.jython.org/jythonbook/en/1.0/LangSyntax.html#if-elif-else-statement
I've been learning Go on the side, and it's pretty straightforward. If you know Python well and would prefer to stick with something you know, you'll probably be fine re: the GIL (I imagine the server will spend most of its time waiting for responses to come in over the wire), in which case you might want to take a look at Twisted.
If you need true concurrency and want to stick with Python, you could try Jython, though I can't recommend it since I've never used it.
I confess I just had to go look it up to (ahem) refresh my memory, but note Jython made some documented simplifying design decisions in the area to favor ease of use for the python-side developer over performance. A lot comes down to Jython using java ConcurrentHashMap to implement dicts and dict-like things (which is a lot of things in python...).
http://www.jython.org/jythonbook/en/1.0/Concurrency.html#python-memory-model
> Reasoning about concurrency in Python is easier than in Java. This is because the memory model is not as surprising to our conventional > reasoning about how programs operate. However, this also means that Python code sacrifices significant performance to keep it simpler.
If they do want to use Grails, there's Jython (Python on the JVM), too. But I doubt there's any Java framework that's so great that it's worth going half-and-half; if they switch to Python they can find a Pythonic framework that will do everything Grails can.
>I need to find a way for python to see who is online now
If you're using Jython you can use
from org.bukkit import Bukkit arrayOfOnlinePlayers = Bukkit.getOnlinePlayers()
My knowledge of Jython is limited to what I have picked up by messing around with plugins, so I'm not entirely sure how you can use the array in Python, but that's how you can obtain it.
>who has been online frequently recently (last month or so), who has been missing for a long time but had been frequent
Similar to above, you could probably work out something with Bukkit.getOfflinePlayers()
and offlinePlayer.getLastPlayed()
.
Java is more than just a language nowadays. It's more of a platform. You have projects like jython which (for your purpose) is basically python with the ability to call upon the very rich java platform. That might be a huge advantage, but at your stage, I wouldn't worry about that.
If by cross platform you mean the major "desktop" OSes like Windows and *nix (including OSX), then python certainly is just as cross platform as java. If you want to do development for a android tablet or cell phone, then Java would be a better option.
What do you mean by light weight? Execution speed, size of installation, amount of libraries available, syntax?
If you want something that's easy to start with, and has a clear but expressive syntax, I would go with python. Java has a lot of features that makes getting started hard, but is great for larger projects and bigger teams. If you want to learn how to program and think like a programmer, I would start with python as its, imo, the ability to think in algorithms and data structures that makes you a good programmer (if I'm skilled enough to make that judgement..)