Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Dynamically compiled language vs statically compiled language [closed]

Tags:

The first line of this article by Brian Goetz made me to post this question in SO . Here 's the line again:

Writing and interpreting performance benchmarks for dynamically compiled languages, such as Java, is far more difficult than for statically compiled languages like C or C++.

I know the answer of statically typed vs dynamically typed language . But what is the difference between dynamically compiled language vs statically compiled language?

like image 743
Geek Avatar asked Sep 26 '12 11:09

Geek


People also ask

What is the difference between a dynamically and statically-typed language?

Statically typed languages: each variable and expression is already known at compile time. Dynamically typed languages: variables can receive different values at runtime and their type is defined at run time.

What is a statically compiled language?

Statically-typed language can be referred to the languages where the type of variables is known at the compile time. It has various intuitive features such as better code completion, perform type checking during the course of compilation, better tooling and refactoring, among others.

What is statically-typed and dynamically-typed languages give examples?

Statically typed languages perform type checking at compile-time, while dynamically-typed languages perform type checking at run-time. Statically-typed languages require you to declare the data types of your variables before you use them, while dynamically-typed languages do not.

What is static or dynamic programming language?

A dynamic language (Lisp, Perl, Python, Ruby) is designed to optimize programmer efficiency, so you can implement functionality with less code. A static language (C, C++, etc) is designed to optimize hardware efficiency, so that the code you write executes as quickly as possible.


1 Answers

Dynamic compiled and dynamically typed don't have much to do with each other. Typing is part of the language syntax, while the compilation strategy is part of the implementation of the language.

Dynamic typing means that you don't necessarily have to declare the type when you declare a variable and that conversion between types happens automatically in most cases.

Dynamic compiling means that the language is compiled to machine code while the program is being executed, not before. This allows, for example, just-in-time optimization - the code is optimized while the application is running. A JIT optimizer has the advantage that it has much more reliable information about which branches of the code are used most often and how they are usually used, because it can observe the application in action before applying optimizations.

Dynamic compilation is a problem for automatic benchmarking, because multiple measurements of the same program code section can compare completely different machine code interpretations because the optimizer has decided to change the implementation between two runs.

like image 176
Philipp Avatar answered Jan 18 '23 12:01

Philipp