Sign in to follow this  
Followers 0
HiGhVoLtAgEgUrU

C++

39 posts in this topic

Hey guys how important is it learn C++, or C Sharp along with PLC's. Is it better to learn one first and then the other. And in which ways it helps in our industry. I know C++ has lots of use. I know C little bit. But that' was 7 years ago. I took one class at college. I kinda forgot now.

Share this post


Link to post
Share on other sites
How important is C++ is like asking an auto mechanic how important is it to know how to service Mercedes Benz Automobiles. If he is working at a Benz garage it is very imporant, at a Ford garage not so much. It will not be a detriment for you to learn C++ as learning any structured language is always a help. If you are in OEm Equipment work or Heavy Data Collection and HMI work then C++ will probably be more useful than if youa re a PLC machine operations guy. really need to understand your plan and target niche in Automation Industry to give a valid evaluation as to the usefullness of C++.

Share this post


Link to post
Share on other sites
You'll learn a thing or two listening to Bob! Software programming experience is helpful, but not usually directly applicable - you'll know if you need to use it. If you do go down the embedded software route, C will likely be your language, not C++ and certainly not C#. C Sharp is one language in the Microsoft .NET suite that compiles code to an intermediate language (bytecode) to run on a virtual machine (like Java). There are a lot of advantages and reasons to go this route, but not really for embedded devices. The language could be relevant to create an HMI or HMI development suite, but then you should learn software engineering techniques rather than (or in addition to) programming. At that point you're way outside "PLCs".

Share this post


Link to post
Share on other sites
I find that VB is the most useful, a lot of the HMI's use VB like scripting. I took an evening class on VB6 many years ago, it was only marginally helpful, most of the class was centered on DB stuff. I think I got the most use from looking at existing Code on an HMI that a VB guru worked on. I support an older unix based DCS and on that platform plain old "C" is king. Since I support both unix and windoze machines, I've been dabbling in PERL scripting, mostly because it can be run on both platforms. (easily)

Share this post


Link to post
Share on other sites
+1. Skill at good program design and data strutcturing are good skills to develop. A programmer with those skills can usually quickly pick up any particular language. Although a course might use C as the language for programming, focus on learning program design techniques. The same design techniques you use in a C program to run on a PC can be applied to a ladder program on a PLC, even though the applied technoloy is very different.

Share this post


Link to post
Share on other sites
Any significant application written to run on a PC will be done in C++, maybe C#. C# is easier to learn but also can't do things that C++ can do. Embedded programming is mostly done in C or maybe assembly language on a 8 bit micro. C#, C++ and Java are not used in serious embedded project because the garbage collection can interfere with real time response. C#, C++ and Java allocate and de allocate classes on a heap and this takes time. C is lean an mean. If you want to write code the runs on a PC I would learn C# or perhaps Java. BTW, both C# and Java generate intermediate code that can be compiled just in time during execution. http://en.wikipedia.org/wiki/Just-in-time_compilation

Share this post


Link to post
Share on other sites
The VB statement has been true in the last decade for HMIs, but is losing momentum. VBA has been included because HMI packages were all written for Windows and MS made this development relatively easy. The "HMI flavor" VB has been easy enough to learn, but leaves a lot to be desired in terms of capabilities. Wonderware has their home grown thing, Citect uses CiCode, Inductive Automation uses Python, Intellution and Rockwell still support VBA. As far as the future goes, Microsoft is pushing .NET based scripting, which is syntactically similar to, but incompatible with the flavor of VBA we're referring to. It really makes sense to go for a platform independent and PC industry standard language. MS has a history of releasing new versions/service packs that are backward incompatible with their customer base. My personal preference is Python, PHP, or Ruby (only dabbled with). IMO Perl belongs in the textbooks with LISP and Prolog. The only thing worse are the home grown languages that HMI vendors invent. Try finding a book on Cicode. You won't, but a Pascal book would get you started. +2 with Alaric on structured languages. Edited by Nathan

