[HN Gopher] Show HN: Going into freshman year, figured I should ...
___________________________________________________________________
Show HN: Going into freshman year, figured I should build an
interpreter
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
Author : liamilan
Score : 63 points
Date : 2023-08-26 17:28 UTC (1 days ago)
| withtheprogram wrote:
| clickable link to repo: https://github.com/liam-ilan/crumb
| xrd wrote:
| Man, your blog (https://www.liamilan.com/) is wonderful. I wish
| you had an RSS feed, hint, hint.
| 38 wrote:
| this is great that you're getting into programming, but please,
| do yourself a favor and move away from C.
|
| its 2023. C still has its place, but unless you really need the
| benefits of C (extreme performance at the cost of safety), then
| several better options these days. I think C should be something
| you move to AFTER you've exhausted the performance envelope of
| another language, not before.
| Snarwin wrote:
| I'd say C is actually a pretty good choice for an educational
| project like this. Having to write out all of your data
| structures by hand and manage your memory manually is a good
| learning experience, and since you're not writing serious
| production code, you don't have to worry too much about making
| mistakes.
| convolvatron wrote:
| _someone_ has to learn to build runtimes
| flippinburgers wrote:
| This kid has plenty of time to dive into other languages. C is
| a great choice.
| slashdev wrote:
| C is like a high level assembly language. It maps very closely
| to how the computer actually runs programs. That, and it's
| simplicity, make it a great way to learn.
|
| It's not usually a great idea for production code anymore, but
| for learning it's fantastic.
| the_biot wrote:
| That old chestnut. C is nothing remotely like an assembly
| language, of any kind. It is a low-level programming
| language, but only compared to most languages. Disassemble
| some compiled C code sometime -- it's another world entirely.
| slashdev wrote:
| I've programmed in both assembly and C, among other things.
| I stand by it, C is much closer to the machine than most
| languages.
| ta-sfghjkk wrote:
| [flagged]
| gus_massa wrote:
| Did you wrote your own garbage colector? Is it a moving one or a
| not moving one?
| liamilan wrote:
| 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
| [deleted]
| gus_massa wrote:
| 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) <- y }
|
| How does the compiler decides if it must free the memory used
| by x?
| s_Hogg wrote:
| All lists are passed by value and X isn't the return value,
| would be my guess
| zerojames wrote:
| I love this! Amazing work!
| liamilan wrote:
| Thanks!
| delta_p_delta_x wrote:
| Nicely done.
|
| You're a freshman, picked up C over the summer, and have already
| built an interpreter for a language that you haven't officially
| been taught yet, and have a blog with a couple dozen posts.
|
| I'll be honest, people with achievements like yours make me feel
| pretty worthless.
| brailsafe wrote:
| [delayed]
| mindvirus wrote:
| Love it! I learned so much from building projects like this! None
| of mine had cool logos like yours - this looks really pro.
|
| Have you tried teaching Crumb to GPT4? I bet it could surprise
| you with what it can do.
| s_Hogg wrote:
| Congratulations, this is great. Have you thought about spending
| some time writing down what you had to learn and how you went
| about figuring out what to learn in order to do this? I think
| it'd be even more interesting than the language itself.
| liamilan wrote:
| Yeah actually, stay tuned! :D
___________________________________________________________________
(page generated 2023-08-27 23:01 UTC)