functional languages with inline Intel ASM?

  • Follow


Can anyone point at functional languages that have their own Intel inline
ASM capabilities?  I'm not expecting such a beast to exist, but I'd like to
know if it does.

Only thing that someone has explicitly named so far is Corman Lisp, which
apparently has partial IA-32 support, but is missing a lot of stuff like
16-bit, MMX, SSE, and SSE2.  Or so one person tells me.
http://www.cormanlisp.com/

I'm not feeling picky about platform at the moment.  I'm a Windows guy, but
would be interested in Linux implementations for sake of my knowledge if
nothing else.

-- 
Cheers,                          www.indiegamedesign.com
Brandon Van Every                Seattle, WA

Brandon's Law (after Godwin's Law):
"As a Usenet discussion grows longer, the probability of
a person being called a troll approaches one RAPIDLY."


0
Reply Brandon 1/25/2004 2:17:46 AM

Brandon J. Van Every wrote:

> Can anyone point at functional languages that have their own
> Intel inline ASM capabilities?  I'm not expecting such a beast to
> exist, but I'd like to know if it does.
> 
> Only thing that someone has explicitly named so far is Corman
> Lisp, which apparently has partial IA-32 support, but is missing
> a lot of stuff like 16-bit, MMX, SSE, and SSE2.  Or so one person
> tells me.
> 
> I'm not feeling picky about platform at the moment.  I'm a
> Windows guy, but would be interested in Linux implementations for
> sake of my knowledge if nothing else.

Perhaps not quite what you were expecting, but one can interface C
with Objective Caml:

http://caml.inria.fr/ocaml/htmlman/manual032.html

Thus, I think you could write a time-critical function in C or even
in assembly language, and use that function from a Caml program...

(Well, I've never tried, so it is likely that what I said made no
sense.)

Nudge


0
Reply Nudge 1/25/2004 7:48:21 PM


Nudge <devnull@kma.eu.org> wrote in message news:<40138e6b$0$24014$626a54ce@news.free.fr>...

> Perhaps not quite what you were expecting, but one can interface C
> with Objective Caml:
> 
> http://caml.inria.fr/ocaml/htmlman/manual032.html
> 
> Thus, I think you could write a time-critical function in C or even
> in assembly language, and use that function from a Caml program...

Btw: Bigloo (very excellent and fast Scheme compiler) has also a very
good and easy to use C interface.

Fensterbrett

0
Reply chain_lube 1/26/2004 7:19:53 PM

> Nudge <devnull@kma.eu.org> wrote in message
>
>> Perhaps not quite what you were expecting, but one can interface C
>> with Objective Caml:

Pretty much all the languages can, functional or otherwise.  It's not what I
was asking, but thanks for trying.

-- 
Cheers,                     www.indiegamedesign.com
Brandon Van Every           Seattle, WA

20% of the world is real.
80% is gobbledygook we make up inside our own heads.


0
Reply Brandon 1/26/2004 10:24:23 PM

"Brandon J. Van Every" <try_vanevery_at_mycompanyname@yahoo.com> wrote in
message news:buv51v$m0u7r$1@ID-207230.news.uni-berlin.de...
> Can anyone point at functional languages that have their own Intel inline
> ASM capabilities?  I'm not expecting such a beast to exist, but I'd like
to
> know if it does.
>
> Only thing that someone has explicitly named so far is Corman Lisp, which
> apparently has partial IA-32 support, but is missing a lot of stuff like
> 16-bit, MMX, SSE, and SSE2.  Or so one person tells me.
> http://www.cormanlisp.com/
>
> I'm not feeling picky about platform at the moment.  I'm a Windows guy,
but
> would be interested in Linux implementations for sake of my knowledge if
> nothing else.
>
> -- 
> Cheers,                          www.indiegamedesign.com
> Brandon Van Every                Seattle, WA
>
> Brandon's Law (after Godwin's Law):
> "As a Usenet discussion grows longer, the probability of
> a person being called a troll approaches one RAPIDLY."
>
>

Delphi(windows) and Kylix(Linux) have their own inline assemblers, Object
Pascal though.  There are a few instructions that aren't supported BUT you
can still inline them if you know the Hex codes

example of this is (windows version)

function HasMMX: Boolean;
asm
  MOV EAX, 1
  CPUID
  TEST EAX, $800000
  JZ @@1
  MOV EAX, True
  JMP @@2
@@1:
  MOV EAX, False
@@2:
end;


or if the instruction isn't supported

function GetCPUTicks:Int64;
asm
  DB  $0F, $31 // RDTSC  requires Pentium or higher (CPU Clock Ticks)
end;

