Live data from Hacker News

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

news.ycombinator.com

51–60 of 84 posts

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

#51

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.

Ya, but would you rather spend the summer enjoying summer or writing C

This is them enjoying the summer. Aspie supremacy.

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

#52
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?

It's an interpreter rather than a compiler, and looking at the code it seems to use ref counting

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

#53

My main advice: never trust C, C++, or their compilers. Undefined behavior bites. Even if you just care about the latest 64-bit Ubuntu Linux LTS, compiler updates or flag changes bite as well. That's the main difference between C and C++ and almost any other language. Not the syntax, neither the perceived "low-levelness", nor manual memory management. In any other language, if you make a mistake, the program behaves…

I suppose this is one of those things where people’s experiences vary widely, but FWIW after 20 years of writing C/C++, I can count the number of times this has bitten me on one finger. And even then, I still think it was more likely just an optimizer bug in the god-awful compiler.

Yes, I think it heavily depends on what you're doing and your mindset.

E.g. if you work with a single compiler on a single platform all the time and expect the compiler to "just compile the code", then you're likely to learn all its quirks, avoid them automatically, use proper abstractions/contracts/invariants to guard against incorrect code, etc. Moreover, you likely know how exactly the most popular UB shows itself with your compiler.

If you juggle compilers all the time and work with not-so-high-quality code (legacy or not), especially the one with little tests, I expect UB to pop up a lot. Or even if you just test on one platform and do final runs on another, that happens all the time in competitive programming or home assignment grading, especially with beginners.

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

#54
post #11

[flagged]

This is bad advice. > several better options these days Every other option requires you to buy into some additional paradigm-of-the-day. You can easily lose decades going down the wrong programming rabbit holes.

No. Paradigms are few (OO/logic/functional/procedural/a few more) and learning those is essential and very transferrable.

> You can easily lose decades going down the wrong programming rabbit holes

total rubbish.

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

#55

Earlier quoted context omitted.

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.

I think Lisp won that battle. The core syntax was named after actual cpu registers (cdr/car).

Seriously? :)

Is lambda calculus or the PDP instructions set a closer match to which language?

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

#56

Here's perhaps some unexpected and unsolicited advice... so pretty clearly you aren't going to have a hard time with the CS curriculum (assuming that's what you intend to study) so my $0.02 is - find a second or even third major to augment your skill set. If you are already able to get to this level on your own, you'll likely breeze right through a typical undergrad CS course of study. So consider other courses of st…

i did this and regret it (38 now and have a technical CS startup), i studied electrical/computer engineering but what i should have done was gone to a better CS school or get approved for accelerated course work. the main problem for 18 yo me was lack of visibility into what a good CS program looked like, as opposed to just knowing more than the CS teachers at an eng school not ranked for CS. also, take as much math as you can.

you should be studying: lisp ocaml haskell, interpreters (SICP), compilers, type systems, transaction processing, effect systems, FRP, concurrency NOT java guis python SQL databases webdev gamedev .. whatever

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

#57

Here's perhaps some unexpected and unsolicited advice... so pretty clearly you aren't going to have a hard time with the CS curriculum (assuming that's what you intend to study) so my $0.02 is - find a second or even third major to augment your skill set. If you are already able to get to this level on your own, you'll likely breeze right through a typical undergrad CS course of study. So consider other courses of st…

I don't know the specific curriculum but I would caution that being a competent programmer does not directly translate into academic success. Yes, the author will have a massive head start but but that does not necessarily mean they will find studying easy.

At least that was my experience as a self-thought programmer. The first weeks were super boring for me but also lulled me into being complacent until I suddenly found myself in deep trouble. Just because you understand the practical side does not mean you can will automatically grok the academic side of things.

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

#59

Here's perhaps some unexpected and unsolicited advice... so pretty clearly you aren't going to have a hard time with the CS curriculum (assuming that's what you intend to study) so my $0.02 is - find a second or even third major to augment your skill set. If you are already able to get to this level on your own, you'll likely breeze right through a typical undergrad CS course of study. So consider other courses of st…

I'd suggest the opposite. I originally double majored in the arts before switching to tech. For me, the classes in all cases were less useful than self-study with projects, more expensive, and oftentimes outdated. The degree opened the door to more jobs, but the classes themselves weren't worth the expense in my opinion. Your mileage may vary by university, of course.

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

#60

Here's perhaps some unexpected and unsolicited advice... so pretty clearly you aren't going to have a hard time with the CS curriculum (assuming that's what you intend to study) so my $0.02 is - find a second or even third major to augment your skill set. If you are already able to get to this level on your own, you'll likely breeze right through a typical undergrad CS course of study. So consider other courses of st…

I don't know the specific curriculum but I would caution that being a competent programmer does not directly translate into academic success. Yes, the author will have a massive head start but but that does not necessarily mean they will find studying easy. At least that was my experience as a self-thought programmer. The first weeks were super boring for me but also lulled me into being complacent until I suddenly f…

Fully agree on that. In my first year I started discussing with the professor during a lecture that for sure java strings are not immutable because you are still able to access the memory behind it and proving it to him, while completely missing the point of the concept of an immutable object and that he was fully aware of that.
Post reply on HN