• 几种语言的比较(WIP)


    各种feature的实现
    1. 执行shell
    2. 处理时间
    3. 处理参数
    4. 处理文件
    5. logging
    6. test
    7. 多线程、进程,并发 
    语言
    1. python
    2. groovy
    3. scala
    4. java
    5. C++
    6. C
    7. shell
    8. go

    执行shell, check output

    1. groovy
      1. a= "ls".execute(); println a.text
    2. scala
      1. import sys.process._; “ls”.!!
    3. Java
    4. python
      1. import subprocess; a = subprocess.check_output("ls /tmp", shell=True); print(a)
    5. C++

    处理时间

    1. java/scaca 
    2. python

    处理参数

    1. python
      1. argparse
    2. scala
      1. scallop
      2. scopt 
      3. Argparse4j
    3. java
      1. Argparse4J
      2. JewlCli    

    文件

    1. scala:
      1. import java.io._ ; val writer = new PrintWriter(new File("test.txt)); writer.write("hello world"); writer.close)
      2. import scala.io.Surce; Source.fromFile("test.txt").foreach{println}

    logging

    1. python (RotateFile and Console)
      1. handler_Console = logging.StreamHandler()
        handler_Console.setFormatter(formatter)
        handler_Console.setLevel(logging.DEBUG)

        base_dir = os.path.dirname(os.path.abspath(__file__))
        log_path = os.path.join(base_dir, log_file_name)
        handler_F = RotatingFileHandler(log_path, maxBytes=200*1024, backupCount=5)
        handler_F.setFormatter(formatter)
        handler_F.setLevel(logging.INFO)

        logger = logging.getLogger(logger_name)
        logger.addHandler(handler_Console)
        logger.addHandler(handler_F)
        logger.setLevel(logging.DEBUG)

    2. scala or java
      1. SLF4J, Log4j, Log4j2 (使用SLF4J and Logback,  log4j vs logback vs log4j2)
      2. import org.apache.log4j.Logger;
        import org.apache.log4j.PropertyConfigurator;

        static Logger logger = Logger.getLogger(this.getClass)
        PropertyConfigurator.configure("log4j.properties");
      3. log4j.properites

        # Root logger
        log4j.rootLogger=INFO, console, file

        log4j.appender.console=org.apache.log4j.ConsoleAppender
        log4j.appender.console.Target=System.out
        log4j.appender.console.layout=org.apache.log4j.PatternLayout
        log4j.appender.consoleAppender.layout.ConversionPattern=[%t] %-5p %c %x - %m%n


        # Direct log messages to a log file
        log4j.appender.file=org.apache.log4j.RollingFileAppender

        log4j.appender.file.File=C:\tempinfo.log
        log4j.appender.file.MaxFileSize=10MB
        log4j.appender.file.MaxBackupIndex=10
        log4j.appender.file.layout=org.apache.log4j.PatternLayout
        log4j.appender.file.layout.ConversionPattern=[%t] %-5p %c %x - %m%n

  • 相关阅读:
    vue中使用第三方UI库的移动端rem适配方案
    前端规范--eslint standard
    从上往下打印二叉树
    栈的压入,弹出序列
    随机森林
    LR
    顺时针打印矩阵
    包含min函数的栈
    树的子结构
    合并两个有序链表
  • 原文地址:https://www.cnblogs.com/bob-dong/p/14241276.html
Copyright © 2020-2023  润新知