🦥JIT Compliation

Hello friends!

Welcome to this week’s Sloth Bytes. I hope you had an amazing week!

You don't remember that meeting. Nobody does.

I bet right now you couldn't tell me what your last meeting or lecture was about even if your life depended on it.

Don't worry, I can't either. I have the memory of a goldfish.

That's why I started using Granola.

It picks up your meetings automatically and transcribes everything in the background while you take notes like normal. No bot joining your call, no “recording in progress” sound, nobody knows it's there.

After the meeting, it takes your messy notes and the full transcript and turns it into a clear summary of the meeting and what you actually need to do next.

You can even share that summary with your team because I bet they forgot too.

Now nobody has to pretend they remember.

JIT(Just-In-Time) Compliation

For the longest time, I had no clue what JIT actually was. I just knew that it was used to make things faster and was an optimization, but no idea how.

I also didn’t really understand the difference between it and normal compilation.

Turns out, they’re a really good and super popular.

You're Already Using JIT (You Just Don't Know It)

Your browser: Chrome's V8, Firefox's SpiderMonkey, Safari's JavaScriptCore, they all use a JIT complier to make JavaScript fast enough that you can use Google Docs without your laptop melting.

Java applications: The JVM's HotSpot compiler uses JIT to optimize it while it runs. Fun fact:Java apps have that a "warm-up" period where they get faster over time. That’s because of JIT compilation.

C# and .NET: The CLR runtime uses JIT to compile your C# code right before it runs.

Your phone: Android's ART runtime uses JIT to make apps run smoothly without destroying your battery.

JIT compilation is everywhere.

Okay, But What Actually Is JIT?

JIT (Just-In-Time) compilation is when your code gets compiled into machine code while your program is running, not before.

Think of it like packing for a trip:

Option A (Traditional Compilation): Pack everything you might need before you leave. Even the things you'll never use. Compile everything upfront.

Option B (JIT Compilation): Pack light, buy stuff as you need it. Forgot sunscreen? Grab it at the local store. Compile code only when you actually need it.

Option B is way more flexible. You're not wasting time on stuff you don't need, and you can adapt on the fly.

JIT vs. Regular Compilation: What's The Difference?

Traditional Compilers (like GCC for C++)

  • Compile everything before your program runs

  • Take their time optimizing (no users waiting)

  • Produce a binary file you run later

  • No runtime overhead, but also no runtime information

JIT Compilers

  • Compile code while your program runs

  • Have to be fast (program is literally running)

  • Can use runtime info to make smarter optimizations

  • Some overhead, but way more adaptive

Why Not Always Use JIT Compilers?

So why do we still use traditional compilation? Why isn't everything JIT-compiled?

Good question.

1. Predictability Matters - JIT-compiled code have a "warm-up period" where performance is unpredictable.

For some applications, that's a dealbreaker.

Imagine you're writing code for:

  • A medical device that needs to respond in exactly 10ms

  • A Mars rover that can't afford performance surprises

  • A stock trading system where 5ms of warm-up could cost millions

A “warm-up period” would cause massive damage.

2. More Resource - JIT compilers need:

  • RAM for the compiler itself, plus both original code and compiled machine code

  • CPU cycles to profile and compile while your app is running

  • Battery on mobile devices

Embedded systems, IoT devices, and resource-constrained environments can't always afford this overhead.

This is why languages like C, C++, and Rust dominate embedded systems, compile once, run forever with minimal overhead.

3. Security and Control JIT compilers generate code at runtime, which some security models really don't like.

iOS actually restricts JIT compilation in apps (except Safari) because dynamically generated code is a security risk to them. Which ruined game emulators since they rely on JIT.

Systems programming, operating systems, and security-critical applications need to know exactly what code will run. No dynamic optimization, no runtime surprises.

4. Cold Start Problems Serverless functions (AWS Lambda, Cloud Functions) have a brutal problem: they start cold, run for 100ms, then shut down, so there’s enough time to “warm-up” the program.

5. Simpler Deployment Traditional compilation gives you a single binary file. Copy it. Run it. Done.

JIT-compiled languages need:

  • The runtime environment (JVM, Node.js, .NET CLR)

  • All the dependencies

  • Consistent behavior across different runtime versions

So when should you use JIT?

  • Long-running applications

  • Complex applications

  • Development and testing

Here’s some resource if you want to dive deeper (nerd)

V8 and JavaScript JIT:

Java and HotSpot:

JIT vs AOT (traditional) Compilation:

Thanks to everyone who submitted!

Find the Missing Number

Create a function that takes an array of numbers between 1 and 10 (excluding one number) and returns the missing number.

Examples

missingNum([1, 2, 3, 4, 6, 7, 8, 9, 10])
output = 5

missingNum([7, 2, 3, 6, 5, 9, 1, 4, 8])
output 10

missingNum([10, 5, 1, 2, 4, 6, 8, 3, 9])
output = 7

Notes

  • The array of numbers will be unsorted (not in order).

  • Only one number will be missing.

How To Submit Answers

Reply with

  • A link to your solution (github, twitter, personal blog, portfolio, replit, etc)

  • or if you’re on the web version leave a comment!

  • If you want to be mentioned here, I’d prefer if you sent a GitHub link or Replit!

That’s all from me!

Have a great week, be safe, make good choices, and have fun coding.

If I made a mistake or you have any questions, feel free to comment below or reply to the email!

See you all next week.

What'd you think of today's email?

Login or Subscribe to participate in polls.

Want to advertise in Sloth Bytes?

If your company is interested in reaching an audience of developers and programming enthusiasts, you may want to advertise with us here.

Reply

or to participate.