Shop OBEX P1 Docs P2 Docs Learn Events
CANCELLED: CONTEST: C .vs Forth - The Line in the Sand — Parallax Forums

CANCELLED: CONTEST: C .vs Forth - The Line in the Sand

mindrobotsmindrobots Posts: 6,506
edited 2012-12-26 06:40 in Propeller 1
CANCELLED!!!!

We're bickering like a bunch of old hens about this, let's put some code to silicon and see what happens.

A long time ago, when I was fresh out of High School, I was hired to be a programmer for someone's new business venture. He was writing a business application suite (BICARSA/GLAPAR) for the new AS/400....in FORTRAN! Yes, kids, not the right tools for the right job but we got it done, it did work and he went on to sell and support it and make a living. The moral to that story is that you CAN drive screws with a hammer but it's REALLY, REALLY hard to do!!

I've seen a lot of statements in the great C .vs Forth debate like "I tried Forth to write a couple calculation intense programs" or "I can do this in C easily but it's hard to do in Forth"...ok, lots of wrong tool, wrong job approaches to learning and evaluating the languages going on.

Since BOTH languages are supposed to excel at embedded programming and MCU type applications (FFTs, bubble sorts, WEB servers, etc aren't what I'd consider being an embedded MCU application good for the Propeller), let's see some real practical, typical applications in both languages. You guys know what kinds of applications and uses I mean...I can;t ever remember anyone on the Forum asking "I'm trying to integrate my drive servos into my PING collision avoidance routines and my Fibonacci series just isn't right....." or "My bubble sort is interfering with my Zigbee Joystick controller" - Remember, it's a microcontroller...probably not a good choice for a SQL application.

We've had a couple of Forth challenges that have brought out some good close to the hardware control type applications. Good on Forth.

PropGCC has been in beta since June and is certainly stable and usable. I've yet to see anyone really put some hardware into motion yet with PropGCC. I haven't seen any PropGCC powered robots, Christmas displays, Latte milk steamers or much of anything as far as I can recall.

So, now is the time for all good programmers to come to the aid of their language!! For Motherhood, Apple Pie and bragging rights in this never ending debate, I challenge both camps to come up with some real MCU type applications that showcase the Propeller and your choice of either Forth or PropGCC!! Better yet, work in a couple Parallax sensors or something. Let's see some PropGCC BOEbots, How about an S2 driven by Tachyon?

Enough talk, let's see some servos grind and some LEDs blink!!!

If you don't bring money to the table, you can't get in the game! In other words, before you start arguing the merits of one or the other in this thread, you BETTER have a project on the drawing board. No more TALK!

You have until the Spring Equinox......Equal Day, Equal Night, prove they aren't Equal languages for MCU applications.

I'll talk to the prize Genie to see if we can sweeten the pot but for now, just do it for your pride, do it for your ego, do it for your language!!!!

Get crackin' !!!!

P.S. If you REALLY want to be gutsy, call somebody out. I'll do this in this language, can you do it in that language?? (actually, this might get UGLY, so maybe it's a bad idea)
«1

