Live data from Hacker News

Show HN: Going into freshman year, figured I should build an interpreter

news.ycombinator.com

1–10 of 84 posts

Show HN: Going into freshman year, figured I should build an interpreter

#1
Hi all!

I'm going into my freshman year, and figured that the best way to prepare for the intro to programming Racket course would be to implement my own garbage-collected, dynamically typed, functional programming language in C ;)

Anyways... here's the repo: https://github.com/liam-ilan/crumb

I started learning C over the summer, so I still have a whole lot to learn... Any feedback would be greatly appreciated! :D

Re: Show HN: Going into freshman year, figured I should build an interpreter

#4

Did you wrote your own garbage colector? Is it a moving one or a not moving one?

Crumb is garbage collected (there is no need to manually allocated/deallocate memory)... though there is no background "garbage collector" process running... The interpreter for Crumb is a tree-walk interpreter, and it just frees memory whenever it can... Crumb frees memory in the following cases:

1) When a function is finished, all memory related to the scope of that runtime is freed.

2) When an value is not returned out of a statement, or assigned to a variable, said value is freed.

3) When a function is applied, if an argument has no reference (it is not stored in a variable), it is freed.

4) Additionally, if the function itself has no reference (such as in the case of an immediately invoked function), it is freed.

Hope that clarifies things a bit :D

Re: Show HN: Going into freshman year, figured I should build an interpreter

#5
post #4

Did you wrote your own garbage colector? Is it a moving one or a not moving one?

Crumb is garbage collected (there is no need to manually allocated/deallocate memory)... though there is no background "garbage collector" process running... The interpreter for Crumb is a tree-walk interpreter, and it just frees memory whenever it can... Crumb frees memory in the following cases: 1) When a function is finished, all memory related to the scope of that runtime is freed. 2) When an value is not returne…

Sorry if I got the syntax wrong, but in something like

  f = {
     x = (list 1 2 3)
     y = (list x x)
     z = (get x 1)
     
How does the compiler decides if it must free the memory used by x?

Re: Show HN: Going into freshman year, figured I should build an interpreter

#8
post #4

Did you wrote your own garbage colector? Is it a moving one or a not moving one?

Crumb is garbage collected (there is no need to manually allocated/deallocate memory)... though there is no background "garbage collector" process running... The interpreter for Crumb is a tree-walk interpreter, and it just frees memory whenever it can... Crumb frees memory in the following cases: 1) When a function is finished, all memory related to the scope of that runtime is freed. 2) When an value is not returne…

[deleted]

Re: Show HN: Going into freshman year, figured I should build an interpreter

#9
post #4

Earlier quoted context omitted.

Crumb is garbage collected (there is no need to manually allocated/deallocate memory)... though there is no background "garbage collector" process running... The interpreter for Crumb is a tree-walk interpreter, and it just frees memory whenever it can... Crumb frees memory in the following cases: 1) When a function is finished, all memory related to the scope of that runtime is freed. 2) When an value is not returne…

Sorry if I got the syntax wrong, but in something like f = { x = (list 1 2 3) y = (list x x) z = (get x 1) How does the compiler decides if it must free the memory used by x?

All lists are passed by value and X isn't the return value, would be my guess
Post reply on HN