Subject: [[email-masked]: Shimon Schocken on Tuesday 05/06/2001]

From: "Nadav Har'El" <[email-masked]>
Date: Fri, 6 Apr 2001 16:04:27 +0200

The following colloquium in the Technion might be of interest to the
"hacker" community (just look at the name of their computer!). Note,
however, that it's a 2 month advanced notice (it's not next week ;))

Sounds like the course they are describing could be a lot of fun.
Some years ago someone (an Electrical Engineer) gave me as a for-fun
summer project an old Motorolla CPU, hoping that I would have fun with
it by connecting it to my computer and writing a cross-compiler for it
(it was before the days of GCC having a cross-compiler for virtually anything).
But it was a bit too complicated (and getting the CPU to actually connect
to anything, you know "hardware", was a bit beyond what I could do alone and
I didn't want to bother him too much), so I switched to my alternate plan for
the summer: writing a library for doing text and graphics on the IBM PS/2 by
directly accessing memory and I/O ports without using the BIOS (on DOS, of
course - these were the days I didn't yet boycot Microsoft, and used both
Unix and DOS and/or Windows 3.1). Oh, those highschool days when I had whole
summers to do whatever I feel like... ;)

----- Forwarded message from [email-masked] -----

Date: Fri, 6 Apr 2001 07:40:11 +0200 (IST)
From: [email-masked]
To: [email-masked]
Subject:  Shimon Schocken on Tuesday 05/06/2001

Time+Place : Tuesday 05/06/2001 14:30 room 337-8 Taub  Bld.
Speaker    : Shimon Schocken
Affiliation: Interdisciplinary Center (IDC), Herzelia
Host       : Benny Chor
Title      : The Hack Project
 
Abstract   :
The talk describes a new course in which we construct a complete
computer system, called Hack, in one semester.  Following a review of
key topics in Boolean algebra and gate logic, we build some thirty
combinational and sequential chips, which set the stage for the
construction of Hack's ALU, CPU, and memory systems. The hardware is
built using a simple Hardware Description Language and a hardware
simulator, developed for this course. We then test the entire machine by
running some programs on it, written in Hack's assembly and machine
languages. The students write the necessary assembler.

Next, the students build a virtual machine called Vack, and write an
interpreter that translates Vack code into Hack's machine language. We
then introduce a Java-like language, called Jack, and the students write
a compiler from Jack to Vack. This completes the design of the computer.
Using Jack, the students write a simple operating system for the
computer, and a sample application like a text-editor or a tetris game.

Our objective in this course is to give the students a realistic picture
of the hardware-software interface, and to have them get their hands
dirty and build a complete computer from scratch.

Joint work with Noam Nisan.

----------------------------------------------------------
Visit our home page-  http://www.cs.technion.ac.il/~colloq

----- End forwarded message -----

-- 
Nadav Har'El                        |       Friday, Apr  6 2001, 13 Nisan 5761
[email-masked]             |-----------------------------------------
Phone: +972-53-245868, ICQ 13349191 |Despite the cost of living, have you
http://nadav.harel.org.il           |noticed how it remains so popular?

---

From: Shlomi Fish <[email-masked]>
Date: Tue, 10 Apr 2001 11:24:56 +0300 (IDT)