Comments

  • 4x5n4x5n Posts: 745
    edited 2012-12-22 09:12
    I actually liked fortran!! Don't have much interest in using it anymore but it has it's place and in that place it has most other languages beat!

    Personally I'm not happy with the language war going on here and wish it would end. Can we just agreed to not care what language other people are using and just use the one we like?
  • mindrobotsmindrobots Posts: 6,506
    edited 2012-12-22 09:26
    I actually have a Method to my Madness, this time....if we let it unfold a bit, there may be a twist to make it a bit more fun and a learning opportunity for all involved.

    Are you bringing a project to the party?? Choose your tool and hack away! It doesn't even have to be a fancy/difficult/complicated project. Maybe you have a new Emic you want to try out in C or Forth? PINGdar in C or Forth? C Nunchucks at 10 paces?

    Even better, haven't tried PropGCC and SinpleIDE yet? What a perfect opportunity!!
  • David BetzDavid Betz Posts: 14,516
    edited 2012-12-22 09:31
    mindrobots wrote: »
    PropGCC has been in beta since June and is certainly stable and usable. I've yet to see anyone really put some hardware into motion yet with PropGCC. I haven't seen any PropGCC powered robots, Christmas displays, Latte milk steamers or much of anything as far as I can recall.
    The firmware for the Parallax 8x8 RGB LED module was written using PropGCC. There is also a Spin version but I think the module ships with the PropGCC version in EEPROM.
  • mindrobotsmindrobots Posts: 6,506
    edited 2012-12-22 09:48
    Thanks, David! I missed that one.

    Got a project in mind??? :0) (to try in Forth AND PropGCC??)
  • Dave HeinDave Hein Posts: 6,347
    edited 2012-12-22 09:50
    My first submission is the filetest.c program in the progcc/demos directory. It implements simple versions of the Linux ls, cat, echo, cd, mkdir, ch, rm and rmdir commands. When I get a chance I'll clean up the Lerner program, which was written in C, and then ported to Spin using the CSpin utility, which was also written in C. I also have a vi text editor, which was written in C and converted to Spin.
  • David BetzDavid Betz Posts: 14,516
    edited 2012-12-22 10:02
    mindrobots wrote: »
    Thanks, David! I missed that one.

    Got a project in mind??? :0) (to try in Forth AND PropGCC??)
    I'm afraid my current project is getting PropGCC running on P2. I don't think I'll have time for any other porting efforts.
  • mindrobotsmindrobots Posts: 6,506
    edited 2012-12-22 10:07
    Dave,

    I borderline like the filetest.c for this contest since it allows you to get to files on the SD. I'm thinking more of things that make the prop shine as an embedded controller or a more typical micro-controller function. While it's good clean fun to turn the Prop into a microCOMPUTER, that's not what I'm looking for.

    How about log some data in one of those files and then send it someplace with a Zigbee?

    Bang some bits, hook it up to something, sense something, actuate, motivate...drive a relay, blink some lights, talk to a GPS.
  • mindrobotsmindrobots Posts: 6,506
    edited 2012-12-22 10:09
    David Betz wrote: »
    I'm afraid my current project is getting PropGCC running on P2. I don't think I'll have time for any other porting efforts.

    Fair enough. That's something we all want you working on so don't let us distract you!!
  • Heater.Heater. Posts: 21,230
    edited 2012-12-22 13:12
    mindrobots,
    FFTs, bubble sorts, WEB servers, etc aren't what I'd consider being an embedded MCU application good for the Propeller.
    Why on earth not?

    There have been two successful projects described on this forum that have used my FFT code. There is another FFT for the Propeller here: http://propeller.wikispaces.com/FFT. I'm sure it's author would be pleased to hear that not a good application for the propeller.

    Props have been used to serve up web pages. Why not, it's only text. Helps if you have a device handling the TCP/IP stack for you though.

    Plenty of MCU apps will require data to be sorted.

    4x5n,

    I prefer to think of the current "language war" as a "language debate". Such debates are famous for becoming heated but on the positive side there is a lot of useful info to be gleaned. Like how not to try and do something in whichever language.
  • mindrobotsmindrobots Posts: 6,506
    edited 2012-12-22 14:07
    Beyond "because it's my contest", I'll have to ponder a more suitable response.

    :0)
  • KC_RobKC_Rob Posts: 465
    edited 2012-12-22 14:12
    Heater. wrote: »
    I prefer to think of the current "language war" as a "language debate". Such debates are famous for becoming heated but on the positive side there is a lot of useful info to be gleaned. Like how not to try and do something in whichever language.
    Spot on, I think. Much can be learned from these "debates" and they are part and parcel to the evolution of software techniques and tools. That they also sometimes unfortunately become a little heated isn't too large a price to pay.
  • jazzedjazzed Posts: 11,803
    edited 2012-12-22 14:45
    Hi Rick,

    Not really sure what you're after, but I've worked on many projects with Propeller-GCC.

    Here is a PropBOE BOT project that uses a ping to do obstacle avoidance.
    Propeller is capable of doing much more, but a BOT is a common Parallax MCU example.

    If you want more than this you'll just have to take a number :)
  • SRLMSRLM Posts: 5,045
    edited 2012-12-22 14:52
    How about C++ instead of C?
  • MJBMJB Posts: 1,235
    edited 2012-12-22 16:58
    Heater. wrote: »
    There have been two successful projects described on this forum that have used my FFT code. There is another FFT for the Propeller here: http://propeller.wikispaces.com/FFT.

    In all this language discussions is miss the solution focus.
    If I needed a FFT on Prop and there is a PASM module, that can run in a cog
    I would not rewrite it in FORTH but rather try to find a way to USE it.
    PASM is faster anyhow and FFT can use the speed.
    So why all this discussion ...
    My question would be - how can I reuse this PASM module from TACHYON?
    And actually - do you have an idea how to use your FFT as such a module HEATER?
  • KeithEKeithE Posts: 957
    edited 2012-12-22 17:20
    And say that I wanted a prime factor FFT. It would be nice to run one of the available code generators which is going to write out C code if I remember correctly. I don't know how suitable that code would be for the prop gcc, but it would be nice to be able to use it with either C or Forth. Simulink can also write out code. I know that it can spit out Verilog RTL which can be massaged into something usable, but am not aware of all of its code generation capabilities.
  • Heater.Heater. Posts: 21,230
    edited 2012-12-22 17:31
    MJB,

    You are right of course, no one in his right mind would want to use a pure Forth FFT on the Propeller and probably not anywhere else. But this is me we are talking about...err no, what I mean is, I should never have selected the FFT as an exercise for my learning some Forth, it has just lead to people assuming I would actually be something I would want to use for real. It's only an exercise.

    CarlJacobs made a version of the fft_bench in Forth that has the inner loop in assembler here: http://forums.parallax.com/showthread.php?129972-fft_bench-An-MCU-benchmark-using-a-simple-FFT-algorithm-in-Spin-C-and-...&p=1019479&viewfull=1#post1019479

    The PASM part of heater_fft can easily be adapted for use from any language. Basically just throw away the Spin parts. If you can get the bfly routine started in a COG you just pass it commands and parameters through it's mail box which itself passed in via a pointer in PAR.

    That means that you are probably needing to tweak the PASM so that the assemblers in Forth can handle it.

    I was going to do this for use from C but then the GCC gurus managed to compile the C version such that the inner loops get compiled to raw PASM running in a COG (The FCACHE mechanism). It's nearly as fast as the hand coded PASM.
  • MicksterMickster Posts: 2,694
    edited 2012-12-23 07:12
    If the contest is going to be judged on execution speed, code size and READABILITY...Let's include PropBASIC(?)....I believe it would come out on top...shame it gets very little recognition.

    Mickster
  • mindrobotsmindrobots Posts: 6,506
    edited 2012-12-23 08:36
    Contest Cancelled
    It was ill conceived and ill received.

    Sorry I wasted time and bandwidth.
  • altosackaltosack Posts: 132
    edited 2012-12-23 10:49
    Cancelled ?

    Well, dang, that means my next propGCC project will have to stand on its own merits, and not on how effectively it crushes those heathens that have the audacity to think they can program (if you want to call it that) in anything else ! (And I just might have to use conventional motivational techniques for completing it.)

    Siiiggghhhhhh.
  • jazzedjazzed Posts: 11,803
    edited 2012-12-23 13:06
    SRLM wrote: »
    How about C++ instead of C?

    Just following up ....

    @SLRM (Cody). I don't have time to do a full implementation of the bot program in C++, but I've attached some classes for you.

    Thanks,
    --Steve
  • mindrobotsmindrobots Posts: 6,506
    edited 2012-12-23 13:11
    Steve,

    I was guessing this to mean the project Cody is working on is in C++ and not C.

    Either way, your 'bot code is welcome and sounds like the perfect thing to browse through while watch the Browns lose.......
  • Christof Eb.Christof Eb. Posts: 1,201
    edited 2012-12-23 13:12
    Hi,
    the idea of a contest, to see which languages are used, is very interesting, I think. I have been thinking about a specific task, that needs not much hardware, perhaps only what is on the demoboard. It would be interesting to see different ways to solve the problem.
    A very open challenge is always running and to be seen in the "projects" forum. Forth and C are both still not very widely used there. . .
    Christof
  • SRLMSRLM Posts: 5,045
    edited 2012-12-23 13:21
    jazzed wrote: »
    Just following up ....

    @SLRM I don't have time to do a full implementation of the bot program in C++, but I've attached some classes for you.

    Thanks,
    --Steve

    My question was directed at the OP for the contest, since I'm working on a project that uses PropGCC C++ for the code base. Still, thanks for sharing the BoeBot code. That's one of my side projects once I tired of working on my job project. I'll take a look at the code that you posted.
  • jazzedjazzed Posts: 11,803
    edited 2012-12-23 13:44
    Sorry, it wasn't clear. The example does use C though as "encapsulated" code.
  • MicksterMickster Posts: 2,694
    edited 2012-12-23 17:29
    I for one am tired of the C and Forth hype so hey....let us REALLY put our code where our mouth is ....I am new to the Prop but I would like to see some equivalent "better" version of code that I created in PropBASIC...anyone up for the challenge? (specifically encoder quadrature decode).

    Mickster.
  • Dave HeinDave Hein Posts: 6,347
    edited 2012-12-24 05:56
    mindrobots wrote: »
    Contest Cancelled
    It was ill conceived and ill received.
    Ill conceived? Maybe. Ill received? Only by the Forth programmers. We just need to understand that Forth is not a high level language. It's more like a macro assembler for a stack-based machine. It's main purpose is to bootstrap a development system on CPUs that have no development support, except for an assembler. Once there are high level languages available for a CPU there's not much reason to use Forth on that CPU.
  • Martin_HMartin_H Posts: 4,051
    edited 2012-12-24 06:37
    Even without a contest, it would be interesting to see Forth examples for common embedded problems. Things like a servo controller, DC motor PWM, RC time, I2C. I can't write any of these in Forth so it would be good for cutting and pasting. I've heard that back in the 80's some hobby robots used Forth. It would be neat to see their vocabularies ported to PropForth so modern robots could run them.

    One thing that PBasic, Spin on the Propeller, and C++ on the Arduino have going for them is a healthy amount of sample code. You know the old saying "good programmers write code, great programmers reuse it".
  • Peter JakackiPeter Jakacki Posts: 10,193
    edited 2012-12-24 07:27
    Martin_H wrote: »
    Even without a contest, it would be interesting to see Forth examples for common embedded problems. Things like a servo controller, DC motor PWM, RC time, I2C. I can't write any of these in Forth so it would be good for cutting and pasting. I've heard that back in the 80's some hobby robots used Forth. It would be neat to see their vocabularies ported to PropForth so modern robots could run them.

    One thing that PBasic, Spin on the Propeller, and C++ on the Arduino have going for them is a healthy amount of sample code. You know the old saying "good programmers write code, great programmers reuse it".
    I think that many of these examples that you are asking for have already been posted and certainly there are many more covered in my Introductions page and in the links at the end of that of which EXTEND.fth has a 5Khz 8 channel PWM. I2C and EEPROM routines etc. The list goes on...
  • Martin_HMartin_H Posts: 4,051
    edited 2012-12-24 08:31
    I think that many of these examples that you are asking for have already been posted and certainly there are many more covered in my Introductions page and in the links at the end of that of which EXTEND.fth has a 5Khz 8 channel PWM. I2C and EEPROM routines etc. The list goes on...

    Thanks, prof braino sent me a link to some samples.
  • koehlerkoehler Posts: 598
    edited 2012-12-24 18:16
    As a non-Forth user since the 80-81 when I first heard about it, I've always been interested in it..
    All the discussion here has given me an incentive to give it a shot with the prop, since that is the area where it should shine, down amongst the nut and bolts, side-by-side with assembler.

    Its actually a little annoyiing that some of the experts here seem to be more interested in bashing Forth, or calling it a dud as they try to learn the language and program a relatively complex transform.
    And relatively complex is probably true for a good percentage of actual programmers.
    And it only gets better when they try and call C a high-level language.
    C has always been only a couple steps up from assembler, and high level, yeah maybe. One has to bend reality a fair bit to really call it high-level today.
    C++/C#, now those are generally considered high-level.

    FWIW, these folks have several Forth FFT's, amongst quite a bit of other code: http://ccreweb.org/software/kforth/kforth4.html

    I gotta wonder if the Forth-bashing isn't more about thread envy that the Forth threads are seeing.

    Forth is a very odd critter, more a round peg in a squares hole world of programming languages.
    Jumping in to 'correct misconceptions' don't seem to me to be being done for mine or anyone elses benefit as much as to snipe.

    Being very good at programming and being professional are not mutually inclusive.
Sign In or Register to comment.