473,406 Members | 2,352 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Threads vs. continuations

I've been doing some thinking, and I've halfway convinced myself of
the following statement: that threads as implemented by Python (or
Java) are exactly equivalent to one-shot continuations in Scheme. Am
I right? (I'd have asked in the scheme groups, but I feel like I'm
less likely to get flamed to death here... hehe.)

If that's the case, it seems threads plus hygeinic macros and a few
primitives a la Scheme would form a solid basis upon which to build a
programming language. The only thing preventing Python from being
that language is the difficulty of integrating a macro system, n'est-
ce pas?

Thanks!

Paul
Feb 19 '08 #1
7 1154
mi***********@gmail.com wrote:
I've been doing some thinking, and I've halfway convinced myself of
the following statement: that threads as implemented by Python (or
Java) are exactly equivalent to one-shot continuations in Scheme. Am
I right? (I'd have asked in the scheme groups, but I feel like I'm
less likely to get flamed to death here... hehe.)

If that's the case, it seems threads plus hygeinic macros and a few
primitives a la Scheme would form a solid basis upon which to build a
programming language. The only thing preventing Python from being
that language is the difficulty of integrating a macro system, n'est-
ce pas?

Thanks!

Paul
An interesting question to which I shall stay tuned for an answer.

However, allow me to point out that there is a macro language for
Python. It's called 'm4' ... <ducks and runs>

--
----------------------------------------------------------------------------
Tim Daneliuk tu****@tundraware.com
PGP Key: http://www.tundraware.com/PGP/
Feb 19 '08 #2
In article <06**********************************@h25g2000hsf. googlegroups.com>,
<mi***********@gmail.comwrote:
>
If that's the case, it seems threads plus hygeinic macros and a few
primitives a la Scheme would form a solid basis upon which to build a
programming language. The only thing preventing Python from being
that language is the difficulty of integrating a macro system, n'est-
ce pas?
"Difficulty" as measured in Guido being less likely than the survival of
a snowball in the Sahara to ever consider anything like hygenic macros.
--
Aahz (aa**@pythoncraft.com) <* http://www.pythoncraft.com/

"All problems in computer science can be solved by another level of
indirection." --Butler Lampson
Feb 19 '08 #3
On Feb 19, 8:26*pm, miller.pau...@gmail.com wrote:
[...]
The only thing preventing Python from being
that language is the difficulty of integrating a macro system, n'est-
ce pas?
Well there's logix (http://www.livelogix.net/logix/)
--
Arnaud

Feb 19 '08 #4
I've been doing some thinking, and I've halfway convinced myself of
the following statement: that threads as implemented by Python (or
Java) are exactly equivalent to one-shot continuations in Scheme. Am
I right?
No. In case of threads, progress can be made in an overlapping
(concurrent), in case of Java even parallel fashion. In particular,
if a thread blocks in a blocking operating system call (e.g. a network
receive operation), other threads can continue. I believe this is not
possible with continuations in Scheme.

In more detail, threads as provided by the operating system underly
a system scheduler: they can be preempted, they have priorities,
and they may voluntarily block. All this is not possible with
continuations.

IOW, threads are more expressive than continuations.

Regards,
Martin
Feb 19 '08 #5
Tim Daneliuk <tu****@tundraware.comwrites:
'Not trying to start a fight here, I'm just curious about the
current state of that art. It is the case today that all
modern language threading is realized over a kernel implementation
of threading that behaves as you suggest?
Certainly not. See Erlang, Haskell, Concurrent ML, etc.
The low level i/o in the runtime systems for those languages has
to be written to never block, but the payback is much lighter weight
user threads.
Feb 19 '08 #6
Tim Daneliuk wrote:
Martin v. Löwis wrote:
Is/Was it not the case, though, that some languages present
a threading model to the programmer that is realized in user
space, but not in the kernel. ISTR some early implementations
of Posix Threads that worked that way. The API was there
and was correct, but - since everything was actually running
in user space - when a single "thread" blocked, they all did.
People did things like that to hammer threading onto operating
systems so dumb they couldn't context switch, like
DOS, early Windows, and MacOS through 7. Nobody does that
any more.

For one thing, it's easier to build a real scheduler
than to build the hacks for working without one. (Mac programmers
referred to this as the Mess Inside - no real CPU dispatcher, but
"deferred tasks", "timer tasks", "vertical interval tasks", and
similar hacks to work around the lack of one.)

John Nagle
Feb 20 '08 #7
John Nagle <na***@animats.comwrites:
People did things like that to hammer threading onto operating
systems so dumb they couldn't context switch, like
DOS, early Windows, and MacOS through 7. Nobody does that
any more.
I see stuff heading more the other way; here's a description of a test
of Erlang with 20 million (userspace) threads:

http://groups.google.com/group/comp....b7a62afb727a4f

I don't know of any OS's that can handle that many threads.
Lightweight userspace threads also makes it sane to do things like
make GUI's with a separate thread per widget, and in general to
handle large numbers of concurrent tasks without the large memory
footprint and context switch overhead of kernel level threads.
Feb 20 '08 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
by: Russell Wallace | last post by:
Hi all, Python lets you continue a single logical line across more than one physical line, either by putting a \ at the end or letting it happen automatically with an incomplete infix operator....
17
by: Mike Thompson | last post by:
'Seaside' is a Smalltalk framework for what might be called "Modal Web Development" or "Synchronous Web Programming", or even "Continuation Based Web Apps". http://www.beta4.com/seaside2/ ...
2
by: Florian Lindner | last post by:
Hello, http://docs.python.org/lib/module-ConfigParser.html writes: "with continuations in the style of RFC 822; " what is meant with these continuations? Thanks, Florian
6
by: vasudevram | last post by:
Hi, I am Googling and will do more, found some stuff, but interested to get viewpoints of list members on: Continuations in Python. Saw a few URLs which had some info, some of which I...
26
by: gnuist006 | last post by:
Again I am depressed to encounter a fundamentally new concept that I was all along unheard of. Its not even in paul graham's book where i learnt part of Lisp. Its in Marc Feeley's video. Can...
3
by: gangesmaster | last post by:
i've had this strange idea of using the exception's traceback (which holds the stack frame) to enable functional continuations, meaning, raise some special exception which will be caught by a...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.