Stories
Slash Boxes
Comments

SoylentNews is people

posted by cmn32480 on Friday January 15 2016, @10:17AM   Printer-friendly
from the start-from-the-beginning dept.

Came across this old tutorial, which may be of interest to Soylentils for recreational learning:

This fifteen-part series, written from 1988 to 1995, is a non-technical introduction to compiler construction. You can read the parts on-line or download them in a ZIP file.

The plain text download is here or the PDF here. Enjoy.


Original Submission

This discussion has been archived. No new comments can be posted.
Display Options Threshold/Breakthrough Mark All as Read Mark All as Unread
The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
  • (Score: 1, Insightful) by Anonymous Coward on Friday January 15 2016, @11:12AM

    by Anonymous Coward on Friday January 15 2016, @11:12AM (#289831)

    All learning is recreational. Employers don't give a shit about your learning ability. You don't go to school to learn. You go to school to be trained to suck cock, and then you suck cock to get a job. Learning does not occur.

    And if you even mention your skills with 1970s-era languages like Pascal in a job interview, you will not get the job.

    Learning?! Enjoy being poor.

    • (Score: 2, Interesting) by YeaWhatevs on Friday January 15 2016, @11:40AM

      by YeaWhatevs (5623) on Friday January 15 2016, @11:40AM (#289839)

      This is true, but not the whe story. Employers see training time, especially independent study, as wasted time. Having seen training and convention time abused by a memorable few, I now feel the same way. One could argue that bad policies are made by exception. On the other hand, they end up paying more for the few who continue to learn on their own.

      • (Score: 3, Insightful) by bob_super on Friday January 15 2016, @04:50PM

        by bob_super (1357) on Friday January 15 2016, @04:50PM (#289940)

        > Employers see training time, especially independent study, as wasted time.

        It's a good thing that I'm seeing my boss's boss next week, so I can give him a hug.
        Seriously, every team meeting, he spend at least ten minutes reminding us how we should use every opportunity to train, learn and become experts in any topic that can become relevant to the team.
        The bastard actually means it, too.

    • (Score: 2, Insightful) by Anonymous Coward on Friday January 15 2016, @02:43PM

      by Anonymous Coward on Friday January 15 2016, @02:43PM (#289887)

      Learning does not occur.

      I dont know where you went to school. I know I learned a hell of a lot of things. Including how to type and write, oddly enough.

      School is what you take out of it. You are forced to go. So either you make the best of it or you get shit out of it. Sounds like you wanted to get doubles on your shit plate?

      like Pascal
      Gee maybe because no one uses it? It would be like rocking into a Perl shop with nothing but 25 years of C and expect to get the job. Would I put it on a resume? No, because no one cares about it anymore other than a sneaky way with the variant called Delphi. It would be like asking someone who has only ever worked on Fords to switch out the transmission on a BMW. He has the basics but it will take him awhile because of a bunch of subtle differences.

      I am currently doing small online studies of reverse engineering. It is fascinating to me also it help me with my other very important skill debugging. One I am not afraid to say is quite good. The downside is most reverse engineering type sites are massively shady. As many of them grew out of the warez/virus scenes.

      • (Score: 0) by Anonymous Coward on Friday January 15 2016, @03:09PM

        by Anonymous Coward on Friday January 15 2016, @03:09PM (#289896)

        I dont know where you went to school.

        I've found that people who say they received a good education usually did not receive anything that could be called a good education. It's mostly just that they are confused as to what a good education even is.

        School is what you take out of it

        No, it isn't. If you have terrible teachers and the school rarely or never encourages anything other than rote memorization, it's a simple fact that it's less probable that students will get a good education. If certain information is not being taught, or understanding is not encouraged, then you have to take your education into your own hands. But at that point, it's not the school that you must thank for your education, but yourself and whoever else is helping you. Sadly, most people will not try to seek out an education themselves, so what they will end up with is a terrible education and, most likely, a hatred of learning.

        You are forced to go.

        Not always.

        Gee maybe because no one uses it?

        That doesn't sound like a very education-friendly attitude. It's nice to have curiosity and experience in things that others do not.

        • (Score: 0) by Anonymous Coward on Friday January 15 2016, @04:55PM

          by Anonymous Coward on Friday January 15 2016, @04:55PM (#289944)

          So you are disagreeing with me by agreeing? Wah?

    • (Score: 2) by DeathMonkey on Friday January 15 2016, @06:34PM

      by DeathMonkey (1380) on Friday January 15 2016, @06:34PM (#289983) Journal

      Employers don't give a shit about your learning ability.
       
      Then why did they hire me to implement a software platform I had never even used before?

    • (Score: 0) by Anonymous Coward on Friday January 15 2016, @06:40PM

      by Anonymous Coward on Friday January 15 2016, @06:40PM (#289985)

      You talk like a fag and your shit's all retarded.

    • (Score: 0) by Anonymous Coward on Sunday January 17 2016, @04:27AM

      by Anonymous Coward on Sunday January 17 2016, @04:27AM (#290537)

      You are either a troll or you have absolutely no idea what you are talking about.

  • (Score: 4, Informative) by ThePhilips on Friday January 15 2016, @11:16AM

    by ThePhilips (5677) on Friday January 15 2016, @11:16AM (#289832)

    Why go old and fun, if you can go new and fun? LLVM's Kaleidoscope tutorial [llvm.org] is quite easy and simple way to start off in the design of compilers.

    Otherwise, talking about "good old stuff", in many ways, I grew up on the classical Wirth books, like e.g. Compiler Construction [ethoberon.ethz.ch]. Or earlier ones, like Algorithms + Data Structures = Programs [wikipedia.org] which was my gateway to the p-codes [wikipedia.org].

    • (Score: 1, Interesting) by Anonymous Coward on Friday January 15 2016, @02:57PM

      by Anonymous Coward on Friday January 15 2016, @02:57PM (#289891)

      I used this book when I was learning it. http://www.amazon.com/Compilers-Principles-Techniques-Tools-2nd/dp/0321486811 [amazon.com]

      Honestly I did not like it much. I did have a seriously awesome teacher Dr. David A. Klarner. http://www.amazon.com/Mathematical-Recreations-Collection-Martin-Gardner/dp/0486400891 [amazon.com] http://www.amazon.com/Mathematical-Gardner-David-Klarner/dp/1468466887 [amazon.com] He would always come into class and make whatever he was working on relate to the class. Most of the time it was geometrical stuff but he made it relate pretty much every time.

    • (Score: 0) by Anonymous Coward on Friday January 15 2016, @03:41PM

      by Anonymous Coward on Friday January 15 2016, @03:41PM (#289910)

      Skimming that LLVM page, isn't LLVM a compiler itself?

      • (Score: 3, Interesting) by ThePhilips on Friday January 15 2016, @04:35PM

        by ThePhilips (5677) on Friday January 15 2016, @04:35PM (#289931)

        No. LLVM/Clang is a set of libraries with facilities to help implement compilers, code-generators, linkers, interpreters, JIT, optimizers and so on. They also happen to have libraries for C/C++/etc parsing, preprocessing and converting into the bytecode (for interpreter or JIT) or actual platform-specific object code.

        Oh, and they also have several demos, most famous out of them is called "clang". The "clang++" demo is also popular.

        Just kidding. But not by much: clang as an application is fairly thin front-end to the underlaying LLVM/Clang libraries. In the actual demos (at least in the past) there was a ~50 line C++ application which took on command-line a ".c" file, compiled it in memory and run it in memory via interpreter. The Kaleidoscope is actually a demo of how to write an interpreted language with JIT support using the LLVM libraries. It's pretty awesome.

        • (Score: 0) by Anonymous Coward on Friday January 15 2016, @08:58PM

          by Anonymous Coward on Friday January 15 2016, @08:58PM (#290023)

          Thanks.

  • (Score: 2, Insightful) by YeaWhatevs on Friday January 15 2016, @11:59AM

    by YeaWhatevs (5623) on Friday January 15 2016, @11:59AM (#289842)

    First off, I applaud Jack for learning compilers. Having personally worked with one memorable physicist turned programmer though, I can't help but cringe (I know I'm overgeneralizing, but this is how opinions are formed). From what I've seen, physicists make horrible programmers, and like all horrible programmers, by definition, they churn out crap code until it fails under it's own weight. If you are stuck with them, the best you can do is patiently allow the bugs to pile up in their code until they fire themselves, and then nuke the site from orbit. If they are good, they'll get their act together. And whatever you do, do not play the hero and fix the problems with their code, this only serves to give the situation lifeline.

    • (Score: 1, Insightful) by Anonymous Coward on Friday January 15 2016, @02:42PM

      by Anonymous Coward on Friday January 15 2016, @02:42PM (#289886)

      Physicists who only learned programming for the sake of being able to get computers do their physics calculations tend to be bad programmers. Physicists who learned programming due to a genuine interest in that topic are more likely to create good code.

      But that's not specific to physicists. I'm pretty sure the tons of crappy code haunting the web, full of trivial security exploits, are not all written by physicists.

    • (Score: 1, Informative) by Anonymous Coward on Friday January 15 2016, @04:50PM

      by Anonymous Coward on Friday January 15 2016, @04:50PM (#289941)

      OTOH, I've worked with physicists who were among the best programmers I've known. I've also worked with too many computer science grads who were completely useless.

      Maybe your "one memorable physicist" was just someone who would have been bad at any job they undertook. This happens. So does useless generalization.

    • (Score: 2) by stormreaver on Friday January 15 2016, @05:08PM

      by stormreaver (5101) on Friday January 15 2016, @05:08PM (#289948)

      First off, I applaud Jack for learning compilers...From what I've seen, physicists make horrible programmers....

      Apparently, you don't know Jack. (sorry, couldn't resist).

    • (Score: 0) by Anonymous Coward on Friday January 15 2016, @06:10PM

      by Anonymous Coward on Friday January 15 2016, @06:10PM (#289975)

      Electrical Engineers can write really mediocre code, too. I say this as someone who graduated with a BSEE but immediately got a job doing the usual sort of IT programming.
      The problem is that EEs don't receive any training in how to organize complex code using simple and clear abstractions and programming just to that API without dipping into the lower levels to break the abstraction. EEs are trained to deal in very low level details and sometimes have problems raising their level of abstraction, indeed, many pride themselves in their "efficiency" of saving a byte here and there in return for an unmaintainable system that in the end doesn't run measurably faster. EEs that do business programming have to change and get better as programmers, but those that do embedded software (programming small devices with limited memory and CPU and a very narrow function that are typically developed, sold, and then not upgraded, or only very infrequently) don't experience the pressure to raise the bar of their programming. Those embedded EEs are good at what they do, but their coding style tends to be "stunted".

      • (Score: 0) by Anonymous Coward on Friday January 15 2016, @09:58PM

        by Anonymous Coward on Friday January 15 2016, @09:58PM (#290036)

        Traditionally, software was a thin flexible layer on top of hardware. Extrapolate from that and you have all the answers.

        BTW, there is no such thing as "software" without hardware, and EE build the hardware.

        • (Score: 0) by Anonymous Coward on Monday January 18 2016, @06:16AM

          by Anonymous Coward on Monday January 18 2016, @06:16AM (#291015)

          The software does more and more work every year even in embedded systems and has become the highest value part. The brains and sophistication lie in the software, as does the majority of the development effort. In contrast, the CPU or board level architecture is usually a bog standard generic design that is used unchanged (or minimally changed) across many projects.

  • (Score: 1, Informative) by Anonymous Coward on Friday January 15 2016, @12:18PM

    by Anonymous Coward on Friday January 15 2016, @12:18PM (#289846)

    Never read that tutorial, but I imagine it discusses writing grammars and feeding them to older generation parser/lexer generators. One of more modern and easier-to-use parser generators is ANTLR, and Terrence Parr (its creator) has written a pretty good book on using it to generate compilers. ANTLR is written in Java and generates lexer/parser written in Java, but learning its basics should facilitate using other compiler generators a good deal also.

    • (Score: 3, Interesting) by ThePhilips on Friday January 15 2016, @12:38PM

      by ThePhilips (5677) on Friday January 15 2016, @12:38PM (#289853)

      Never read that tutorial, but I imagine it discusses writing grammars and feeding them to older generation parser/lexer generators.

      Why RTFA - or even quickly glimpse through the PDF - when it is faster to make the false assumptions?

      No, it doesn't use yacc/bison or lex/flex or their analogs. In fact, the book has anti-yacc/lex rants in the beginning.

      One of more modern and easier-to-use parser generators is ANTLR [...]

      Not relevant. For once, the parser generators are boring (translate automaton into fsm; we've seen and did that gazillion times before). Second, parsing is only first - and tiny in comparison - step toward writing a compiler.

      • (Score: 0) by Anonymous Coward on Friday January 15 2016, @01:16PM

        by Anonymous Coward on Friday January 15 2016, @01:16PM (#289864)

        Second, parsing is only first - and tiny in comparison - step toward writing a compiler.

        Tell that to people writing C++ compilers.

    • (Score: 0) by Anonymous Coward on Friday January 15 2016, @04:05PM

      by Anonymous Coward on Friday January 15 2016, @04:05PM (#289921)

      ANTLR is popular and has a gui, but it is no better than any ambiguous grammar parser. I think the dreaded reduce/reduce conflict has driven some to ANTLR, but ambiguous is ambiguous, a different parser won't fix it, and ANTLR doesn't have any advanced facilities for detecting and cleaning up ambiguous grammers. Lack of good ambiguous cleanup, handling unicode, error correction in token set selection and reasonable size executable output is why I wrote my own.

  • (Score: 3, Interesting) by wonkey_monkey on Friday January 15 2016, @12:53PM

    by wonkey_monkey (279) on Friday January 15 2016, @12:53PM (#289857) Homepage

    This fifteen-part series, written from 1988 to 1995, is a non-technical introduction...

    I'm not sure I'd call it non-technical. There's plenty of code in there.

    Anyway, a lot of this feels quite familiar from a compiler I recently wrote for video pixel manipulation). It parses RPN expressions (with lots of extensions) and turns them into x87 machine code. I'd previously written an RPN calculator in C++, with the input string being "compiled" to a bytecode, but after that it was a bunch of switch/case statements to do the calculation every time. The fully compiled version obviously runs a lot quicker. The compiler simulates a virtual stack, keeping track of which operands will be where (not yet loaded, loaded on the FPU stack, or shunted off to another stack for when the FPU is full) and would generate (hopefully) the fastest code for each case.

    I eventually managed to add conditional jumps (with caveats; you have to ensure the virtual stack will be in the exact same state at both ends of the jump - the compiler should ideally do this itself but it was too complicated) and have been able to implement a deinterlacer, denoisers and a Mandelbrot generator:

    https://www.youtube.com/watch?v=6uGRN2HX5cM [youtube.com]

    Anyway, no one much cares probably, but I enjoyed doing it.

    --
    systemd is Roko's Basilisk
  • (Score: 2) by Gravis on Friday January 15 2016, @02:44PM

    by Gravis (4596) on Friday January 15 2016, @02:44PM (#289888)

    what's old is new[s] again!

  • (Score: 2) by jdavidb on Friday January 15 2016, @06:17PM

    by jdavidb (5690) on Friday January 15 2016, @06:17PM (#289980) Homepage Journal
    Thanks for posting - I went through about half of this many years ago, shortly before taking a compilers course for my degree. Loved it.
    --
    ⓋⒶ☮✝🕊 Secession is the right of all sentient beings