Share this post


Link to post
Share on other sites
Hey Nathan, back in the day, I did quite a bit of LISP programming. LISP= Lost In Senseless Parenthesis. I remember almost never getting the correct amount of parenthesis the first go. Hey Nathan, back in the day, I did quite a bit of LISP programming. LISP= Lost In Senseless Parenthesis. I remember almost never getting the correct amount of parenthesis the first go. The DCS, I support has it's own structured text, very similar to Pascal, with a little C thrown it, it's very intuitive, and easy to learn.

Share this post


Link to post
Share on other sites
Lol, I know the feeling. It made me hate lists. Good stuff with the DCS - that's how it should be.

Share this post


Link to post
Share on other sites
How do you debug python. I am writing a hydraulic simulator. One of my final choices was python but I chose java instead because it is faster, has a debuger, has more books, can be run as an applet. Python is a better basic but VB has a better debugger.

Share this post


Link to post
Share on other sites
For general purpose programming/application use, I think Java is way better - but the learning curve is much steeper for a "non-programmer". This should especially be true with all the cool things that Java 6 update 10 brings to the table. Python is a great way to learn to program from scratch. For more serious python development, check out pydev. It runs in Eclipse. I haven't had the need to use it.

Share this post


Link to post
Share on other sites
I saved the pydev link, thanks. Last July I made a choice between using python, java or C with wxwidgets. http://www.wxwidgets.org/ I picked java for the reasons above and the ability to 'deploy' java easier. PCs people have java already installed. Few PCs have the python or wxwidgets libraries installed. I wanted a language that I can develop and run on any system. The above would do that. However, I liked the look and feed capabilities of java. Java apps on a Mac looks like a Mac app and java apps on a PC look like a Windows app etc. Yes, java has a steep learning curve but I think it is because of the size of the programs one can write. Applets are easy because they are small by nature. Big programs and exponentially more problems and details that need to be worked out. I think it is more the size of the program rather than the language. I would have the same issues with python. Python and java are just tools. I am sure the programming techniques are the same. For what you do pythons makes sense because you are just using it for script support. I recommend that others look at python.

Share this post


