Programming Language Converted
Humanoido
Posts: 5,770
The operating speed of a programming language can become an issue with some apps. PASM is very fast and SPIN is probably next fastest. There are several languages which can be converted. Which languages rate at the fastest operating speeds when converted? Thank you in advance.
Humanoido
Humanoido
Comments
I'd say PASM was fastest Zog is trailing last a bit after Spin. Catalina is quick but big.
Catalina compiles into LMM although I think it's using small "overlays" of PASM.
ImageCraft's C also compiles into LMM. I'm not sure yet whether it's also using small pieces of PASM. I know this was planned, but I don't know whether they implemented it.
PropForth has its own assembler and programs can consist of a mix of Forth and assembly, but it doesn't actually compile Forth into assembly.
Regarding Spin vs. Forth or C. It all depends on how you measure it and what's important. Spin is stack-based which adds a cost for execution. Forth is stack-based as well, but can use the stack in a simpler fashion which can produce more speed. C doesn't need a data stack, just a call stack. Spin has some optimizations for local variable use that can make a big difference in code size, but not much difference in execution speed. The current C implementations are, compared to Spin, space hogs. If speed is more important than code size, C or Forth are much better than Spin. If code size is important, Spin may be better to use overall.
Another question, is compiled PropBasic considerably faster than SPIN?
Humanoido
Yes. As Mike pointed out, PropBASIC compiles directly to PASM.
You obviously like to be able to categorize things and to compare things. This is one of those cases where you're comparing "apples" and "oranges". They're both fruit, but you need to be very explicit about the criteria you're using when you attempt to compare them otherwise. "faster" or "smaller" depends too much on the specifics of the situation to make meaningful comparisons. If you use too general a measure, the comparison is useless in any real way.
Compiled PropBasic would be faster than the equivalent Spin code. On the other hand, there are many things that you could write in Spin, but not in PropBasic, either due to lack of features or (more likely) due to memory constraints when compiling to native Propeller instructions.
Seems like that would offer the best of both worlds - a simple language and the speed of compiled native language run-time executables (instead of being interpreted during run time).
"Code written in the Spin language is interpreted during run time by a cog running the Spin Interpreter while code written in Propeller Assembly is run in its pure form directly by a cog."
The main reason (I believe) for not having a Spin to PASM compiler is that the amount of space available in the cog (496 long words) is too small for anything but hand written / hand optimized code or the output of a high quality code optimizer (which is a major undertaking). In addition, a lot of features used heavily in timing dependent code are very hard to handle in an automated code optimizer (like conditional execution or cog synchronization).
That sounds logical - I figured it must be related to size issues.
Too bad, that approach would take longer to compile but would scream when being executed.
SpinLMM is a Spin interpreter that offers an in-line LMM interface for speedup where necessary.
A threaded LMM that Bill has proposed (similar to pjv's threaded PASM but programs live in HUB). Threaded LMM holds the potential to allow 8*N applications per Propeller (N is arbitrary). No one has reported using it yet, but any language that uses LMM today could potentially implement threaded LMM.
Cheers.
--Steve
I've only had a Propeller for 3 weeks, so I'm not up on all the technology and lingo...
http://forums.parallax.com/showthread.php?t=89640&highlight=Large+Memory+Model
Andy
In summary, LMM is a way to execute PASM instructions by loading one instruction at a time into a COG.
Advantages are 1) faster than Spin running from HUB, 2) allows running programs > COG memory size, 3) allows running programs from external memory depending on the hardware being used.
Drawbacks are 1) slower than PASM - it takes 16 cycles minimum to load an instruction to execute (4 to 5 MIPS @ 80MHz), 2) some instructions must be interpreted (jmp and friends), 3) code is minimum 2x larger than equivalent Spin code depending on language implementation.
Some languages/platforms depend on other loading methods.
--Steve
Thanks for the explanation. Looks like complicated stuff but I can see that it could be very useful in certain situations.
The thread from 2006 was impressive with many knowledgeable participants. I noticed that there seemed to be assembler instructions that are not available in the Propeller Tool IDE. I guess they are "masked" or suppressed for various reasons.
Although I used to write PC assembler programs on IBM/Microsoft DOS computers, I have not programmed code that far "down to the metal".
My career was higher level languages and technologies like COBOL in the 70' and 80's to SQLServer, VB, Visual Studio and web development before I retired.
The microcontroller stuff is a lot more fun - but no related paycheck!