Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.forth > #18573
| From | anton@mips.complang.tuwien.ac.at (Anton Ertl) |
|---|---|
| Newsgroups | comp.lang.forth |
| Subject | Re: Opinions on googl's go language? |
| Date | 2013-01-08 16:22 +0000 |
| Organization | Institut fuer Computersprachen, Technische Universitaet Wien |
| Message-ID | <2013Jan8.172256@mips.complang.tuwien.ac.at> (permalink) |
| References | (3 earlier) <Seudndr9hfhPOEDNnZ2dnUVZ_r2dnZ2d@supernews.com> <50ddba24$0$6565$9b4e6d93@newsspool3.arcor-online.net> <HpmdnZRVcK-1SEDNnZ2dnUVZ_vWdnZ2d@supernews.com> <2012Dec28.182354@mips.complang.tuwien.ac.at> <6254658.Mv3jkHfHv8@sunwukong.fritz.box> |
Bernd Paysan <bernd.paysan@gmx.de> writes:
>If I would develop a machine language course, I would probably start
>with Forth so that the students get the ideas of what bytes and words
>and memory is, and how to examine that (e.g. how a little endian 64 bit
>word looks like broken down into bytes, and therefore why the address is
>a multiple of 8), and then use that Forth to dig down one level further
>into assembly language, a real one, e.g. x86_64 assembler (an entry
>course doesn't have to teach all and every instruction, just the ones
>which you need - that's not that much, push pop call j<cc> ret mov xor
>and or add sub mul lea test are a good subset). That will stay around
>for long enough that I don't have to update my course each year ;-).
That sounds like a good plan if you have a full-blown computer
architecture course. Unfortunately we don't have that anymore at TU
Wien, so we have to compress things a bit more.
>>>Donald E. Knuth apparently thought the concept important
>>>enough to create MIX.
>>> [ _The Art of Computer Programming_ , Vol 1 - Fundamental
>>>Algorithms, 2nd Edition , c1973, p xi]
>>
>> One might say that this was long ago, but more recently he created
>> MMIX for reworking TAoCP.
>
>Yes, but that is just a rework, it would be fairly fundamental if he
>changed from a machine model to a high level programming language.
Depends what you mean by "high-level". I expected him to change to C
for reworking the books. I did not think that reworking from MIX to
MMIX is any easier or less fundamental than from MIX to C.
But given the tendencies to make C a language that is incapable of
expressing low-level things (not that this makes C any higher-level),
maybe Knuth was right in sticking with an assembly language (Forth
might be another option).
In particular, I recently wrote a hash function in (what I consider) C
as follows:
typedef unsigned int uint128_t __attribute__((__mode__(TI)));
#define hashmult 13493690561280548289ULL
unsigned long hash(char *addr, size_t len)
{
/* assumptions: 1) unaligned accesses work 2) little-endian 3) 7 bytes
beyond last byte can be accessed */
uint128_t x=0, w;
size_t i, shift;
for (i=0; i+7<len; i+=8) {
w = *(unsigned long *)(addr+i);
x = (x + w)*hashmult;
}
if (i<len) {
shift = (i+8-len)*8;
/* printf("len=%d, shift=%d\n",len, shift);*/
w = (*(unsigned long *)(addr+i))<<shift;
x = (x + w)*hashmult;
}
return x+(x>>64);
}
While the version of gcc I used for this happened to understand this
code as intended and compiled it correctly, I am sure the
self-proclaimed "people who have knowledge about C" consider it
meaningless and would be happy if gcc miscompiled this code. And I
don't think that there is a way to write this in standard C that
results in code that is as efficient, so maybe the way to go is really
to use assembly language.
Or, to get back on topic, Forth. We can just write this in Forth with
the same assumptions, and it would be equally non-standard, but in
Forth we do not have this attitude that non-standard programs are
meaningless and may be freely miscompiled. Still, what is missing
from Forth to write such code portably *and* efficiently? I think
that unaligned access is the main thing. There have been proposals
for that, but none has been accepted yet.
- anton
--
M. Anton Ertl http://www.complang.tuwien.ac.at/anton/home.html
comp.lang.forth FAQs: http://www.complang.tuwien.ac.at/forth/faq/toc.html
New standard: http://www.forth200x.org/forth200x.html
EuroForth 2012: http://www.euroforth.org/ef12/
Back to comp.lang.forth | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Opinions on googl's go language? the_gavino_himself <visphatesjava@gmail.com> - 2012-12-26 02:13 -0800
Re: Opinions on googl's go language? Hugh Aguilar <hughaguilar96@yahoo.com> - 2012-12-27 16:53 -0800
Re: Opinions on googl's go language? The Beez <the.beez.speaks@gmail.com> - 2012-12-28 02:49 -0800
Re: Opinions on googl's go language? Andrew Haley <andrew29@littlepinkcloud.invalid> - 2012-12-28 07:59 -0600
Re: Opinions on googl's go language? "A. K." <akk@nospam.org> - 2012-12-28 16:26 +0100
Re: Opinions on googl's go language? Richard Owlett <rowlett@pcnetinc.com> - 2012-12-28 11:21 -0600
Re: Opinions on googl's go language? anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2012-12-28 17:23 +0000
Re: Opinions on googl's go language? Richard Owlett <rowlett@pcnetinc.com> - 2012-12-28 16:20 -0600
Re: Opinions on googl's go language? anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2013-01-08 17:55 +0000
Re: Opinions on googl's go language? mhx@iae.nl (Marcel Hendrix) - 2012-12-28 23:48 +0200
Re: Opinions on googl's go language? Bernd Paysan <bernd.paysan@gmx.de> - 2012-12-28 23:56 +0100
Re: Opinions on googl's go language? gavino_himself <visploveslisp@gmail.com> - 2013-01-06 03:53 -0800
Re: Opinions on googl's go language? anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2013-01-08 16:22 +0000
Re: Opinions on googl's go language? Andrew Haley <andrew29@littlepinkcloud.invalid> - 2013-01-08 12:34 -0600
Re: Opinions on googl's go language? anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2013-01-23 16:40 +0000
Re: Opinions on googl's go language? Andrew Haley <andrew29@littlepinkcloud.invalid> - 2013-01-23 11:36 -0600
Re: Opinions on googl's go language? anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2013-01-24 12:46 +0000
Re: Opinions on googl's go language? Andrew Haley <andrew29@littlepinkcloud.invalid> - 2013-01-24 09:17 -0600
Re: Opinions on googl's go language? anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2013-01-24 17:23 +0000
Re: Opinions on googl's go language? Andrew Haley <andrew29@littlepinkcloud.invalid> - 2013-01-24 13:16 -0600
Re: Opinions on googl's go language? anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2013-02-05 17:59 +0000
Re: Opinions on googl's go language? Andrew Haley <andrew29@littlepinkcloud.invalid> - 2013-02-05 12:38 -0600
Re: Opinions on googl's go language? Andrew Haley <andrew29@littlepinkcloud.invalid> - 2012-12-30 03:24 -0600
Re: Opinions on googl's go language? Richard Owlett <rowlett@pcnetinc.com> - 2012-12-30 12:14 -0600
Re: Opinions on googl's go language? Bernd Paysan <bernd.paysan@gmx.de> - 2012-12-30 22:17 +0100
Re: Opinions on googl's go language? Andrew Haley <andrew29@littlepinkcloud.invalid> - 2012-12-30 03:22 -0600
Re: Opinions on googl's go language? Bernd Paysan <bernd.paysan@gmx.de> - 2012-12-30 14:25 +0100
Re: Opinions on googl's go language? Hugh Aguilar <hughaguilar96@yahoo.com> - 2012-12-28 20:55 -0800
Re: Opinions on googl's go language? The Beez <the.beez.speaks@gmail.com> - 2012-12-29 03:35 -0800
Re: Opinions on googl's go language? Doug Hoffman <glidedog@gmail.com> - 2012-12-29 11:49 -0500
Re: Opinions on googl's go language? The Beez <the.beez.speaks@gmail.com> - 2012-12-30 01:57 -0800
Re: Opinions on googl's go language? Doug Hoffman <glidedog@gmail.com> - 2012-12-30 07:01 -0500
Re: Opinions on googl's go language? The Beez <the.beez.speaks@gmail.com> - 2012-12-31 00:29 -0800
Re: Opinions on googl's go language? Doug Hoffman <glidedog@gmail.com> - 2013-01-02 09:18 -0500
Re: Opinions on googl's go language? Hugh Aguilar <hughaguilar96@yahoo.com> - 2013-01-02 20:32 -0800
Re: Opinions on googl's go language? Doug Hoffman <glidedog@gmail.com> - 2013-01-03 06:56 -0500
Re: Opinions on googl's go language? anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2013-01-08 15:50 +0000
Re: Opinions on googl's go language? Doug Hoffman <glidedog@gmail.com> - 2013-01-08 21:41 -0500
Re: Opinions on googl's go language? anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2013-01-23 16:55 +0000
Re: Opinions on googl's go language? Bernd Paysan <bernd.paysan@gmx.de> - 2013-01-23 20:23 +0100
Re: Opinions on googl's go language? Doug Hoffman <glidedog@gmail.com> - 2013-01-24 09:46 -0500
Re: Opinions on googl's go language? Alex McDonald <blog@rivadpm.com> - 2012-12-29 07:41 -0800
Re: Opinions on googl's go language? gavino_himself <visploveslisp@gmail.com> - 2012-12-29 19:29 -0800
Re: Opinions on googl's go language? tcholoka@gmail.com - 2013-01-03 09:36 -0800
Re: Opinions on googl's go language? Hugh Aguilar <hughaguilar96@yahoo.com> - 2013-01-06 00:32 -0800
Re: Opinions on googl's go language? Mark Wills <forthfreak@gmail.com> - 2013-01-06 01:26 -0800
Re: Opinions on googl's go language? gavino_himself <visploveslisp@gmail.com> - 2013-01-06 03:57 -0800
Re: Opinions on googl's go language? tcholoka@gmail.com - 2013-01-06 06:02 -0800
Re: Opinions on googl's go language? Hugh Aguilar <hughaguilar96@yahoo.com> - 2013-01-07 23:41 -0800
Re: Opinions on googl's go language? tcholoka@gmail.com - 2013-01-08 00:15 -0800
Re: Opinions on googl's go language? gavino_himself <visploveslisp@gmail.com> - 2013-01-06 03:56 -0800
csiph-web