Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7705457
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T23:52:11+00:00 2026-05-31T23:52:11+00:00

This is more about Node.JS, which uses the V8 engine. This is the JavaScript

  • 0

This is more about Node.JS, which uses the V8 engine. This is the JavaScript engine that is also used for Google Chrome.

I hear about V8 being really fast, not just for Node, but for browsers too. However, one thing I notice about JavaScript, is that types are not coded for variables.

To accomplish this in Java, you would need an Object variable type for everything. This would be significantly less efficient in, for example, a for loop:

for (var i = 0; i < array.length; i++) {}

My question is, how does V8 handle variable types? Does it know that this i variable is always either an int or long? (I see this as unlikely beause, i++ has the ability to convert a long to a double.)

Or does V8 handle things in such a way that it does not matter? I think some simple examples of what the JIT compiler would create would be useful. Both Java and JavaScript do have JIT compilers to convert code to C.

I am not a C programmer, but I am curious to know how types are handled, and if Java is really more efficient in that area. (yes, I know that I/O is going to be much more significant for most programs than type handling)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T23:52:12+00:00Added an answer on May 31, 2026 at 11:52 pm

    In a word: Yes.

    V8 compiles the code into an intermediary bytecode, then the “hotspots” are analyzed by the “Crankshaft” compiler, and if it determines that certain variables will never be anything other than an integer, a double, a string, or so on, it generates machine code with it “unboxed.”

    It only performs this optimization on branches that have already been traversed; others are deferred until information about the actual types involved are calculated by the “regular” engine, and then injected into the optimized code.

    On top of this, V8 can translate essentially-static prototype hierarchies into “classic” C++-style object inheritance for performance improvements on “complex” types.

    It can only do all of this, however, on code that is called “often”; like loops or frequently called functions.

    The linked to article (part of a series), explains this in much, much more detail, and is definitely worth reading.

    EDIT: But, of course, a statically-typed language like Java will optimize as much of the code as possible at compile time, so it should outperform Javascript in all but toy benchmarks. However, V8 is closing the gap between the two, and Javascript is a lot more “fun” to write than Java or C++, so initial prototyping or development of programs where the user is the largest source of latency means Javascript is often the better choice, in my opinion.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

EDIT: This question is more about language engineering than C++ itself. I used C++
This isn't really a programming question but more about programming and testing tools. Is
I'm asking more about what this means to my code. I understand the concepts
This is kind of more generic question, isn't language-specific. More about idea and algorithm
I got this in an interview question -- the question was more about what
So I'm trying to learn more about lambda expressions. I read this question on
More than about LINQ to [insert your favorite provider here], this question is about
A discussion about Singletons in PHP has me thinking about this issue more and
I'm not talking about making portable code. This is more a question of distribution.
I know there is already a question about this but my issue is more

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.