Are there differences between interpreted code and managed code?

chrstrbrts

Senior member
Aug 12, 2014
522
3
81
My question is quite simple I suppose.

Are there differences between interpreted code and managed code?

Interpreted code is definitely managed, right?

I mean interpreted code has to run over some sort of software layer, an interpreter, a virtual machine, etc.

Are there any examples of managed code that come from a compiler?

Java code is compiled to java bytecode, but then run over an interpreter/virtual machine.
 

DaveSimmons

Elite Member
Aug 12, 2001
40,730
670
126
Managed code is Microsoft's term for code that runs in the .NET CLR framework instead of as a native Win32 EXE.

C++ .NET, C#, etc. are still compiled (to CLR) instead of interpreted like a shell script.
 

chrstrbrts

Senior member
Aug 12, 2014
522
3
81
Managed code is Microsoft's term for code that runs in the .NET CLR framework instead of as a native Win32 EXE.

C++ .NET, C#, etc. are still compiled (to CLR) instead of interpreted like a shell script.

So, managed code is a term specific to Microsoft?

I thought it was a general term for any situation where code ran on top of some kind of non-OS software layer that provided memory management services.

Am I wrong?
 

urvile

Golden Member
Aug 3, 2017
1,575
474
96
So, calling Java code 'managed' would be wrong?

CLR doesn't garbage collect or memory manage?

Nah let's say Java is managed it's garbage collected and uses type safe references instead of pointers. C# is similar unless you are using platform invoke. Which allows the programmer to call unmanaged code but then the coder has to manage the memory. Because you are calling C/C++ APIs typically.

Um just in time compilation as well.....does that help?
 

DaveSimmons

Elite Member
Aug 12, 2001
40,730
670
126
It's just a name MS came up with to distinguish .NET apps from "native" / "unmanaged" Win32 apps.
 

urvile

Golden Member
Aug 3, 2017
1,575
474
96
It's just a name MS came up with to distinguish .NET apps from "native" / "unmanaged" Win32 apps.

Yes it is but it's because it involves memory management etc. but yeah it is an MS thing. You could call Java garbage collected but it all works in the same way. The thing with C# apps is you can still get memory leaks because managed objects can hold pointers to unmanaged memory or via platform invoke. However the language does provide various methods to manage that but it still has to be done manually. Because unmanaged is not on the heap and not garbage collected.

I have seen some wicked memory leaks in C# apps one in particular that was caused by a stream not being disposed correctly. Anyway maybe the OP will actually learn something.
 

DaveSimmons

Elite Member
Aug 12, 2001
40,730
670
126
Sure, I wasn't disagreeing with you just pointing out it's a marketing term as much as a technical one. .NET itself has no meaning, it's just meant to make you think of the internet.
 

urvile

Golden Member
Aug 3, 2017
1,575
474
96
Yep. That's MS for you. Still their technologies do pay my bills. :) I think the OP was getting his terminologies a little mixed up.
 

Merad

Platinum Member
May 31, 2010
2,586
19
81
I think this is one of those areas where terminology is a little fuzzy. In my mind an interpreted language is one where you can directly run the source code without any sort of compilation step (shell script, Perl, Python, etc.). Then you have compiled languages that output bytecode and require a "runtime" (bytecode interpreter) to execute (Java, C#). Finally there are the languages that compile directly to native machine code and execute directly (C, C++).

However the lines can be pretty blurry. Python can be compiled to bytecode. Java and C# are both always compiled to bytecode (AFAIK), but both of their runtimes tend to precompile chunks of your code into machine code (JIT compilation) and execute it directly rather than using the bytecode interpreter...
 

mxnerd

Diamond Member
Jul 6, 2007
6,799
1,103
126
Interpreted code means the code is not compiled. It's also not managed.

Ex. Javascript, Python, early BASIC.

Interpreted code must be reinterpreted every time you re-run the code, so it's slower.

Managed code is compiled, but only to a pseudo code (similar to assembly, but it's not), not native assembly (machine code). Once compiled, the pseudo code will be run.
 
Last edited: