Java has the JVM, what does C have?

I know that C has a compiler but what determines execution performance?

For example in an if else block, what if the code just had all ifs instead of if elses, what determines that all the ifs will be ran? In Java it would be the JVM, but in C what is the execution compiler thing?

4

In Java the virtual machine executes your code, but C compilers generate code that the real machine executes. To be precise, in both cases your program ends up being converted into real machine code, but in the case of Java there’s a middle step of compiling to JVM bytecode.

So Java programs are converted to real instructions by the JVM when you load them, whereas C programs are already converted to real instructions by the compiler before they’re run.

1

Apart from machine code, there is no programming language in existence which executes directly on hardware, in the sense that you can’t feed it the literal source text. All real implementations must translate the source program into the language of the “machine”.

For some implementations, it’s translated statically. We usually call these implementations “compiled”. For others, it’s translated into some intermediate form, which is then translated dynamically as the program is run. We usually call these implementations “interpreted”. There is a continuum of possibilities between these, and even many modern CPUs do dynamic translation as part of its execution core.

Even when your program is statically compiled long before execution, unless you’re writing firmware, it’s rare that the compiled code runs directly on the bare metal with nothing supporting it. The operating system provides a virtual machine for user-space programs, often providing such features as the illusion that you have a CPU all to yourself. The illusion of a flat memory space which could be larger than the physical RAM attached to the machine is even called “virtual memory”.

On top of that, even when you’re programming in C, there is a C virtual machine! It is traditionally referred to as “the C runtime”, or CRT for short.

Because C is mostly translated directly into assembly/machine code well ahead of time (on some platforms, there may also be some threaded code, and that can be considered part of the virtual machine), the virtual machine usually only has to handle startup and shutdown.

Startup typically involves setting up the stack and heap; the operating system rarely provides these for you, and it’s the job of the programming language to provide these to the programmer. On some platforms there may be some initialisation of signal handling, setting up the “main” thread in a multi-threaded environment, running global constructors on the off chance that the program has been linked to C++ code, handling dynamically linked libraries, or there may be some processing required to set up argc/argv and envp. Finally, CRT transfers control to main.

As for shutdown, many operating systems can kill a process uncleanly, so shutdown doesn’t need to do very much. The main thing is to process atexit() calls for the case where the program does exit cleanly.

3

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật