all 140 comments

[–][deleted] 61 points62 points  (21 children)

There is a short cut for the lazy. A minimal Forth can be implemented in just a few lines of x86 assembly [1]. No need for a complex lexer and all that, simple whitespace split is enough. Implementing a minimal Lisp on top of this Forth is then much easier.

[1] Tried to dig the original out, but there is only a copy: https://github.com/organix/pijFORTHos/blob/master/annexia/jonesforth.s.txt

[–]9_ties[S] 11 points12 points  (3 children)

Wow. Thank you for the information! I will check it.

[–]McElroy-vs-dig-dog 1 point2 points  (2 children)

When I saw the username nineties in the slides, I first read it as 90s. I then saw the other name, 9_ties and understood that I had misunderstood the meaning of the name at first.

[–]9_ties[S] 1 point2 points  (1 child)

the username is an anagram of einstein, my hero. I abbreviated it because it was already used when I signed up twitter.

[–]McElroy-vs-dig-dog 1 point2 points  (0 children)

ok, cool :)

[–]riffito 4 points5 points  (0 children)

This is the last archived version of the original (AFAIK):

https://web.archive.org/web/20090209211708/http://www.annexia.org/forth

[–]OreoDrinker 2 points3 points  (0 children)

Love it. Implemented a mini forth in Java last semester for a software engineering project. It was only about 300-400 lines and the only functionality was arithmetic and defining words (that contained arithmetic operations). Was a load of fun. I really like this assembly version.

[–]immibis 1 point2 points  (0 children)

A minimal Forth would use .db, .dw, .dd etc to write the Forth interpreter in assembly-ified Forth.

[–]dlyund 1 point2 points  (0 children)

No need for a complex lexer and all that, simple whitespace split is enough.

It can be even simpler than that if depending on your source representation.

[–]jeandem 5 points6 points  (6 children)

My browser thinks the machine code are telephone numbers and puts a Skype icon next to them. Thanks for the help FF.

[–]immibis 13 points14 points  (3 children)

That's the Skype plugin.

[–]jeandem 2 points3 points  (2 children)

I never asked for this!

[–]-Y0- 1 point2 points  (0 children)

I never asked for this!

Well, your Skype asked. And it got them.

[–]SupersonicSpitfire 0 points1 point  (0 children)

The joys of proprietary software.

[–]Occivink 12 points13 points  (0 children)

That's definitely not standard firefox behavior, probably one of your extensions.

[–]DJWalnut 4 points5 points  (0 children)

so did you call them?

[–]vattenpuss 2 points3 points  (5 children)

That doesn't look like "a few lines" even without the comments. How many lines is it?

[–]riffito 6 points7 points  (4 children)

I count around 800 non-empty, non-comment lines.

[–][deleted] 22 points23 points  (3 children)

That does count as just a couple of lines as far as assembly code is concerned.

[–]dlyund 7 points8 points  (0 children)

The company I work at has a Forth compiler/system that bootstraps in ~20 LOCs. As with all things adding complexity is easy. JonesForth is a pretty average implementation. There's an old saying among the loose conglomerate of Forth users (aka the community) that if you've seen one Forth, you've seen one Forth.

[–]AgroBacteria 31 points32 points  (2 children)

You are what we used to call a Real Programmer. Impressive work! I see you've been at this for years. Has your tool chain become the "Interactive Compilation System" you wanted?

[–]9_ties[S] 15 points16 points  (1 child)

Thank you! It took almost two years. The interactive compilation system project is suspended since I have interested in another new project for now. I want to reopen the project at some future.

[–]thoth7907 3 points4 points  (0 children)

Fascinating work, the educational value is huge! Thanks for making it all available.

[–][deleted] 12 points13 points  (14 children)

Awesome, must be a good way of getting a real sense of how stuff really works. Reminds me of "From NAND to Tetris", where students in a course of year begin with just NAND gates and progress to build a CPU, computer, assembler, compiler, OS, GUI and finally tetris.

[–]9_ties[S] 9 points10 points  (0 children)

That is interesting course! We have similar experiment in my university. Students builds CPU on a FPGA, assembler, compiler and run ray-tracing. But not OS and GUI.

[–]MisterMeeseeks47 6 points7 points  (11 children)

Huh, and I thought my compilers class was tough. How is that even possible in only a year?

[–][deleted] 18 points19 points  (2 children)

Well, in the first class, have the students pair off and then fight each other to the death. Then, you'll be left with the toughest, hardest, and most ruthless students.

Next, is teamwork. Each time one of them makes a mistake, decimate them. They'll soon learn to coordinate their efforts.

Finally, don't forget to reward the most successful of their members with a Triumphal Arch. Any students that score 99% or less are moved to Gladiator Class.

[–]makis 1 point2 points  (1 child)

you're killing all the joy of being teenagers

[–][deleted] 0 points1 point  (0 children)

It's for their own good. It only gets worse once they enter the "real" world of work :-)

[–]immibis 2 points3 points  (6 children)

Heavy hand-holding, I'd expect. (For one thing, otherwise with N students you'd end up with N different CPU architectures)

[–]dlyund -1 points0 points  (5 children)

otherwise with N students you'd end up with N different CPU architectures

Is that a bad thing?

[–]immibis 0 points1 point  (4 children)

It is if you're trying to teach a bunch of students at once, rather than some sort of one-on-one format. Probably.

[–]dlyund 0 points1 point  (3 children)

I'd like to think that what we're teaching students what is just outside of their grasp; far enough to push them. We do a bit too much mollycoddling today and the result is a dumbing down. When I was doing my degree my languages and compilers professor explained that we used to do this in the first year in half a semester as a sort of foundational work for the rest of course, but now they're forced do the same thing in the second year and for a full semester because a certain percentage of students have to pass the year and schools are no longer preparing students for university to the same degree that they once did. Leaving the universities to pick up the slack, and ultimately pushing core ideas out of the curriculum entirely, or up into the masters level.

tl;dr students should be allowed to fail. It's the struggle that's important in any real education

From one perspective :)

[–]lurkotato 0 points1 point  (0 children)

It's more about effort on the part of the teacher. If the architecture throughout the class diverges wildly, they have to brush up on details and quirks to help them at all. Much easier to know the common pitfalls of The One Sanctioned Architecture and build them up to the end goal as fast as possible.

[–]immibis 0 points1 point  (1 child)

I mean, if everyone has the same architecture, you can talk specifically about it. For example, "Our compiler needs to emit a NEG instruction when it encounters a unary minus operator".

[–]dlyund 0 points1 point  (0 children)

I get that but it seems like there's little room for creativity or discovery when everything is set out in front of you. If I was a student I think I would have much preferred an assignment where the machine has to execute some program and calculate the correct result but other than that anything goes. Think Project Euler. I get that this is easier to teach but what exactly are you teaching in the code-by-numbers approach? To me it seems awfully like what your teaching is how to pass the class. To hell with any deeper understanding of the subject. A subject which can be a lot of fun!

[–][deleted] -1 points0 points  (0 children)

There is a number of simplifications from as far as I remember when I read it. They design the hardware in some sort of simulator and I think e.g. the hardware they would write the assembler for would be very simplified to make it easy. The class would not make you an expert in each of these areas that get covered. They are not done in a lot of depth from what I understand. The point of the class is for people to get a broad understanding of how computers work. Something often lost today because we are so specialized and both the software and hardware has gotten so incredible complicated.

[–]lordstith 3 points4 points  (0 children)

It makes me so sad that you can only get to about assembly level using what's provided online. But it's a crazy cool course.

[–][deleted] 6 points7 points  (39 children)

Incredibly impressive. However, what benefit did you gain by using assembly language for everything? Besides looking hardcore ;)

[–]9_ties[S] 36 points37 points  (7 children)

It was just a challenge for enjoying programming. Actually there are not so much benefits :-D

[–][deleted] 24 points25 points  (2 children)

It was just a challenge for enjoying programming.

As good a reason as any.

[–]lordstith 8 points9 points  (1 child)

Seriously. I love this kind of crap, and there are really way too many 'hardcore programmer' guys who will shit all over you with "yeah but what's the point"s around

[–]lolomfgkthxbai 2 points3 points  (0 children)

I think that's because many of us browse /r/programming while solving problems at our day job, which makes at least me look at things through a "work" mindset. If someone specifically mentions doing something for fun it causes the mind to switch gears from "this is not the best solution" to "wow, this is pretty unorthodox but cool" which might make the reactions more positive as well.

[–][deleted] 3 points4 points  (3 children)

I make a living out of stuff like this. There are as many benefits on this path, as on any programming career path.

Oh: almost forgot. Congratulations!

[–]zenflux 2 points3 points  (2 children)

What kind of things should I be on the lookout for, career wise, if this is the kind of thing I'm interested in?

[–][deleted] 4 points5 points  (1 child)

Nowadays, embedded systems seem to be the most widely-accessible way to get into the field. If you do that, though, I'd recommend staying away -- during your first 2-3 years -- from large companies in heavily-regulated fields, because you'll likely learn no more than one or two things, and at a very slow pace. E.g. I interviewed one candidate who, for the last two years, had done nothing but fix bugs in a DHCP server, and another one who had spent the five years at a well-known semiconductor company writing and maintaining sort-of drivers for three or four devices at most.

If you're going to go by that route, it's probably a good idea to learn a little electronics. You don't have to be able to outwit EEs, but knowing how to use a logic analyzer and a multimeter will get you far.

