Questions tagged [language-implementation]

Having to do with issues arising when implementing a programming language.

141 questions
284
votes
4 answers

PyPy -- How can it possibly beat CPython?

From the Google Open Source Blog: PyPy is a reimplementation of Python in Python, using advanced techniques to try to attain better performance than CPython. Many years of hard work have finally paid off. Our speed results often beat…
Agnel Kurian
  • 57,975
  • 43
  • 146
  • 217
105
votes
7 answers

Why are all fields in an interface implicitly static and final?

I am just trying to understand why all fields defined in an Interface are implicitly static and final. The idea of keeping fields static makes sense to me as you can't have objects of an interface but why they are final (implicitly)? Any one knows…
peakit
  • 28,597
  • 27
  • 63
  • 80
92
votes
4 answers

How is the C++ exception handling runtime implemented?

I am intrigued by how the C++ exception handling mechanism works. Specifically, where is the exception object stored and how does it propagate through several scopes until it is caught? Is it stored in some global area? Since this could be compiler…
pjay
  • 2,422
  • 4
  • 21
  • 20
72
votes
3 answers

Why does Python have a limit on the number of static blocks that can be nested?

The number of statically nested blocks in Python is limited to 20. That is, nesting 19 for loops will be fine (although excessively time consuming; O(n^19) is insane), but nesting 20 will fail with: SyntaxError: too many statically nested…
Right leg
  • 16,080
  • 7
  • 48
  • 81
69
votes
2 answers

Why is __FILE__ uppercase and __dir__ lowercase?

In Ruby 2.0.0-p0, the __dir__ variable was introduced for easy access to the directory of the file currently being executed. Why is __dir__ lowercase when __FILE__ is uppercase?
conradkleinespel
  • 6,560
  • 10
  • 51
  • 87
48
votes
9 answers

Are there any Common Lisp implementations for .Net?

Are there any Common Lisp implementations for .Net?
TraumaPony
  • 10,742
  • 12
  • 54
  • 74
45
votes
3 answers

What is the connection between laziness and purity?

Laziness is what kept Haskell pure. If it had been strict, purity would soon go out the window. I fail to see the connection between the evaluation strategy of a language and its purity. Considering the reputation of the tweet's author I am most…
43
votes
1 answer

How are java interfaces implemented internally? (vtables?)

C++ has multiple inheritance. The implementation of multiple inheritance at the assembly level can be quite complicated, but there are good descriptions online on how this is normally done (vtables, pointer fixups, thunks, etc). Java doesn't have…
JanKanis
  • 6,346
  • 5
  • 38
  • 42
38
votes
8 answers

Why is the main method entry point in most C# programs static?

Why is the main method entry point in most C# programs static?
Tony The Lion
  • 61,704
  • 67
  • 242
  • 415
25
votes
6 answers

what exactly is a "register machine"?

From http://code.google.com/p/unladen-swallow/wiki/ProjectPlan I quote: "Using a JIT will also allow us to move Python from a stack-based machine to a register machine, which has been shown to improve performance in other similar languages…
24
votes
4 answers

Why must Python list addition be homogenous?

Can anyone familiar with Python's internals (CPython, or other implementations) explain why list addition is required to be homogenous: In [1]: x = [1] In [2]:…
Marcin
  • 48,559
  • 18
  • 128
  • 201
24
votes
7 answers

How is C++'s multiple inheritance implemented?

Single inheritance is easy to implement. For example, in C, the inheritance can be simulated as: struct Base { int a; } struct Descendant { Base parent; int b; } But with multiple inheritance, the compiler has to arrange multiple parents inside…
23
votes
2 answers

How is foreach implemented in C#?

How exactly is foreach implemented in C#? I imagine a part of it looking like: var enumerator = TInput.GetEnumerator(); while(enumerator.MoveNext()) { // do some stuff here } However I'm unsure what's really going on. What methodology is used for…
Jamie Dixon
  • 53,019
  • 19
  • 125
  • 162
21
votes
6 answers

How does a Haskell compiler work?

Where can I get some paper/doc/whatever which describes how a Haskell compiler actually works? I read quite a few of the docs of GHC, but stopped after getting a headache. So, something which doesn't require a PhD to understand it and isn't written…
fuz
  • 88,405
  • 25
  • 200
  • 352
21
votes
4 answers

How could one implement C++ virtual functions in C

The C++ language provides virtual functions. Within the constraints of a pure C language implementation, how can a similar effect be achieved?
user319824
1
2 3
9 10