TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

I told my 2nd year CS students to create a programming language

129 点作者 dovyski大约 13 年前

17 条评论

dandrews大约 13 年前
I did something like this once many years ago for one of my wife's students, a precocious high-schooler who needed to be challenged beyond the elementary Fortran she was teaching at the vocational school. So I outlined the steps it would take to translate a toy language into a toy computer's instruction set, and reviewed it with the young man one afternoon at my office - an abbreviated compiler theory class with an eager audience of one. Tom took the big flowchart that we made home, studying and meticulously documenting it. When he brought me the documented design a couple of days later I asked him to implement it.<p>Tom spent awhile doing this in Waterloo Fortran, and when he presented me with the working compiler I said "Good job. Now execute the code." He blinked his surprise - until then I don't think he'd considered that the toy machine could have been interpreted. A revelation! He went back home and wrote the VM for the toy machine without any assistance; it worked well and I was as proud of him as I could be.<p>A couple of years later I hired Tom and a couple of years after that he lapped me, going on to better things. 30 years later I still keep a copy of his compiler and interpreter, reminding me from time to time of the bright kid who grew up to become a fine programmer and family man.
评论 #3839733 未加载
评论 #3841503 未加载
semisight大约 13 年前
I wish I had a professor like you. When I asked why there was no compiler class, the answer I was given was: "compilers are a solved problem; there's no point in teaching them anymore."<p>Maybe it's just my school though.
评论 #3839879 未加载
评论 #3839685 未加载
评论 #3839388 未加载
评论 #3839498 未加载
评论 #3840205 未加载
评论 #3839386 未加载
评论 #3839409 未加载
评论 #3839575 未加载
aik大约 13 年前
This is great. More professors need to be like you.<p>With the exception of barely 2 projects in uni, all my homework/projects were short and small scale, meaning I already knew how to complete 90% of it, and just had to learn the content from the latest lecture to complete the rest.<p>With this assignment I probably would have known ~40%, meaning I wold have to buckle down and actually get invested - figure out what I know and don't know, and self study to the answer. Because I wouldn't just be able to rely on my teacher and lecture notes, I would actually have to take (some) control of my learning to succeed (rather than expect the teacher and textbook to hand feed me everyone I need to know). Because I'm not hand fed everything, I would actually become motivated because my success (or failure) for once would be somewhat in my own hands. What a concept!!! Congrats.
评论 #3839913 未加载
beambot大约 13 年前
Go check out Peter Norvig's "Write a lisp interpreter in Python": <a href="http://norvig.com/lispy.html" rel="nofollow">http://norvig.com/lispy.html</a><p>It's a very slick implementation. BTW, we had a similar requirement for our "Programming Languages" undergraduate course: to implement our own language with a BNF grammar, parser, etc (done in ML). It was one of the best learning experiences we had!
评论 #3839638 未加载
blahedo大约 13 年前
It's a neat idea, but I really want to hear an experience report on the <i>results</i>. I don't want to throw cold water on this, because I want it to work and I think it might, but I have a fair amount of experience here[0] and can think of a number of reasons why it might go poorly as well. All we see in the OP is, "here's an idea that's cool (and it is) and I'm optimistic that it will work."<p>[0]I have taught courses where intro-level students write Scheme interpreters (in Scheme, in Java) and courses where students implement interpreters for higher-level languages, and courses (well, one so far) where they implement an actual compiler (for a subset of C).
评论 #3841525 未加载
vessenes大约 13 年前
Cool!<p>It's interesting that you want them to make a procedural language, although if they started with C, it makes some sense.<p>I wonder if you could broaden the experiment slightly by relaxing your constraints and saying they either need to allow reassignment of variables, or else support lambdas, and in exchange they can assume immutability.
评论 #3839408 未加载
评论 #3839440 未加载
stcredzero大约 13 年前
So, from what I understand, they have the flexibility to choose their own syntax. If they're interested in doing the least amount of work possible, they could either implement a Lisp-like language or Forth. (Smalltalk is pretty teeny as well. A basic Smalltalk-y language would weigh in at 1/6th the size of Python's grammar.)
评论 #3839628 未加载
kaens大约 13 年前
Will you be able to show off the results? I'd be really pretty interested to see what some 2nd year comp-sci students come up with.<p>The pipe dream part of me wants you to have them stick their results on github and work with each other, or start getting taught stuff by ... well, everyone.<p>My high-school comp-sci teacher is a large part of the reason why I can reason clearly about code, and he would push us in directions like this -- not as extreme, but similar in the "ok, here's an end goal that you can achieve by thinking about it and making combinations of what you know" sense.<p>I know a <i>lot</i> of programmers who don't grok compilers, even at a high level, and it's a shame -- a lot of things are a lot easier, and you open the doors to doing a lot more if you do.
评论 #3841546 未加载
evincarofautumn大约 13 年前
Couldn’t commend you more highly for this—not least because it’s exactly what I would do if I were a CS professor. ;)<p>Interpreters, compilers, and games are the things that have taught me the most about programming and computing in general. Implementing programming languages pushes high-level CS concepts as well as firsthand understanding of how languages work. Games are a fun practical application of those concepts—embedded scripting languages in particular—plus trig, vectors, matrices, rendering, optics, audio, DSP, physics, you name it. And languages and games both provide plenty of opportunities to learn about optimisation.<p>I hardly know why CS is taught any other way.
评论 #3839555 未加载
Tyr42大约 13 年前
Our advanced CS class (first year) has written a scheme interpreter. We were going to port it to C, from racket, but we ran out of time in the class. I might just finish it for fun this summer.
micheljansen大约 13 年前
Cool! I had a (mandatory) course on compiler construction in my second year of CS as well. It was one of the toughest subjects, but it also made me understand and appreciate programming languages so much better. Like everyone, we tried to create a language without the annoyances found in many modern languages. Like everyone, we found that those annoyances are actually really hard to avoid. It was tons of fun :)
评论 #3841575 未加载
dkrich大约 13 年前
Not sure what's unusual about this except for the fact that it was assigned to 2nd years. I had to create a compiler from scratch during my course work, and I'm sure many other CS programs require the same.<p>It is a great way to learn how a compiler works, but then again, in this day and age it seems less and less relevant to know that stuff, especially if you are going into a typical programming position.
weiran大约 13 年前
We did this for our Compilers module during my second year CS degree at Nottingham university. It's a very interesting subject and I thought it gave a very good grounding in understanding new languages. Unfortunately we had to write our compiler in Java, we had the option of using Haskell but I didn't really learn get to grips with functional programming until the third year.
tylerhowarth大约 13 年前
I am in a principles of programming languages class currently, and we are doing very similar work. We are writing interpreters, type checkers, and more for a new language our teacher has defined. We are doing all of this in Scala.
评论 #3839611 未加载
kingkilr大约 13 年前
I gave a talk yesterday on implementing a VM in 30 minutes. I'm not sure how well it went (it's a lot of material for 30 minutes), but I hope I at least got some people excited about implementing languages.
评论 #3841591 未加载
iz_mani大约 13 年前
I think this is a pretty good approach. You don't learn till you get your hands dirty. I hope kids do well.
voodoochilo大约 13 年前
the dragonbook is never more than an armlength away from my screen. love the idea.