Opinions on a new programming language
Spiral_72
Posts: 791
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,
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,
Comments
-Phil
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...
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.
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.
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!
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.
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.
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.
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.
Its slow and clunky, but its so easy to do.
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.
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!
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
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.
'
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
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
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.
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.
<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.
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.
As far as I am concerned, Java is the same as .net excepting platform issues.