Shop OBEX P1 Docs P2 Docs Learn Events
Opinions on a new programming language — Parallax Forums

Opinions on a new programming language

Spiral_72Spiral_72 Posts: 791
edited 2012-05-02 11:29 in General Discussion
There's no better person to ask than y'all!

I would consider myself the grand master at programming in...... DOS

Now that you have stopped laughing, tonight I've finally gotten fed up. I wanted to write a simple program to pull data from my BS2 to my PC via RS232. In days past, this was no problem, but Windows 7 doesn't let me have access to the COM port (COM3).... whatever that means, neither will it let me call a graphics screen directly, neither will it..... you get the idea.


So, kicking and screaming into the 21st century. I need to learn a Windows compatible programming language. Presently I want to pull data off the PING via RS232 through the STAMP and display it graphically on the screen. I have many other ideas similar to this one, but all along the same lines: The PC communicating with the microcontroller.

I need basic graphics, no high end 3D, speed is nice, access to ports, etc.
What is your opinion and why?
I know BASIC, assembly, and C. Should I use Visual Basic? Python? or?


Thank you,
«134

Comments

  • jazzedjazzed Posts: 11,803
    edited 2011-02-13 20:47
    Visual C# is a wonderful combination of Java, C, C++, and elements of Visual Basic.
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2011-02-13 21:18
    For maximum utility and portability, I use Perl. There's definitely a learning curve, though, that some don't have the patience for. I guess, in that case, Python might be a good second choice. I wouldn't waste a minute with OS-dependent languages, though, like the Visual-x's.

    -Phil
  • Kevin WoodKevin Wood Posts: 1,266
    edited 2011-02-13 21:58
    My vote here is Python, since it's fairly easy to learn, many good resources available, and very cross platform. On Windows, I suggest using ActivePython from ActiveState, which you can download for free. I suggest getting at least version 2.6, for their package manager, and using the 32-bit version, which has better support for win32.

    I'm attaching a basic sample of code that works with my mbed, which uses com8. If I drop the file (renamed to robot.py) into C:\Python27\Lib (ActivePython 2.7), I can import the library by opening a Python shell and typing import robot (note: you need to be connected to your serial device, or add error handling...).

    After importing the library, I can interact with my mbed "robot" (just uses the leds to simulate motion) by typing stuff like...
    >>> r = robot
    >>> r.connect()
    >>> r.fwd()
    >>> r.rev()
    >>> r.stop()
    >>> r.disconnect()
    

    This is just a simple example, but there's enough there to get you going with a BS2. Wire up a couple of leds, and write some pbasic to receive a few letters to turn the leds on/off. Just make sure to use the correct COM# in the Python file. From there you can add all the fancy stuff, like error handling, or passing the com# as a cmdline parameter, etc. Then you can look into the various GUI toolkits available for Python.

    If you need more, take a look at the O'Reilly books on Python. They're pretty good.

    BTW, the Python code & concepts should work with any of the Parallax micros, and with tweaks (right com port name...), should work on Windows, Mac, Linux, Solaris, FreeBSD, etc.
  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2011-02-13 22:19
    There are some geniuses that seem to acquire each and every progaming language -- I am not one of them.

    It is just too easy to get overrun by multiple learning curves and a parade of updates in computer languages. My goal is utility and to learn the fewest that will serve me wel.

    Having said that, Python is just about the best of the new languages for all and everything on a mainstream computer. On the other hand, C and its derivatives are academically exploited for published examples more than any other language, so for reading one just about must have a knowledge of at least C,

    Microcontroller are a completely different world for utility purposes and Parallax has proven that PBasic or Spin are quite adequate for deploying them. With a smattering of Assembly language, these languages work well with the tiny computers, but one dosen't get into vast OSes, huge storage, and sophisticated sorting.

    Python is your best better for a good start with a lot of fun.
  • jazzedjazzed Posts: 11,803
    edited 2011-02-13 22:23
    Visual Basic is a beginner language in many colleges these days. Visual anything is very easy to learn. Learning curve is much steeper for Perl than Visual Basic or C#.

    I really like Perl because it is very C like and it has a built-in hash type. Perl stands for Practical Extraction and Report Language. Perl is more of a string/expression parser that is also a programming language. It is nice that it offers quick integration with many libraries, but it carries it's own baggage like any other "interpreted" language. The funny thing about Perl is that it should really be spelled PREL for Practical Regular Expression Language ... that is if you think regular expressions are regular or practical. RegEx is undoubtedly a powerful tool if you already know it. Same goes for SED or anything else if you already know it.

    Python is too different to bother with for me, but I can see where some would like it. I bought a book, browsed through it, and decided my language tool box did not need to be "enhanced" by Python. If someone pays me to learn Python, no problem.

    IMHO, If you like BASIC, Visual Basic is best and if you like C but not Java, Visual C++ is best. If you like C and Java, Visual C# is best. If you like Java, well Java is best.

    If you like a new challenge, Perl or Python may be best. Anything but Forth!
  • schillschill Posts: 741
    edited 2011-02-14 05:48
    The three on my list would be (in no particular order): Processing, C#, Python.

    Processing (www.processing.org) is one of those "artist-oriented" languages but it works well for graphics-based programs. It's a bit lacking in user interface generation. It's used to provide the PC end of a lot of Arduino-based projects.

    Others have discusses C# and Python.
  • ctwardellctwardell Posts: 1,716
    edited 2011-02-14 07:54
    Let's have some fun with this...

    This one of those areas where there is a lot of opinion and prejudice, and in most cases the answer is truely up to personal preference.

    So let me propose this...how about Spiral_72 post a somewhat more specific spec, and the proponents of various languages can come up with a solution in their language of choice.

    So far we have this to go on:

    "Presently I want to pull data off the PING via RS232 through the STAMP and display it graphically on the screen."

    "I have many other ideas similar to this one, but all along the same lines: The PC communicating with the microcontroller."

    "I need basic graphics, no high end 3D, speed is nice, access to ports, etc."

    Here is some additional info that we need:

    1) Will the BS2 handle pinging at some interval and just send out serial data or will it ping via some serial command?

    2) How will the serial data represent the distance pinged?

    3) How is the ping data to be displayed, some type of running graph?

    The spec doesn't need to be the actual project that you want to do, obviously you want to do that yourself, but it should be representative of the various types of tasks that you want to perform.

    My goal here isn't to point out that one language is better than the other, but to have a reference set of solutions to a specific problem so people can review those solutions to see what works for them.

    If this works well we could expand this to solutions to other sample projects in the future.

    My personal area of comfort is in the Windows VBA, VB6, VB.Net and to some extent C# realm, but I would like to gain more exposure to Python and Perl.

    Just a thought...

    C.W.
  • Erik FriesenErik Friesen Posts: 1,071
    edited 2011-02-14 09:06
    If you know C already, go with visual c#, there are many examples available, and it is easy to make the switch. I understand Phil's feelings about visual x's, but... The Visual studio IDE is good, once you get used to it you will be unhappy with others, especially in regards to intellisense. If you intend to do long term development for multi platform, than that is good, however, if not, it really is not worth the time investment, IMO.
  • Spiral_72Spiral_72 Posts: 791
    edited 2011-02-14 09:07
    Wow! Y'all didn't hold back :)

    ctwardell: Thank you sir. I don't know that there is a right answer to this and I don't have "Specs" for what I want to do. The example given was just whats on the my mind at the moment. The point of this was for me to see what a bunch of guys (girls too?) with microcontrollers program their PC with..... not learn a new language to do one task. I'm just so far behind now, my programming knowledge of years past doesn't really work for today's operating systems.


    Alright, I'll tally this up and decide after some reading..... if anyone else has an opinion, lemme know.


    Thank you all..... very much.
  • Spiral_72Spiral_72 Posts: 791
    edited 2011-02-14 09:09
    For maximum utility and portability, I use Perl. There's definitely a learning curve, though, that some don't have the patience for. I guess, in that case, Python might be a good second choice. I wouldn't waste a minute with OS-dependent languages, though, like the Visual-x's.

    -Phil

    That's a very good point I haven't considered.
  • schillschill Posts: 741
    edited 2011-02-14 09:14
    For maximum utility and portability, I use Perl. There's definitely a learning curve, though, that some don't have the patience for. I guess, in that case, Python might be a good second choice. I wouldn't waste a minute with OS-dependent languages, though, like the Visual-x's.
    Spiral_72 wrote: »
    That's a very good point I haven't considered.

    I like the idea of working under multiple OSs mainly for giving what I've done to other people. I use Windows almost exclusively so if it's for personal use I don't worry about it. But multiple OS is almost always a better choice.

    Python and SPIN both use indenting to indicate loops, etc. so if you are going to work with the Prop you will see some (minor) similarity between the two.

    Processing is available for Windows, Linux, and Mac. It's java-based.
  • PliersPliers Posts: 280
    edited 2011-02-14 09:56
    All my windows interfacing is done with VB.net
    Its slow and clunky, but its so easy to do.
  • Spiral_72Spiral_72 Posts: 791
    edited 2011-02-14 10:21
    ctwardell wrote: »
    Let's have some fun with this...
    Here is some additional info that we need:

    1) Will the BS2 handle pinging at some interval and just send out serial data or will it ping via some serial command?
    2) How will the serial data represent the distance pinged?
    3) How is the ping data to be displayed, some type of running graph?

    C.W.

    For this particular project, all communication will be through RS232. It's actually a Parallax USB to serial converter on my computer, because that is the only option I have for I/O.
    I suspect, the BS2 will have routines stored in it that I write. The main loop will listen to serial data and wait for a command. The main loop interprets the command and performs the requested function, returning results if necessary.
    #1 The BS would get the PC's request to PING across some sweep (maybe variable) say 60 degrees. The BS sweeps a PING mounted servo to the start angle and sweeps the requested degrees. I'd probably write the data to an array and transmit it back once the sweep is done, but that's not decided. The PING is pretty slow, so I may have time to send the data real-time.
    #2 The serial data would be numeric data I think. I don't remember off hand if the PING distance is a byte or word. But it would be something like a 0-127 DEC angle with the high bit HIGH to indicate an angle and the distance.... times "n" degrees.
    #3 It will initially be a circle plot (or section of a) on the screen with a point at whatever angle the reported distance was from the center. Later? I don't know.... it depends how well all this stuff works. I suspect it will always be 2D though.

    It's a sonar really. It's a learning experience and may make it to the Bot depending on if I can get my laser version working or not.

    Regardless, serial data about the robot's sensors will be sent back to the PC for the decision making. I don't know how much I can pack into 9600 baud, but we'll see.


    There WILL be some algorithms to filter/calculate the numbers..... but the PC is good at stuff like that. Most microcontrollers are not due to limited resources.
  • Spiral_72Spiral_72 Posts: 791
    edited 2011-02-14 10:29
    schill wrote: »
    Python and SPIN both use indenting to indicate loops, etc. so if you are going to work with the Prop you will see some (minor) similarity between the two.

    Really?? That's good to know. I "WILL" use the Prop soon. I have it in my shopping cart waiting to hit the "Order" button. I can't wait :) Maybe another couple weeks and I'll order!
  • vaclav_salvaclav_sal Posts: 451
    edited 2011-02-14 10:52
    1.For controller applications, communicating and data processing my vote is C.
    2.Visual Basic does what the title states – visual renditions of whatever. It does communication and data processing as a afterthought.
    3.Anything invented in Redmond will be soon replaced with something else made there.
    Vaclav
  • Bobb FwedBobb Fwed Posts: 1,119
    edited 2011-02-14 15:28
    I use Visual C#. It does everything you would need for windows based programming, and for the most part you don't have to code the visual stuff. There are lots of handy protocols included in the standard IDE, and lots of support from the general public.

    Visual Basic and Visual C# are very similar. A bunch of web sites will have code snippets for both. Functionality is about the same, it's really just the syntax and programming style that is different. As said before, C# is a combination of other languages like C and C++, but without the needed memory management and other such things. Because it is like C, it has some syntax shared with SPIN.
  • SSteveSSteve Posts: 808
    edited 2011-02-14 16:24
    I agree with Phil that you should avoid OS-specific languages. Personally I have had a lot of fun working with Ruby. I love the language's design. I can't imagine taking up Perl except on a dare.
  • HumanoidoHumanoido Posts: 5,770
    edited 2011-02-14 16:42
    Don't settle for one language. I like writing programs with multiple languages. I wrote AI programs in this fashion for Japanese industrial robots and American 25-ton robots. Propeller can handle multiple languages. See for yourself here.
  • $WMc%$WMc% Posts: 1,884
    edited 2011-02-14 17:25
    Spiral_72
    '
    Take a look at Just BASIC v1.01.
    '
    Its really easy to learn,It will open up COM 3 on your USB port, And GUIs are really easy to make.
    '
    Lots of examples
    '
    Its also FREE.and you can upgrade to Liberty BASIC v4.03 for under $50.00
    '
    They have a pretty good forum too.
    '
    Just adding to the list. Hope this helps.
    '
    www.JustBasic.com
  • Martin_HMartin_H Posts: 4,051
    edited 2011-02-14 19:06
    Python and Ruby are popular dynamic languages. I've worked with Ruby and it is not bad. I've avoided Python because syntactically meaningful white space gives me the heebie jeebies. I've recently started learning Spin and I'm not a fan of it there either.

    Java is a good language, but not for GUI clients. It is also starting to show its age. However, but Groovy is likely going to be its successor. Groovy is basically a dynamic language version of Java.

    I know Phil likes PERL, but I can't send implicit variables ($_ I'm looking at you) or that every statement can be a conditional construct, so I am not a fan of it.

    I am paid to program in C#, otherwise I wouldn't bother learning it or any other MS specific language.
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2011-02-14 19:13
    Martin, you use implicit variables all the time when you speak or write. They're called "pronouns". :)

    -Phil
  • RavenkallenRavenkallen Posts: 1,057
    edited 2011-02-14 20:48
    I am also trying to begin learning PC programming and i have chosen Python... I didn't know much about it and yet i managed to get it to talk with my Propeller without much work. You can make GUI's, webpages, games, widgets and you can even use the shell(I think that is what it is called) as a fancy calculator... There is also a TON of books out there that teach Python and make it even easier to understand. Plus, you can go online and find some excellent tutorials...
  • Dr_AculaDr_Acula Posts: 5,484
    edited 2011-02-15 00:37
    I'm going to put in a vote for .net. Several reasons: The C and Basic parts seem to be merging into a common language. The autocomplete makes it much harder to make syntax errors. Huge libraries of code exist so writing things like a serial port driver are more a matter of grabbing code from the internet rather than writing code. And the code is free.
  • Heater.Heater. Posts: 21,230
    edited 2011-02-15 02:37
    Dr_A,

    On the down side,

    0) As far as I know .net is not a language. But rather:"The .NET Framework is Microsoft's application development platform that enables developers to easily create Windows applications, web applications, and web services using a myriad of different programming languages, and without having to worry about low-level details like memory management and processor-specific instructions."

    1) .net only works on Windows. No good if you want to share the fruits of your labors with a wide audience of open source hackers. Why would anyone want to contribute to a closed platform over which they have no control?

    2) "The C and Basic parts seem to be merging into a common language" - What?!. If I want to write the most portable (cross-platform) code in the world I do it in C. Bodging standard C up to make it look like BASIC would wreck that idea. I though recently, Dr_A, you had become enamored with the ease with which C code can be reused on all kinds of different platforms.

    3) Auto complete is available in other languages/IDEs

    4) "Huge libraries of code exist so writing things like a serial port driver are more a matter of grabbing code from the internet rather than writing code." - That is true of many other languages. C probably has the biggest choice of libs and free opensource code of any other language. Look at all the goodies that you can get for Perl, Python, Java etc etc.

    5) "And the code is free." - Perhaps monetarily. I don't want to have to lock myself into Windows to use it though.

    P.S. Yes I know C# runs under mono on Linux etc. But that leaves the vast array of Windows specific stuff that does not.
  • Martin_HMartin_H Posts: 4,051
    edited 2011-02-15 05:01
    By merging, they are allowing cross language interop and access calls to the common language runtime. So C# can call VB or managed C++, and any language can make the same calls to the .Net framework. So the languages remain syntactically distinct.

    As an aside, the ability for cross language interop is as old as the hills, and is only new in the MS world. Back in the 1980's I was writing Pascal calling FORTRAN math libraries on an IBM 3081D. I later did the same thing between C and BLISS on VAX/VMS.
  • schillschill Posts: 741
    edited 2011-02-15 06:19
    Martin_H wrote: »
    As an aside, the ability for cross language interop is as old as the hills, and is only new in the MS world. Back in the 1980's I was writing Pascal calling FORTRAN math libraries on an IBM 3081D. I later did the same thing between C and BLISS on VAX/VMS.

    It's not all that new in the MS world. Also back in the 80s, I wrote libraries (DLLs) in Turbo Pascal (or was it Borland Pascal by then?) to call from Visual Basic.
  • ctwardellctwardell Posts: 1,716
    edited 2011-02-15 06:33
    ctwardell wrote: »
    This one of those areas where there is a lot of opinion and prejudice...

    <soapbox>

    Well, I wasn't wrong with my previous statement.

    One of the primary hurdles with the python, perl, ruby, etc. suggestions is they are incomplete suggestions as far as I am concerned.

    The OP request was for a language that would allow for a GUI, the above mentioned languages by themselves do not include that functionality.

    I would like to see some more complete suggestions for those languages which would include info on suggested GUI libraries and if serial support requires an additional library then that should be included as well.

    I've looked at this some myself and it seems picking a GUI library is just as fraught with opinionated stone throwing as picking the language in the first place.

    </soapbox>

    A suggestion I'll throw out there at this point for my original thought of creating examples in various languages is that we use character based serial for coms with the BS2 so that the target can be easily operated and debugged from a simple terminal application. I know that is a bit of a change from the OP's more refined spec, hopefully he will agree to that change.

    C.W.
  • Martin_HMartin_H Posts: 4,051
    edited 2011-02-15 08:12
    @schill, true but either you or the compiler had to declare the calling standard (stdcall or cdecl) and hope your data types aligned. For example C strings are null terminated while VB's are length prefixed. Unless the C programmer wrote their call expecting a BSTR it wouldn't work, but if they did then C couldn't call it natively. I'm talking about an it just works kind of interop.

    COM was their first attempt at standard calling convention, but was really awkward to use and far from transparent.

    With .Net MS standardized its calling convention and data types, so things are much more transparent. Well until you step outside the .Net walled garden and call legacy unmanaged code.
  • potatoheadpotatohead Posts: 10,261
    edited 2011-02-15 08:23
    Well, there is a case for just continuing with DOS. Just put it in a virtual machine, while you explore other options.
  • Erik FriesenErik Friesen Posts: 1,071
    edited 2011-02-15 08:44
    I recently was given the task to choose whichever programming language I wished to create a gui and all that goes with it. After spending some time playing with c++, c#, vb, and another basic I can't remember, I went with c#. Reasons? It seemed to me that as a single developer, I would spend the least amount of time with it.

    As far as I am concerned, Java is the same as .net excepting platform issues.
Sign In or Register to comment.