Note: These languages were designed for the x86 platform, so there is no
support for other instructions.

GCC uses GAS to compile, GAS has its own assembler language so that it can
be cross platform.

Jeremy



0
Reply Dragon 1/27/2004 2:04:35 AM

Dragon Lord wrote:
> 
> Delphi(windows) and Kylix(Linux) have their own inline assemblers,
> Object Pascal though.

These are not functional languages.

-- 
Cheers,                     www.indiegamedesign.com
Brandon Van Every           Seattle, WA

20% of the world is real.
80% is gobbledygook we make up inside our own heads.


0
Reply Brandon 1/27/2004 5:12:21 PM

"Brandon J. Van Every" <try_vanevery_at_mycompanyname@yahoo.com> wrote in
message news:bv4m5h$o5mbb$1@ID-207230.news.uni-berlin.de...
> Dragon Lord wrote:
> >
> > Delphi(windows) and Kylix(Linux) have their own inline assemblers,
> > Object Pascal though.
>
> These are not functional languages.
>
> -- 
> Cheers,                     www.indiegamedesign.com
> Brandon Van Every           Seattle, WA
>
> 20% of the world is real.
> 80% is gobbledygook we make up inside our own heads.
>
>
Semi functional :-D

but in any case, adding inline assembly would break the definition of a
functional language and thereby, it wouldn't be a functional language but
rather a semi functional.

"Functional programming is a style of programming that emphasizes the
evaluation of expressions, rather than execution of commands. The
expressions in these language are formed by using functions to combine basic
values. A functional language is a language that supports and encourages
programming in a functional style."



0
Reply Dragon 1/27/2004 9:51:54 PM

"Dragon Lord" <invalid@joke.com> wrote in
news:101dl1afciicb10@corp.supernews.com: 

> 
> but in any case, adding inline assembly would break the definition of
> a functional language and thereby, it wouldn't be a functional
> language but rather a semi functional.
> 

By that rational, once you click "compile" your program ceases to be 
functional. The processor itself would need to be functional in order for 
any language to be "truely" functional. The fact that it compiles to 
assembly and remains functional means that you can write functional 
assembly code.

-- 
Best regards,
 Jeff			jma[at]mfire.com
 http://www.jm-basic.com

0
Reply Jeff 1/27/2004 11:47:29 PM

Jeff Massung <jma@NOSPAM.mfire.com> writes:

> "Dragon Lord" <invalid@joke.com> wrote in
> news:101dl1afciicb10@corp.supernews.com: 
> 
> > 
> > but in any case, adding inline assembly would break the definition of
> > a functional language and thereby, it wouldn't be a functional
> > language but rather a semi functional.
> > 
> 
> By that rational, once you click "compile" your program ceases to be 
> functional.

Indeed. Do you think that when you click "compile" that C++ code
magically remains C++ as it's turned into an executable? 
On the architectures people commonly encounter, executables aren't 
functional. Source languages, however, can be.

Phil
-- 
Unpatched IE vulnerability: history.back method caching
Description: cross-domain scripting, cookie/data/identity 
             theft, command execution
Reference: http://safecenter.net/liudieyu/RefBack/RefBack-Content.HTM
Exploit: http://www.safecenter.net/liudieyu/RefBack/RefBack-MyPage.HTM

0
Reply Phil 1/28/2004 8:27:31 AM

Jeff Massung <jma@NOSPAM.mfire.com> writes:

> "Dragon Lord" <invalid@joke.com> wrote in
> news:101dl1afciicb10@corp.supernews.com: 
> 
> > 
> > but in any case, adding inline assembly would break the definition of
> > a functional language and thereby, it wouldn't be a functional
> > language but rather a semi functional.
> > 
> 
> By that rational, once you click "compile" your program ceases to be 
> functional. The processor itself would need to be functional in order for 
> any language to be "truely" functional. The fact that it compiles to 
> assembly and remains functional means that you can write functional 
> assembly code.

Indeed.  Maybe the solution would be to allow inlined typed assembly
language and let the compiler check for consistency, e.g., verify that
only variables declared mutable are overwritten.  

	Torben


0
Reply torbenm 1/28/2004 5:48:26 PM

Jeff Massung wrote:

> "Dragon Lord" <invalid@joke.com> wrote:
> 
>> but in any case, adding inline assembly would break the definition
>> of a functional language and thereby, it wouldn't be a functional 
>> language but rather a semi functional.
> 
> By that rational, once you click "compile" your program ceases to be
> functional.