Hmmm. This course sounds like "Logic Design and Intro to Computers" of the
EE faculty (http://tiger.technion.ac.il/~imenache/Logic/) on steroids.

I would not attend this Hack-Vack-Jack course, because since I took Logic
Design (and like I said earlier it was my favourite course so far), I
don't know whether it will renew a lot to me.

Besides, I probably will need a zillion CS faculty pre-requisites which I
don't have.

Since the course mentions compilers I thought I'll share a story with you.
A friend of mine has an HP48 calculator, which can be programmed in
Assembler. When he installed Linux, he decided to write a Pascal compiler
for it - from scratch, without even using Lex and Yacc. He told me that
there was already a C compiler for it, but I left it at that.

Several monthes later we spoke on the phone, and I asked him how is the
compiler progressing. He said that something in it wasn't working, but I
didn't understand exactly what. Then I asked him if he might be able to
use gcc, so he told me that gcc can generate code for the HP48. Then, I
told him gcc had a Pascal front-end called GNU Pascal or GPC. So, he said
he wished he knew it earlier because it could have saved him a lot of
trouble...

In any case, how many language front-ends there are to gcc anyways. Here
are the ones I'm aware of:

1. ANSI C (gcc)
2. C++ (g++)
3. Objective C (comes with the gcc distribution)
4. Pascal (gpc and perhaps also Free Pascal)
5. Java and Java byte code (gcj)
6. Ada (GNATS - it's written in Ada, so you need to bootstrap it)
7. Fortran 77 (g77) - available on GNU sites.
8. Haskell - Glasgow Haskell Compiler or ghc. It is written in Haskell,
and requires itself to be compiled.

And this is without all those Something -> C translators. Do you know of
any others?

Regards,

	Shlomi Fish

----------------------------------------------------------------------
Shlomi Fish        [email-masked] 
Home Page:         http://t2.technion.ac.il/~shlomif/
Home E-mail:       [email-masked]

A more experienced programmer does not make less bugs. He just realizes
what went wrong more quickly.

---

From: mulix <[email-masked]>
Date: Tue, 10 Apr 2001 11:54:20 +0300 (IDT)

> EE faculty (http://tiger.technion.ac.il/~imenache/Logic/) on steroids.

i think it encompasses a lot more than just logic design. however, since
the material the sugested course encompasses sound like half of a degree
in CS, i doubt they'll be covered in any sufficient detail. there's a
limit to what can be done in only one semester. 

> he wished he knew it earlier because it could have saved him a lot of

for the "programming languages" class i'm currently taking
(http://www.cs.technion.ac.il/~cs234319/), i needed a
pascal commpiler and an SML interpreter for linux. i tried both GPC and
free pascal (fpc). GPC is supplied as a patch to gcc, but a rather old
version of gcc- egcs something, or perhpahs even gcc 2.8.*, i do not
remember. this was a problem, as i use gcc 2.95.2 (soon to be 2.95.3,
maybe even a 3.0 snapshot if i feel brave). free pascal on the other hand
is completely stand alone, works fine and also generates debug information
GDB. so for me, fpc it was. my first homework exercise, which was in
pascal, can be found here: http://www.pointer.co.il/~mulix/prog_lang_1.pas

(a tangent: i asked a professor whether i could publish my homework on the
web [after the due date, of course] and he could not supply a definite
answer. can someone enlighten me on the relevant academic rules?)

a note on "programming languages": the course is highly abstract, dealing
with such subjects as "polynomial representation of variables" and
"classification of type systems". nonetheless, it is very interesting and
eye opening. i do think that you need a bit more programming experience
than your average CS student to appreciate the inner beauty and harmonics
of the material we are being taught. definitely one of my favorite classes
so far.

a rant on pascal: how can a language have none of
case sensitivity
initialization of const arrays
no return from functions or procedures (!)

i'm starting to understand the old joke about nickle's worth. 

> In any case, how many language front-ends there are to gcc anyways.
> Here are the ones I'm aware of:

http://www.gnu.org/software/gcc has the following quote:

"Currently GCC contains front-ends for C, C++,Objective C, Chill, Fortran,
and Java as well as libraries for these languages (libstdc++,
libgcj,...)."

the rest come as stand alone patches to gcc, probably. in any event,
writing a front end for gcc is an intersting excersize. anyone up to it?

-- 
mulix
http://www.advogato.com/person/mulix

linux/reboot.h: #define LINUX_REBOOT_MAGIC1 0xfee1dead

---

From: Oleg Goldshmidt <[email-masked]>
Date: 10 Apr 2001 12:05:05 +0300

mulix <[email-masked]> writes:

> free pascal (fpc). 

IIRC, there is also p2c. Maybe that will work with your favourite
gcc version.

-- 
Oleg Goldshmidt | [email-masked] 
"I'd rather write programs to write programs than write programs."

---

From: "Nadav Har'El" <[email-masked]>
Date: Tue, 10 Apr 2001 12:10:47 +0300

> don't know whether it will renew a lot to me.

Don't worry, I think the actual course is given in the IDC, not the Technion,
so you won't get a chance to take it anyway :) The lecture I was pointing
out to is only a lecture _about_ the course. A meta-lecture.

> Besides, I probably will need a zillion CS faculty pre-requisites which I

I thought their idea was to let you play around with stuff before you know
all the details of how they work (although when I hear the lecture I'll
probably know more about what their idea is). When I first started playing
around with Yacc I was 12 and knew nothing about compiler theory (heck, I
was in elementary school!) - but I managed to take an existing compiler and
add new syntax to it, and later this made me interested about how compilers
*really* work, until a few years later I finally read the dragon book.
Perhaps their course was also meant to motivate new students - I don't
know, I'll have to hear their lecture I guess.

> there was already a C compiler for it, but I left it at that.

If he decided not to use Yacc (or a similar tool), I hope that he at least
learned some compiler theory... Reinventing compiler theory on your own is
not, to put it mildly, a trivial undertaking ;)

> And this is without all those Something -> C translators. Do you know of

Many years ago, when C was beginning to dominate the world, most new
compilers where written as Something-to-C compilers. The idea was that
why should you compiler some language to Assembly Language of a specific
machine, when you already have a "portable assembly language", namely C.
I've seen successful propriatary compilers like this, and also Pascal to C,
Fortran to C, Awk to C, and similar compilers. I'm not sure why, but it
appears as though gcc killed that trend. The stand-alone Fortan-to-C
compiler was ditched in favor for a Fortran front-end withing gcc. There
are downsides to this close integrate (bloatware?), such as you can't
compile Fortran on a machine that has a C compiler, but not gcc (e.g., I
had a C compiler on a Commodore-64!). So what are the real benefits in this
monolithic approach? Is it the better optimization possibilities? Wouldn't
this problem be solved if C optimizers are improved?

-- 
Nadav Har'El                        |      Tuesday, Apr 10 2001, 17 Nisan 5761
[email-masked]             |-----------------------------------------
Phone: +972-53-245868, ICQ 13349191 |Isn't Disney World a people trap
http://nadav.harel.org.il           |operated by a mouse?

---

From: "Nadav Har'El" <[email-masked]>
Date: Tue, 10 Apr 2001 12:27:20 +0300

> answer. can someone enlighten me on the relevant academic rules?)

I don't know the official rules, but my inner morals tells me that it is
perfectly fine to publish homework *you* did, assuming that your solution
is a much more substantial work than the question itself. What is NOT fine
is to look at such solutions instead of trying to do the work yourself.

In my opinion the same should be true also for tests: you should be allowed
to publish previous tests and suggested solutions. As far as I saw, this was
the norm in the Technion (the student union even gave people small gifts
if you gave them copies of tests) but strangely it seems to be frowned upon
in HaifaU...

It is obvious why professors would not want previous excercises and tests
to be published - it will force them to make up new questions every once
in a while. But every now and then these professors need to be reminded that
they are paid for this work, and that the raison d'etre of BA studies is
to teach the students well, not to make life easy for the professor...

> no return from functions or procedures (!)

I think that Brian Kernighan agrees with you :) He wrote (in 1981, that's
20 years ago!) a technical report about why Pascal sucks, titled "Why Pascal
is Not My Favorite Programming Language". See

	http://cm.bell-labs.com/cm/cs/cstr/100.ps.gz

You can also see his homepage, at http://cm.bell-labs.com/who/bwk/.

-- 
Nadav Har'El                        |      Tuesday, Apr 10 2001, 17 Nisan 5761
[email-masked]             |-----------------------------------------
Phone: +972-53-245868, ICQ 13349191 |A Life? Cool! Where can I download one
http://nadav.harel.org.il           |of those from?

---

From: mulix <[email-masked]>
Date: Tue, 10 Apr 2001 13:59:23 +0300 (IDT)

> this problem be solved if C optimizers are improved?

it appears to me that the major loss in such an "intermediate" compiler is
in the area of optimisations. consider the "no alias" keyword of C99,
which says a pointer is not aliased by any other pointer, leading to many
possible optimisations which are too risky otherwise. how would you
translate this to "old c", without losing this important piece of
programmer supplied knowledge in the translation? also, perhaphs
translating to c is much harder than translating to an intermediate
internal representatio, which is the way gcc front ends work. 
-- 
mulix
http://www.advogato.com/person/mulix

---

From: mulix <[email-masked]>
Date: Tue, 10 Apr 2001 14:06:49 +0300 (IDT)

> to teach the students well, not to make life easy for the professor...

there is one class (Digital Systems) i've taken so far, where no tests are
published since the questions come for a closed pool of questions. in all
other classes, the tests are always published, nearly always with official
solutions.

> You can also see his homepage, at http://cm.bell-labs.com/who/bwk/.

i've read it in the past, but i'll read it again. oh, and thanks for the
pointer to stroustroup's april's fools paper. it was hilarious!
-- 
mulix
http://www.advogato.com/person/mulix

---

From: Oleg Goldshmidt <[email-masked]>
Date: 10 Apr 2001 14:14:58 +0300

"Nadav Har'El" <[email-masked]> writes:

> The stand-alone Fortan-to-C compiler was ditched in favor for a
> Fortran front-end withing gcc.

I don't know about it. Can anyone confirm?

A bit of personal reminiscences:

For a few years I worked for a company that was writing tons of
Fortran code, with the main development compiler being f2c/gcc (in the
fort77 incarnation). Worked like a charm (better than commercial
compilers we had on our target platforms), last time I recall a
problem was years ago, and the fix was really fast.

For probably something like a couple of years, when g77 reached some
sort of maturity, I used both f2c and g77. Both worked fine, g77 was a
bit stricter about standards as I recall. there were some differences
regarding debugging information, overall I think that f2c/gcc
combination worked better with gdb (as I recall this stuff was very
well explained in some pretty obvious place in the info pages, for the
inquisitive). Maybe I was simply more used to it though.

One benefit of f2c/gcc combination is that you can look at the C code,
which may come handy if you mix C and Fortran. One must be cautious,
of course, since f2c is not guaranteed to do the same thing as other
Fortran compilers, but it's useful and instructive nonetheless.

> So what are the real benefits in this monolithic approach?

[Irrelevant for GCC]: Financial? You can charge for separate
compilers... ;-)

