I was asked at the interview and couldn't answer, so I had a pain, so I'll organize it for myself.
My experience period is as follows (as of July 2020)
language | Period of use | Use applications |
---|---|---|
Python | 2018.5 ~ 2020.3 | (1)Data analysis including web scraping and machine learning on Jupyter Notebook(2)AWS Lambda executable script and AWS Batch executable file in MLOps |
Java | 2018.8 ~ 2019.5 | Standalone application development with Java |
Ruby | 2019.11 ~ | Web application development with Rails |
--Java was the one who learned the basics of object-oriented programming and system development, and Ruby on Rails was the one who actually made the web application. --Python's Django did just a tutorial --Since PYthon was used mainly for data analysis, compare Java and Ruby, which have experience in system development.
Java --An image that is quite often used in data processing systems such as kafka and Hadoop. --Compiled language speeds up processing --Bytecode compiled language --In other words, when compiled with the javac command, it is ** bytecode (intermediate code) ** instead of machine language. --The software is distributed in this state and works anywhere the JVM is included. --Just InTime compilation (just-in-time compilation) of this bytecode on the JVM is executed on the CPU while making it into machine code. ――JIT compilation is to compile the code of a certain unit such as modules, classes, and functions that make up the software when it is executed. ――I often hear that you can multithread. [Multi-threaded introduction to design patterns](https://www.amazon.co.jp/%E5%A2%97%E8%A3%9C%E6%94%B9%E8%A8%82%E7%89 % 88-Java% E8% A8% 80% E8% AA% 9E% E3% 81% A7% E5% AD% A6% E3% 81% B6% E3% 83% 87% E3% 82% B6% E3% 82 % A4% E3% 83% B3% E3% 83% 91% E3% 82% BF% E3% 83% BC% E3% 83% B3% E5% 85% A5% E9% 96% 80-% E3% 83% 9E% E3% 83% AB% E3% 83% 81% E3% 82% B9% E3% 83% AC% E3% 83% 83% E3% 83% 89% E7% B7% A8-% E7% B5% 90 % E5% 9F% 8E-% E6% B5% A9 / dp / 4797331623) It's out.
Ruby
--I've never seen it used for anything other than a web framework (Rails).
--Processing speed is slow in an interpreted language (apparently)
――It's easy to write. The following are the factors.
--The method () is optional. I feel uncomfortable personally ...
--Alias is often attached to the method of the class. (Example)
--Introduction of blocks.
――Isn't this introduced to make it easier to read? I feel. It seems that there is no problem in passing a lambda function instead of a block in the method argument.
-Introducing blocks, and then blocks{|x|...}
As welldo |x| ... end
By allowing the writing style, each/map/Ease of writing when combined with functional programming such as filter/The readability has been greatly improved.(When I first saw the following, I was really wondering how this kind of writing would be an acceptable language specification.)
[1, 2, 3].map do |each_num|
each_num + 1
end
--Constants can be rewritten
--Constants are variables named with capital letters, such as Var.
--You can reassign to a constant and execute a destructive method of a constant (although a warning is issued).
--The freeze method can prevent destructive methods
--You can do metaprogramming (black magic).
――It's easy for people to write code, but people who read code don't like it so much because it's quite difficult to track.
--This is achieved by the following method.
--ʻEval "@ # {key} = value" can interpret a String object as code --You can add methods dynamically in the class with
define_method str {...} --Dynamic method invocation is possible with
send (: method_name, arguments)`
--I haven't seen much multithreaded programming.
Java vs Ruby
--Implement Java interface <=> MixIn Ruby module --The Java interface does not implement the method content --The contents of the module used for MixIn of Ruby are implemented. -It is possible to call the instance variable / method of the include source class from the instance method of the module --It is expected that you will need to know the caller at the time of writing the module. I don't think it's very good.
--Error handling is required for each method in Java <=> Not required in Ruby --In Java, it is necessary to handle exceptions (or explicitly throw exceptions) for each method. --RuntimeException and IllegalArgumentException do not need to be --In Ruby, if an unhandled error occurs in a method, the current method is terminated at that point and the error is inherited by the caller. --By the way, with `Rails, when I learned that there is a specification that an HTTP response with a 404 error is returned if ActiveRecord :: RecordNotFound that occurred in the active record is not explicitly handled by the controller action, it really is. I was impressed that it was well made. --By the way, in Golang, the error object is returned as a return value.
--Primitive type exists in Java <=> In Ruby, all values are objects
--In Java, boolean, byte, char, short, int, float long, double
are primitive types.
--There is a wrapper class for these. For example, if you want to include int as a list element, use the wrapper type java.lang.Integer instead of List <int>
to make it List <Integer>
.
--The advantage of using primitive type is [here](http://itstudy365.com/blog/java-%E3%83%97%E3%83%AA%E3%83%9F%E3%83%86%E3% 82% A3% E3% 83% 96% E5% 9E% 8B% E3% 81% AE% E3% 83% A1% E3% 83% AA% E3% 83% 83% E3% 83% 88% E3% 81% Detailed in A3% E3% 81% A6 /). I did not know...
--In Ruby, integer is also a class, so you can create a method from a numerical value like 3.each {...}
.
――This also seems to contribute to the reputation that Ruby is fun to write.
――It is complicated and stressing that the meanings of equals and == are opposite.
--In Java, == is identity
and .equals () is equivalence
.
--Use .equals () to compare the keys of
hash. (Confirmed at here)
--If you override equals (), you also need to override hashCode ().
--It is not allowed that ʻA.equals (B) is false but ʻA and B have different hashCode ()
.
--It is permissible for ʻA and B hashCode () to be the same even though ʻA.equals (B) is false
. However, in this case, collision occurs in the hash implemented by the chain method.
--In Ruby, == is equivalence
, ʻequal? () Is identity --Use eql?
To compare the keys ofhash. This is the union of ʻequal ()? + Are the classes of the two objects being compared the same?
.
--If you override eql? (), you also need to override hash ().
--It is not allowed that ʻA.eql? (B) is false but the hash () of ʻA and B is different
.
--It is permissible that the hash () of ʻA and B is the same even though ʻA.eql? (B) is false
. However, in this case, collision occurs in the hash implemented by the chain method.
Recommended Posts