A Data Science Central Community

One usually asked question is: with which programming language to start when someone just begins studying computer science? Then a lot of suggestions will come up.

1 1. You should start with one static typed language say C/C++, java etc. and then move easily to dynamic typed language like Perl, Python etc. Because it is harder to move from dynamic typed language to static typed language.

But then an argument comes up: static typed language is much harder than dynamic one, and less productive. Moreover, the way to write code in dynamic typed language is very different from that of static one. Once you get used to the static typed language, you may not feel comfortable with the dynamic one. So:

2 2. You should start with dynamic typed language.

But there are also arguments that disagree. Then why not:

3 3. We start with both.

This note is a try to study both from the beginning. But this is not a text book, I am not going to write down all the details here, for those who need the details, you could just find enough on Google. I will just do a comparative study on Java and Python.

As a practical study note, we don’t need” Hello World”. We go straight forward to the point.

The first thing to do when writing code would always be declaring the variables you will use in your program (Let’s assume that we already have designed the algorithm). The way you declare a variable in Java is like this:

[type name] [variable name] = [value];

Int example_Variable = 0;

Assigning a value to the variable is not necessary. You can just declare the variable and initialize it when needed. And in Python, the statement is like this:

[variable name] = [value]

example_Variable = 0

You may notice the difference between them. In Java you have to declare the type explicitly. If not you cannot compile you program. Also, the value assigned to the variable must be of the right type, and you can’t change the data type of the variable.

But in Python, the data type is determined by the value assigned. In the example above, the type of the variable is int. If you write the code like this:

A=0

A= “ hello”

Then A is first an integer of value 0, then becomes a string of value “hello”. In Python you can change the data type whenever you want. This is so called dynamic typed. In Java, when you declare the data type for a variable, then it is fixed there. This is so called static typed.

One easily-made mistake when coding in dynamic typed language is:

a=10

b=20

a/b

You want to do a true division and obtain a result 0.5. But by this code you will get a result of 0, a round integer of the true result. Because by assigning 10 to a, a is declare to be an integer(b also), thus the result is of course an integer. You have to assign 10.0 to a( 20.0 to b) so as to obtain a floating point number result. In Java you don’t need to worry about this, because you will always be very clear of the data type. After all, the naming convention and carefully assigning value would be helpful. http://en.wikipedia.org/wiki/Naming_convention_(programming) This link gives you a brief introduction to naming convention.

The second difference is that in Java you need a semicolon ; to indicate that the statement is finish. But in Python you don’t need any delimiter to indicate a finish.

Up till now, we see only disadvantages of Python, and now here comes the advantage. In both Java and Python, there are some built-in fundamental data types:

In Java : boolean, char, byte, short, int, long, float, double;

In Python: Boolean, int, long, float, complex.

The data types are more or less the same between two languages, except one thing: there is a complex data type in Python, and Java no. So mathematicians and those who work with complex number would be very happy using Python. And if you want to use complex number in Java, you have to write your own class for this, including the mathematical operation functions.

Here’s the link for an example of the complex number Java class code:

© 2019 AnalyticBridge.com is a subsidiary and dedicated channel of Data Science Central LLC Powered by

Badges | Report an Issue | Privacy Policy | Terms of Service

**Most Popular Content on DSC**

To not miss this type of content in the future, subscribe to our newsletter.

- Book: Statistics -- New Foundations, Toolbox, and Machine Learning Recipes
- Book: Classification and Regression In a Weekend - With Python
- Book: Applied Stochastic Processes
- Long-range Correlations in Time Series: Modeling, Testing, Case Study
- How to Automatically Determine the Number of Clusters in your Data
- New Machine Learning Cheat Sheet | Old one
- Confidence Intervals Without Pain - With Resampling
- Advanced Machine Learning with Basic Excel
- New Perspectives on Statistical Distributions and Deep Learning
- Fascinating New Results in the Theory of Randomness
- Fast Combinatorial Feature Selection

**Other popular resources**

- Comprehensive Repository of Data Science and ML Resources
- Statistical Concepts Explained in Simple English
- Machine Learning Concepts Explained in One Picture
- 100 Data Science Interview Questions and Answers
- Cheat Sheets | Curated Articles | Search | Jobs | Courses
- Post a Blog | Forum Questions | Books | Salaries | News

**Archives:** 2008-2014 |
2015-2016 |
2017-2019 |
Book 1 |
Book 2 |
More

**Most popular articles**

- Free Book and Resources for DSC Members
- New Perspectives on Statistical Distributions and Deep Learning
- Time series, Growth Modeling and Data Science Wizardy
- Statistical Concepts Explained in Simple English
- Machine Learning Concepts Explained in One Picture
- Comprehensive Repository of Data Science and ML Resources
- Advanced Machine Learning with Basic Excel
- Difference between ML, Data Science, AI, Deep Learning, and Statistics
- Selected Business Analytics, Data Science and ML articles
- How to Automatically Determine the Number of Clusters in your Data
- Fascinating New Results in the Theory of Randomness
- Hire a Data Scientist | Search DSC | Find a Job
- Post a Blog | Forum Questions

## You need to be a member of AnalyticBridge to add comments!

Join AnalyticBridge