Live data from Hacker News

Ask HN: What's a starting point for learning how to write programming languages?

news.ycombinator.com

101–105 of 105 posts

Re: Ask HN: What's a starting point for learning how to write programming languages?

#102
post #13

Chris Lattner, the creator of Swift has a nice walkthrough for making a small language called Kaleidoscope http://web.cs.ucla.edu/classes/spring08/cs259/llvm-2.2/docs/...

This is a better link: https://llvm.org/docs/tutorial/ That page is using a 10+ year old version of LLVM

I loved going through that, definitely second this.

Re: Ask HN: What's a starting point for learning how to write programming languages?

#103

Learn the mechanics of compiler construction first - that'll inform everything about your language, and is a prerequisite to actually building something other people can use. I'd recommend The Dragon Book [1], SICP [2], and Modern Compiler Implementation in ML [3] for this. After that, it's a question of where you want to go with your language, and what distinguishing features you'd like it to have relative to other…

> Languages which just change some syntax and keywords but otherwise look like C are common, but they tend not to get usage beyond their creators Considering c++ is one of the most widely-used languages out there, I would question this.

C++ has a bunch of new semantics on top of C - classes, access modifiers, virtual functions, constructors/destructors, operator overloading, different casting rules, exceptions, namespaces, templates, etc. People who know both of them well consider them very distinct languages, because the programming style you use in a C++ program is very different from a C program.

Re: Ask HN: What's a starting point for learning how to write programming languages?

#104
post #59

Put that flex & bison book away. Don't think about compilers. Design your own litte interpreted language. Write a lexer by hand (not that hard). Write a recursive descent parser by hand. It's a bit tricky to get infix operator parsing stuff right, but an important learning experience. Once you got the basic parsing algorithm right you can probably add lot's of fun stuff to your language just with general programming…

+1. This is the approach I'm currently taking. I tried starting with books and tutorials but felt I wasn't learning much just being spoon-fed code and copy+pasting. I think it's much more illuminating to attack the problem with a beginner's mindset and work it out for yourself, at least up to a point (to start I'm working on implementing a small subset of Scheme). If I occasionally get stuck I'll peek at a book just enough to get un-stuck. I'm having a blast with it and learning a ton. Once I get tired of implementing language features I'll probably start from scratch and follow a book the second time through. For me it's often easier to absorb problem-solving concepts if I've attempted the problem myself before.

Re: Ask HN: What's a starting point for learning how to write programming languages?

#105
I have ADHD that makes it nearly impossible for me to learn how to code, and thus I've never been able to perfect it. I know bits and pieces here and there, but I can tell you what usually works best for me for learning complex tasks.

-1. You need to actively set aside time each day for this task. -2. Leave time for this to last a long time, two months, minimum. -3. Plan every step out. -4. Repeat, repeat, REPEAT!! As in, repeat your training tasks. People have to repeat something seven times to burn it into permanent memory, and you need to remind yourself of it at least once a month for a year, then once every six months after this.

If you do those four things, which are surely no easy task, you should be an excellent programmer in no time. Good luck :)

Post reply on HN