> Is it the better optimization possibilities? Wouldn't this problem
> be solved if C optimizers are improved?

Maybe the fact that different languages follow different models, and
it is not always optimal (in many senses) to twist a language to
produce something fairly contorted in C, something that a C compiler
may have trouble dealing with or optimizing or...

---

From: Moshe Zadka <[email-masked]>
Date: Tue, 10 Apr 2001 14:12:43 +0300

> and requires itself to be compiled.

You forgot Chill

-- 
"I'll be ex-DPL soon anyway so I'm        |LUKE: Is Perl better than Python?
looking for someplace else to grab power."|YODA: No...no... no. Quicker,
   -- Wichert Akkerman (on debian-private)|      easier, more seductive.
For public key, finger [email-masked]  |http://www.{python,debian,gnu}.org

---

From: Oleg Goldshmidt <[email-masked]>
Date: 10 Apr 2001 14:29:11 +0300

> may have trouble dealing with or optimizing or...

I forgot to mention that I do see advantages in translating everything
into a "portable assembler". Or into lisp (to have both a compiler
and an interpreter) -- as Chen was right to mention.

---

From: Shlomi Fish <[email-masked]>
Date: Tue, 10 Apr 2001 14:36:12 +0300 (IDT)

> > and requires itself to be compiled.