Aside note:
Actually, the keywords are "pure" and/or "referentially transparent".
Meaning you can inline expand the contents of a function into its
callers and be confident that this doesn't change the semantics of the
program. Functional programming can be impure, this particular
combinations of features just doesn't mix well.
This doesn't mean that they are not mixed. Most if not all languages 
from the ML family give you both imperative and functional idioms, with 
the understanding that it's your responsibility to make proper use of 
the imperative stuff. Since the functional stuff is "good enough", most 
of ML code is functional, occasionally dropping to imperative idioms 
when efficiency or convenience dictate it. (That's very similar to using 
assembly in imperative languages, just at a more abstract level.)

> The processor itself would need to be functional in order for any
> language to be "truely" functional. The fact that it compiles to
> assembly and remains functional means that you can write functional
> assembly code.

The snag is: how do you make sure that your assembly code is pure? (Or, 
for that matter: your imperative code?)

If you rely on programmers to add pureness annotations: how do you make 
sure that mistakes here can be diagnosed?

I know of no approach that gives good answers to these questions.

Purely functional languages typically shield the programmer from the 
underlying, massively-imperative implementation (whether that's a VM or 
assembly). These do have interfaces for calling pure or impure external 
code (usually relying on the interface author to identfy pureness of 
external functions - this can suck heavily if there's any 
misidentification, but since no C library documents which functions have 
side effects and which don't, there's no way around this problem anyway, 
other than declaring everything impure, which sucks in other ways).

Regards,
Jo
--
Currently looking for a new job.


0
Reply Joachim 1/28/2004 5:50:31 PM

"Jeff Massung" <jma@NOSPAM.mfire.com> wrote in message
news:101dp1pkkhlqc8@corp.supernews.com...
> The fact that it compiles to
> assembly and remains functional means that you can write functional
> assembly code.
>
> -- 
> Best regards,
>  Jeff jma[at]mfire.com
>  http://www.jm-basic.com
>

Since when is assembly/machine code, a functional language?  Your compiler
converts your "functional" language into a "semi-function" language
(instructional step-by-step opcodes).

In fact on an x86, "functional assembly code" is an oxymoron :)

If you can write functional assembly code, try doing so using MS-DOS's Debug



0
Reply Dragon 1/28/2004 5:51:18 PM

"Dragon Lord" <invalid@joke.com> wrote in
news:101flh0hjuud3c8@corp.supernews.com: 

> 
> "Jeff Massung" <jma@NOSPAM.mfire.com> wrote in message
> news:101dp1pkkhlqc8@corp.supernews.com...
>> The fact that it compiles to
>> assembly and remains functional means that you can write functional
>> assembly code.
>>
> 
> Since when is assembly/machine code, a functional language?  Your
> compiler converts your "functional" language into a "semi-function"
> language (instructional step-by-step opcodes).

You do not need to speak a specific language to convey an idea in that 
language. It may be easier, granted, but is not required. By the mere fact 
that x86 code can be created that duplicates a functional language means 
that you can speak functionally in assembly. GHC is a wonderful example of 
this.

You could instead take a reverse approach: since any functional language 
must be converted to an imperative form to even execute, is there really 
such a thing as a functional language?

The only truth here is that one may or may not *program* functionally. One 
language over another may help or hinder this goal, but it is up to the 
programmer to do it. Functional programming is a concept, and a good one. 
But don't confuse what it is with what it does.

-- 
Best regards,
 Jeff			jma[at]mfire.com
 http://www.jm-basic.com

0
Reply Jeff 1/28/2004 7:37:06 PM

"Jeff Massung" <jma@NOSPAM.mfire.com> wrote in message
news:101g2posn106nf9@corp.supernews.com...
> You do not need to speak a specific language to convey an idea in that
> language. It may be easier, granted, but is not required. By the mere fact
> that x86 code can be created that duplicates a functional language means
> that you can speak functionally in assembly. GHC is a wonderful example of
> this.
>
> -- 
> Best regards,
>  Jeff jma[at]mfire.com
>  http://www.jm-basic.com
>

You could ALSO say then, just about every language could be functional too,
since it can duplicate a functional language. But the point was, if you add
in assembly (non functional language, in itself) to a functional language,
the language itself is not functional anymore, but semi functional because
NOW the syntax of the language breaks the definition of being a functional
language.  And languages that DO use it, can't be considered a functional
language, they are just adding "BUZZ" words to fluff it up, so people will
buy/download it.



0
Reply Dragon 1/28/2004 9:49:27 PM

Dragon Lord wrote:

> You could ALSO say then, just about every language could be 
> functional too, since it can duplicate a functional language.

Whether a language can be considered is mainly a function of whether
it's convenient to program in a functional style in it.