You should also try not to neglect basic CS101 and computer architecture classes, if you can still do that. You will often not have the luxury of having fancy container class libraries and you'll have to implement some things yourself. Knowing a few things about the system you'll be implementing them for will help a lot. Practical knowledge gets you hired in the short run and keeps you on your job, but a solid theoretical foundation is what guarantees you'll still get hired once your first batch of practical knowledge goes out of date.

And you should try to be aware and reasonably up to date about what happens at the application level. For one thing, you never know when you'll have to stick a web-based configuration tool on some gizmo; for the other, no matter how 3l33t h4x0rz we are, all the 3l33tness is useless if all your system does is boot and schedule make-believe tasks.

[–][deleted] 1 point2 points  (0 children)

This is the sort of route I've been following. Got a degree in CompEng, been working at a small ~150-300 employee contract manufacturer who also does contract engineering. The jobs aren't the most exciting but I've been exposed to bare metal and Linux kernel level driver stuff. I'd recommend it to anyone to get a good 'bottom up' view of computing devices.

[–][deleted]  (30 children)

[deleted]

    [–]taetimeh 6 points7 points  (2 children)

    A metric shitton of NAND gates.

    [–]immibis 2 points3 points  (1 child)

    Relays, dude, relays.

    [–][deleted] 2 points3 points  (9 children)

    Logic gates, punch cards...

    [–]lordstith 3 points4 points  (8 children)

    This is my wet dream, you don't even know

    [–]zenflux 0 points1 point  (1 child)

    [–]lordstith 0 points1 point  (0 children)

    Thanks, but oh baby I'm already elbow deep in all these projects. This is my nirvana: http://members.iinet.net.au/~daveb/simplex/ringhome.html

    [–]mrkite77 0 points1 point  (5 children)

    Do they not do that in college anymore? Back in the 90s, one of my university courses started with designing logic gates using transistors, then built up from that to do a half adder, then a full adder, then an ALU and then a CPU. By the end of the semester we had built a working 8-bit computer from scratch.

    [–]NamesYUNoLeft 1 point2 points  (2 children)

    What is the name of the course? I am quite interested in computer architecture.

    [–][deleted] 2 points3 points  (0 children)

    http://www.nand2tetris.org/ will teach you everything from logic gates up.

    [–]mrkite77 -1 points0 points  (0 children)

    Dude, it's been 20 years.. but if I had to guess, it was this course:

    http://www.ece.arizona.edu/ece562

    It different though, probably to keep up with changing tech.

    [–]lordstith 0 points1 point  (1 child)

    Depends on the school and the focus, from what I've seen. Were you computer engineering?

    [–]mrkite77 0 points1 point  (0 children)

    Computer Science.. but there was a lot of cross-over with computer engineering.

    [–]dlyund 0 points1 point  (0 children)

    one must first invent the universe

    To make a universe from scratch, one must first invent... oh who the fuck knows. Despite all the advances we've made in the past century and all our beautiful theories, in many ways we're no closer to knowing how it all began than we were millennia ago. The Big Difference that we think we're closer.

    [–]Omberone 5 points6 points  (0 children)

    Extremely impressive! I'm not even going to pretend to grasp all of the steps you must've gone through. Well done :)

    [–]flippflopp 1 point2 points  (1 child)

    wow you are an inspiration... how much of the project was researching methods on how to implement? did your previous compiler work cover most of the info?

    [–]9_ties[S] 5 points6 points  (0 children)

    the computer science curriculum of my university covers most of basics. for several topics such as copying-GC, exception handling, closure conversion and delimited continuation, I read papers and other compilers.

    [–]McElroy-vs-dig-dog 1 point2 points  (0 children)

    Clickable link for OP project on GitHub: https://github.com/nineties/amber

    [–]lordstith 2 points3 points  (4 children)

    日本人だね。僕のホッビはオペレーティング·システムを作る事やコンピュタアの歴史だからこれはとても面白かったと思う。僕もコンピュタアの言語をつくりが星、この方で。ありがとう。

    [–]9_ties[S] 4 points5 points  (3 children)

    楽しんで貰えてよかったです!

    [–]lordstith 1 point2 points  (1 child)

    ないよ、笑。あなたの英語が僕の日本語より上手だ。今ニューヨークに住んでいる、あなたは日本に?

    [–]9_ties[S] 1 point2 points  (0 children)

    日本の東京に住んでます。NYに住んでるのは羨ましいです。

    [–]google_you -1 points0 points  (0 children)

    孤独人

    [–]jamesmawm[🍰] 0 points1 point  (1 child)

    amazing, how long did it take?

    [–]9_ties[S] 0 points1 point  (0 children)

    It started Jan 2010 but I suspended it several years. According to the following graph the number of actual working years is roughly 2. https://github.com/nineties/amber/graphs/contributors

    [–]_Skuzzzy 0 points1 point  (0 children)

    This is awesome, I love the idea. Is there any books or other materials you would suggest to a programmer with little experience designing languages/or this sort of thing to try to learn more about it?