I didn't forget, I just didn't knew a Chill front-end (or the Chill
language for that matter) existed in the first place. But now we have 9
front-ends and going strong.

Regards,

	Shlomi Fish

---

From: "Nadav Har'El" <[email-masked]>
Date: Tue, 10 Apr 2001 14:50:11 +0300

> and an interpreter) -- as Chen was right to mention.

But that was my original point, if you view C as a "portable assembler".
After all, C is very low level. Surely, if C has some constructs that
cannot be optimized without knowledge of the architecture of the specific
machine, then you'll have the same problem with any portable assembler
you devise. If you do a loop in assembly language, and can't assume that
a called function (or another thread) doesn't change the loop pointer, then
you face the same optimizing problem you have when compiling C...

I'm sure that there is some optimization pentalty in compiling to C, but
I would be suprised if that penalty is substantial when using a good C
compiler. Of course, this wouldn't be true if another language was chosen
instead of C - the assumption is that it is a very low-level language quite
close to the machine language.

-- 
Nadav Har'El                        |      Tuesday, Apr 10 2001, 17 Nisan 5761
[email-masked]             |-----------------------------------------
Phone: +972-53-245868, ICQ 13349191 |Can Microsoft make a product that
http://nadav.harel.org.il           |doesn't suck? Yes, a vacuum cleaner!

---

From: Oleg Goldshmidt <[email-masked]>
Date: 10 Apr 2001 16:03:06 +0300

> But that was my original point, 

Precisely. I was concerned that my previous posting would be regarded
as a disagreement, so I wrote the appendage.