Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

FreeSoftware Compiler Blows

Name: Anonymous 2014-03-15 9:38

Name: Anonymous 2014-03-15 10:24

use tcc or clang?

also, someday someone will write a C compiler in Lisp that will outperform every other C compiler, while its source will be short and clear enough for someone who has only taken Java 101 in college to read and understand on a Sunday afternoon

Name: Anonymous 2014-03-15 15:14

>>2
source will be short and clear enough for someone who has only taken Java 101 in college to read and understand on a Sunday afternoon
There is no shortcut in writing a C compiler. You cannot avoid having at least six stages:
1. input -> tokens
2. tokens -> AST (abstract syntax tree)
3. AST -> simplified AST (basically macro-expansion stage)
4. simplified AST -> SSA or CPS
5. SSA/CPS -> machine code
6. machine code -> object file

In case of C, the "input -> tokens" stage would be especially convoluted due to the bad language design, requiring feedback from "tokens -> AST"

I have left out optimization passes, which would run on AST and SSA/CPS forms

Name: Anonymous 2014-03-15 17:17

>>3

Also, implementing C's type system requires some effort, especially type promotions, bit-fields and unions.

Name: Anonymous 2014-03-15 18:24

>>3
There is no shortcut in writing a C compiler.
Yes there is. It's called LISP.

Name: Anonymous 2014-03-15 18:38

>>5
I dare say, LISP won't simplify it.

Moreover, compilers are generally one shot applications, therefore have no reason freeing memory, meaning that Lisp's garbage collection would make no difference, beyond slowing down the compiler.

Name: Anonymous 2014-03-15 21:22

GC is shit.

Name: OP 2014-03-15 21:27

In case of C, the "input -> tokens" stage would be especially convoluted due to the bad language design, requiring feedback from "tokens -> AST"

Really ? I've written an about 80% complete C compiler, and C's tokens are straightforward as fuck. There's only like 30 or so of them. It is however the case that some tokens have different meanings based upon context, but that's something the parser can pretty easily solve if it's properly written.

Name: Anonymous 2014-03-15 21:29

>>8
whoops I'm not OP of this thread but I had a stupid autocomplete from an old posting

Name: Anonymous 2014-03-15 22:21

>>6
There are already < 4000 line C compilers written in Lisp. Search e.g. Vaceitis.

Name: Anonymous 2014-03-16 5:47

>>10
I'm not >>6 , but I just tried Vacietis.

I wouldn't call it < 4000 lines. Vacietis itself is closer to 6000 lines, and it pulls in ~60000 lines of dependencies in .lisp files according to a quick scan of ~/quicklisp/. If we let dependencies slide then we're in ``I can write a load balancing web server in five lines of Ruby!'' territory. Of course, 4000 was probably hyperbole by whoever first said it, and 60000 lines of Lisp is probably simpler than the millions of lines of Sepples that gcc is written in, so I won't quibble over the idea that ``Written in Lisp, it could be simpler''.

However, I don't think the complexity of those 60k lines is enough. It seemed to have some problems with my input files which gcc -Wall -pedantic had no issues with (couldn't find time.h and other headers, and after I inserted them manually it seemed to get confused over an erroneous ``unexpected end of file''). I remain unconvinced.

Name: Anonymous 2014-03-16 5:51

>>11
I won't quibble over the idea that ``Written in Lisp, it could be simpler''.

I won't quibble over the idea that ``Written in Lisp, it could be simpler'' using 4000 as the target linecount.

I should proofread my posts more.

Name: Anonymous 2014-03-16 7:58

>>8

I've written an about 80% complete C compiler
Talk sucks. Show us teh codes.

Name: Anonymous 2014-03-16 8:50

>>11
I was the one who said 4000 lines, and that was going from memory. I guess I was optimistic.

I think if you want to count lines from libraries or the Lisp implementation a good idea might be to use a textual ``tree shaker''.

I imagine using the who-calls or whatever functions from SLIME would make writing a textual tree shaker not too difficult if one doesn't already exist.

Also of interest is that the C compiler that came with Open Genera could compile X11.

Name: Anonymous 2014-03-16 13:17

A good optimizing compiler is a complex piece of software. You can't implement it "in a few lines of <your-favourite-language-name>", unless your <your-favourite-language-name> already includes most of the compiler, like Lisp does, providing READ and EVAL.

Name: Anonymous 2014-03-16 17:14

At least it doesn't suck.

Name: Anonymous 2014-03-19 6:25

>>16
Blowjob, sucking.. both seem pretty good things to mee.

Name: sage 2014-03-19 9:57

>>17

Suck this. unzipz pants*

Name: Anonymous 2014-03-19 23:44

>>17
Blowjob my anus

Don't change these.
Name: Email:
Entire Thread Thread List