Link to post
Share on other sites
No problem. I prefer Java as well for applications that you want others to run because Java Web Start and Applets are so much more ubiquitious than Python scripts (like you said, everyone already has a JRE installed or a web browser, and non-programmers aren't going to want to install a Python interpreter/IDE). Yes they are "both tools" and the techniques a professional programmer would use are similar, but the complexity levels to begin are quite different. Compare getting a typewriter set up to crayons. I'm not knocking either - I like both tools.

Share this post


Link to post
Share on other sites
Python debugging is a little funky. But take a look at Komodo for a full blown IDE. They also give away a stripped down version of their editting/developing environment. Also, if you need to distribute a Python program, you can simply "compile" it because the run time environment is small enough. This is akin to JAR's...the Python packagers out there simply bundle the interpreter and the libraries that were used into a compressed zip file and make it self-executing. In practice it runs faster than simply starting the Java interpreter. In addition, there's Jython which is a Python interpreter written in Java. You can use Java classes and do Java things with it including running it as either applet or stand-alone. In terms of PC languages, I prefer three of them: Python, C, and Java, pretty much in that order. Python gets rid of types. Data has types, not variables. Everything is simple and intuitive. Creating objects/classes is trivially easy. Plus, it is minimalist in terms of typing while not becoming totally cryptic unlike APL or say SQL. The downside is that it's interpreted and that since it's not mainstream, interfacing to other systems can sometimes be a real pain in the rear. C is somewhat like writing in assembly language (the first language I learned after BASIC decades ago), except that it takes all the pain and suffering away. You can do almost anything with it very close to machine-level. It makes interfacing to almost everything except some of the uglier "object systems" (COM/DCOM, CORBA, .NET, etc.) trivially easy to do. And because of it's nature, other than pure assembly language, it is still the reigning speed champion. Finally, there's Java. I hated Java for decades. I only warmed up to it in the past couple years. When it first came out, it was just a great way to make web pages run really slow, crash a lot, and do something utterly useless like put a clock on the screen or try to do early forms of web page "phishing" attacks. Somebody took C++, cleaned up the non-object oriented things about it, and then sent it over to the language police for a thorough screw-up. The result was called Java. It takes an obscene startup time, it is very typist friendly (if you love to type), insists on typing and casting everything (it's a "feature"), and despite being much more documented, tends to be difficult to discern how to use and tends to force an experimental approach to making things work. But, the web capabilities are not to be doubted and it runs on almost anything. In answer to the original question...I echo the rest of the comments. VBA used to be the most useful thing you could learn beyond PLC's, but it's usefulness is fading quickly. Not sure what the next generation will bring. Hopefully not dotNET. But at this point who knows. Edited by paulengr

Share this post


Link to post
Share on other sites
Paul - I agree with you for the most part. A few points to clarify: 1. Jython does dynamic compilation to Java Bytecode - this is much faster than an interpreter. I remember debating with Pete on advantages over runtime (JIT) versus static compilation. I wouldn't say that it is faster in every case, but it does offer compelling advantages. Also Jython can access pretty much everything you can in Java. 2. I'll assume that you're joking and exaggerating about Java - since I agree with you in sentiment, that Java is a cool platform that sucked at first, but would argue that some of your details are jacked up ("decades", "clean up C++ to make Java") and all the rest are so dead on. 3. Check out the details for Java 6 release 10. It is recognized that the last major weaknesses of the Java platform is initial load time - the team has taken action to significantly mitigate that (Kernel, Dev toolkit, new browser plugins). They also include a cool new Look and Feel and are finally taking advantage of Windows graphics APIs. The argument had been "it has to run on everything" - fine, but why not optimize to use hardware acceleration for your biggest customer - and Linux support could follow. 4. I agree with you on the future of VBA and .NET. With the notable exception of Powershell for automating Windows Server system administration, I hope the two totally disappear as scripting/programming languages for non-software developers.

Share this post


Link to post
Share on other sites
The information about the latest Java release was interesting. Also, there is is new release of Python 2.6. I updated that too. I just don't have a lot of time to learn all the languages. The lack of IDE with debugger is damping my enthusiasm. Right now my hydraulic servo system simulator is about 460KB not including the three distribution libraries that go along with it. That is a little big for an applet. What I haven't figured out yet is is these three libraries are required if Java Runtime is already installed. I think I could have done what I wanted to do so far with VB.net but as I go on and add features I think the flexibility I have with Java will win out. Now a comparison with C#.net would be much closer. Anyway, as much as I have learned I realize I am perhap only a third of the way there. Last week I had a need to implement a second order simulator in plain old C. It was easy to do. It was short, clean and very efficient. However, it was not as flexible as the one written in Java. To make the C program do what the java program does would make the code much more messy and the efficiency would probably that of java anyway. BTW, I do most of my development on Macs now so that leaves our MS languages. However, I also refuse to learn the Mac specific languages like Objective C. I want code that will run anywhere. Edited by Peter Nachtwey

Share this post


Link to post
Share on other sites
The great advantage of VB/VBA is that it seemed to be pervasive. You could at one time write scripts to do almost anything with any software in the Windows platform. Since .NET showed up, this capability is totally disappearing since it creates isolation rather than cooperation amongst software objects. That's also the problem...you can't easily use .NET as a "scripting" language. So it doesn't have the same "drop in scripting language" feature that VBA had.

Share this post


Link to post
Share on other sites
Lots going on in the Python world - they're concurrently working on, and have a release candidate available for, version 3.0. It really is a great language as far as being best of breed between high level simplicity and power (object oriented, great APIs). It is especially useful and surprisingly fast in Jython form when teamed up with Java. I agree, they don't have a real good IDE/debugger lined up. From a geek perspective C# and VB.NET are equivalent. That is, with a little know how, you can translate any code from one to the other and it will compile to the exact same CIL instructions (same idea as Java Bytecode). You can feel more nerdy with the more concise C style syntax. The verbose VB instructions better match what the majority of the casual programmers are used to. Staying away from OS specific languages (portability) is good. Between the increasing popularity of Macs and Linux and the stupid decisions coming from Redmond, Java and C become increasingly compelling - again. In the ubiquity (web) department, Java's the only game in town. Getting off topic now - I really like Microsoft's new suites. If you use new versions of Office, Outlook with Exchange and Sharepoint 2007, you get a phenomenal package! It's like a Hippo in terms of support, but exceptional for productivity. If only they didn't go so far backwards with Vista! Edited by Nathan

Share this post


Link to post
Share on other sites
Nathan, do you use python for gui programming? If so, what gui api do you use with python? Why? Python comes with the TK gui. My Mac supports three different options of Cocoa ( the Mac gui api ) for python and Ruby. I know you probably use python as a scipt language just to glue applications together.

Share this post


Link to post
Share on other sites
Sure - and you can also statically compile C Python. It sounds like you're more on my side of the static vs. JIT compilation where Pete was so adamant about the superiority of C's static compilation. I'm a fan of dynamic compilation, garbage collection, etc. Also, I'm not sure that most people realize that very similar dynamic optimization is being done on the fly within your Intel/AMD CPU. Complex instructions that get broken down and resequenced to basic ones. I imagine similar cache optimization is occurring as well.

Share this post


Link to post
Share on other sites
I personally do not, but I have seen it used for GUI programming (list of links here). I really have 2 separate uses for Python, neither is probably applicable for you. 1. General purpose scripting language. I also like PHP for this, even when I'm not doing web apps. Ruby sounds cool, but I haven't gotten around to tinkering with it. Screw Perl, Prologue, Lisp, and all those other languages I've had to fight my way through. This is what I do for small simulations and such where C/C++/VB feels like overkill. 2. FactoryPMI uses Python as the scripting language. Like you said, on the GUI side of things it's really just hooks into the Java Bean objects or simple custom API calls - much simpler than I'm probably making it sound. I have been tinkering with native Java2D code through Jython - it's really cool but painful. Makes me wish I'd taken the computer graphics courses in school. Affine transforms? What? Edited by Nathan

Share this post


Link to post
Share on other sites
I have not been fond of using Python for GUI programming. TK is just plain awful. Don't waste your time. I haven't had access to Cocoa (don't own a Mac). That leaves three options. You can use Java (Jython). You can use wxwindows which isn't bad and typical of GUI packages (aside from Glade, no decent GUI builder though). Or you can do what I do...using your web browser. It is fairly easy to interface Python to a web server and from there, you can do all the web-based things you want to do. Check out "turbogears" for a prebuilt system.

Share this post


Link to post
Share on other sites
I will look at Jython since I am already learning Java and am now much more familiar with Java Swing that any other GUI and it got two thumbs up. BTW, I still think any significant program will be written in C++. What is the most significant and popular program written in Java or Python? I bet all the system programming is done in C or C++.

Share this post


Link to post
Share on other sites
I agree with that statement, but what difference does it make? Nobody on these forums are writing the newest version of MS Office or the latest video game. Python is more of a scripting language, you surely wouldn't use it for serious application development. Java is powerful in the webapps arena, especially server side. Think ebay or Google Mobile maps. On the application side it works well for embedded multimedia and applications - mobile phones, car systems, etc. One of Java's greatest features is the ability to launch on nearly every platform without installation headache - this also insulates you from patch/upgrade compatibility problems. You can also create nice modern looking applications - the old days of being limited crappy looking AWT interfaces are long past. I would say that it doesn't hold up to "Flash" in snazziness factor, but is a much more powerful language. BTW - most of my Java points are also true of .NET - and you'll never see MS write Office or Operating Systems entirely in it.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0