All functional languages have imperative constructs in them, with a wide
spectrum from "using it every day" (Lisp dialects) to "was introduced
for strictly internal purposes" (Haskell). Most modern functional
languages live somewhere in the middle of that spectrum ("functional
constructs are so d**n well-working that you don't drop down to the
imperative ones unless there's a *very* good reason to do so").

There's some ideology involved: many program transformations that are
highly dangerous in the presence of imperative constructs become safe if
it's known that some piece of code is pure and calls just pure code.
(This works whether the "code transformation" in question is the
compiler that's optimizing things, or the programmer who's refactoring
and rearranging code.)
There's a strong sentiment that only languages that have nothing but
pure constructs should be calld functional. I consider that playing name
games, particularly since it's not functionalness but pureness
(referential transparency) that matters. But everyone to his taste :-)

> But the point was, if you add in assembly (non functional language, 
> in itself) to a functional language, the language itself is not 
> functional anymore, but semi functional because NOW the syntax of the
> language breaks the definition of being a functional language.

Applying what I said above, I'd subscribe to your statement if you had
said "pure" and "functional" instead of "functional" and "semi-functional".
In fact, there are languages that are functional but impure. Smalltalk
is a well-known example: it has closures (called "blocks"), and lots of
higher-order functions (all those conditional and iterator methods).
Smalltalk libraries don't make systematic use of higher-order functions,
because impureness and high order don't mix very well, but it's feasible
to combine them to the degree shown.

BTW syntax is relatively irrelevant to whether a language is functional 
or pure.

> And languages that DO use it, can't be considered a functional 
> language, they are just adding "BUZZ" words to fluff it up, so people
>  will buy/download it.

Unlikely - being functional is not generally considered sexy. (You'll
attract a narrow but relatively devoted audience.)

Regards,
Jo
--
Currently looking for a new job.


0
Reply Joachim 1/29/2004 6:51:54 PM

In article <bvbhc3$mrm$1@news.oberberg.net>, Joachim Durchholz wrote:
> Whether a language can be considered is mainly a function of whether
> it's convenient to program in a functional style in it.
> 
> [...]
>
> BTW syntax is relatively irrelevant to whether a language is functional 
> or pure.

Is not syntax that which makes programming convenient or inconvenient?

William
0
Reply wlovas (87) 1/31/2004 8:13:40 PM

William Lovas wrote:
> In article <bvbhc3$mrm$1@news.oberberg.net>, Joachim Durchholz wrote:
> 
>>Whether a language can be considered is mainly a function of whether
                                       ^ functional
(must have been that typing-faster-than-speed-of-thought mode...)
>>it's convenient to program in a functional style in it.
>>
>>[...]
>>
>> BTW syntax is relatively irrelevant to whether a language is
>> functional or pure.
> 
> Is not syntax that which makes programming convenient or inconvenient?

Syntax, convenience, functionalness, and pureness are mutually 
orthogonal (in a strict sense: they do indeed correlate in the looser 
sense that language designers will often select a particular combination 
of these).

Regards,
Jo
--
Currently looking for a new job.

0
Reply joachim.durchholz (563) 2/1/2004 8:03:38 AM

In article <bvibpq$hsm$1@news.oberberg.net>, Joachim Durchholz wrote:
> Syntax, convenience, functionalness, and pureness are mutually 
> orthogonal (in a strict sense: they do indeed correlate in the looser 
> sense that language designers will often select a particular combination 
> of these).

For an example of an interesting point in that design space, there's
always Unlambda (http://www.eleves.ens.fr:8080/home/madore/programs/unlambda/).
Indeed, functional and convenient doesn't have to go hand in hand. I'm
still not decided on the syntax though. :-) It may well be surpassed
by the language Whitespace (http://compsoc.dur.ac.uk/whitespace/) :-)

Stefan,
-- 
Stefan Axelsson                  (email at http://www.cs.chalmers.se/~sax)
0
Reply sax1 (19) 2/2/2004 2:15:53 PM

Stefan Axelsson wrote:
> Whitespace (http://compsoc.dur.ac.uk/whitespace/) :-)

Cool :-))))
There's a certain inelegance here though; the language should be 
redesigned to use just space characters and end-of-lines, to accommodate 
non-ASCII machines.
Anyway, its most serious deficit is that it's imperative ;-)

No discussion of silly languages would be complete without mention of 
Intercal, see http://www.catb.org/~esr/intercal/ .

Regards,
Jo
--
Currently looking for a new job.

0
Reply joachim.durchholz (563) 2/2/2004 3:49:10 PM

18 Replies
143 Views

(page loaded in 0.227 seconds)

Similiar Articles:
















7/22/2012 1:17:25 AM


Reply: