What kind of things can you use Java instead of Python?

I will choose a new programming language, Java, and have been using Python for some time But it seems that most things that can be done in Java can be done in Python So I want to know

>What can java do instead of Python?

>Mobile programming (Android). > POSIX thread programming

>Instead, what can Python do, but not Java?

Clarification: I hope to look at the answer from a practical point of view, but it is not a theoretical point of view, but about the current situation, not the future So in theory, all programming languages can perform any task. In fact, each language has some limitations

resolvent

Solution

I guess with Jython, you can do anything you can do in java with Python

In contrast, python has a pypy compiler, which is very cool – virtual machines with multiple backups (Java runtime, llvm,. Net and python IIRC), multiple garbage collectors, multiple implementations (stackless), etc I know Java has a great choice for virtual machines, but the growth of pypy is amazing because it is written in rpython - a very productive language

In addition, Java can do this. In one file, there are less than 20 lines, and there is no library import? Obviously, both languages have libraries that can do this, but I'm just talking about language flexibility

class Logger(object): # boilerplate code
    def log(self,level,msg,*args,**kwargs): # *args,**kwargs = flexible arguments
        self._log(level,**kwargs) # call with flexible argments

    def _log(self,**kwargs):
        # override me at runtime :) 
        # I think Java people call this Dependency Runtime Injection
        if level>1:
            print msg,args,kwargs

logger = Logger() # boilerplate code

def logged(level): # what pattern do you call this?
    def logged_decorator(function): # and this? 
        def func(*args,**kwars): 
            name = func.__name__ # look ma,reflective Metaprogramming!
            logger.log(level,name,**kwargs)
            return func(*args,**kwargs)
        return func # boilerplate code
    return logged_decorator # boilerplate code

Use example

@logged
def my_func(arg1,arg2):
   # your code here
   pass

The above is the collection of programming house for you. What kind of things can you use Java instead of Python? I hope this article can help you solve what kind of things you can use Java instead of Python? Program development problems encountered.

If you think the content of the programming home website is good, you are welcome to recommend the programming home website to programmers and friends.

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>