Click to See Complete Forum and Search --> : Python vs C# (Or other scripting langs)
pjrage
Nov 8th, 2007, 07:58 AM
Ok, I'm a total linux newbie. I know VERY little about it, but I'm currently working on learning and changing that just to broaden my horizon.
I've heard alot about scripting languages such as tcl, python, perl, etc, and I think I'm going to start trying out Python.
So my real question here is that I keep reading about scripting languages and their main claim to fame seems to be development speed? They primarily compare themselves to C/C++, and I can understand that comparison, but I've never seen them compared to .NET applications?
Maybe it is just me, but I can create applications really fast in .NET with the framework libraries? Every example I read about cases where they think Python/other scripting language would be really fast / save alot of time, I can do the same task so fast in .NET that I just couldn't imagine anything being faster?
That's not to say I think .NET is the end-all and I don't think there's a place for scripting languages, I'm just trying to figure out if I'm missing some huge topic here.
So, is .NET a rapid development architecture like these scripting languages? Or are the scripting languages actually faster/better, and if so, why?
wossname
Nov 8th, 2007, 12:25 PM
For speed critical stuff you'd be better of with .net than an interpreted or scripting language.
That said, coding C# under Linux is an exercise in pain and futility most of the time. Learn C++ if speed really is paramount to you. Otherwise php will probably suffice for most things, although its not as easily debugged.
I only ever use C# (mono) under linux when I need a GUI in my program. I can't realy justify using it at other times. All my commandline apps are written in C, C++ or php.
penagate
Nov 8th, 2007, 12:44 PM
So my real question here is that I keep reading about scripting languages and their main claim to fame seems to be development speed? They primarily compare themselves to C/C++, and I can understand that comparison, but I've never seen them compared to .NET applications?
You're trying to compare two different things: development time and execution time. This is a fundamental fallacy and can never lead to any sort of unbiased, objective conclusion.
Consider this—if you are writing a task that's to be done once, you'd use a scripting language. It may take four hours, whilst a compiled version may take 30 minutes, but who cares? You can leave it running overnight and it will be done by the next morning.
On the other hand, you might spend a whole day developing the tool in the compiled language, and then a week fixing the bugs and whittling away at the execution times; all for what gain? Sure, your program runs eight times faster than it might in a scripted language, and that might make you feel pretty damn pleased with yourself, but to everyone else (read: your boss) you've wasted a week doing something that could have been done in a night.
Conversely, if you were writing a speed-critical routine to be executed on a regular basis, a compiled language would be the obvious choice. And from the selection of those available to you, you'd pick the one that used the right paradigm and offered the right feature set for the task at hand.
The bottom line? Pick the right tool for the job; and don't ever try to compare languages like equals, for there are none.
pjrage
Nov 15th, 2007, 02:02 PM
I guess that's my point, though, penagate. Can you seriously code a program (or do they call it a script?) in a scripting language THAT much faster than you could in .NET?
I suppose I understand if perhaps you HAD to use a linux based system - scripting might be the fastest, I have no idea because I don't know anything about the different available languages/libraries and such for linux. But if you were just asked to write a simple program, choose the OS you use, choose the language, and get said program working ASAP, which language would you grab? In case it is relevant, maybe the program is a two-way chat program using TCP/IP. Or maybe the program is as simple as a generic calculator GUI. And of course, in these examples, the programmer's experience with the different languages is directly related, but for the sake of argument, consider equal knowledge of all languages. Which would be the fastest/easiest/make the most sense to use?
Everything I read seemed to indicate that these scripting languages were perfect for this sort of task, but I just couldn't imagine them being so much faster than using .NET in windows? :confused: Or perhaps everything I read about them being so fast is assuming linux as an OS and is not considering windows and available languages/libraries for windows such as .NET.
Or am I missing the point entirely and asking the wrong questions? :confused:
Truthfully, I'm just trying to get the bottom of what makes these scripting languages so great compared to C/C++. I could name a few reasons that I personally prefer .NET to C/C++ for the types of things I do, but I have no clue what makes scripting so nice. After reading about it, scripting seemed to me to have the same advantages for linux over C/C++ as .NET does over C/C++ for windows.
penagate
Nov 15th, 2007, 07:52 PM
I would not use a scripting language to make a GUI application. I would use some kind of compiled language with a GUI framework.
If the task was something like a once-off process of a bunch of files then I would use a shell script.
People talk more about shell scripts in Linux development than in Windows because Windows doesn't provide a decent scripting environment.
Or am I missing the point entirely and asking the wrong questions?
The point is that you should use whatever you feel you can best do the job in. If you are a proficient programmer and pick up languages quickly then this might mean using a new language specifically for the task. If you're not comfortable working with unfamiliar languages then it would be quicker to use one you are familiar with.
There is no ideal language for anyone for any task.
pjrage
Nov 16th, 2007, 07:12 AM
Thanks, I think you've made it pretty clear.
Would you mind offering a simple example task of processing files as you mentioned a script might be useful for?
Maybe something where you want to change a specific file extension of a few thousand files in a folder to something else? I guess if a scripting language could use 10 lines or so in a for loop to just iterate through every file in the folder, check the extenion, remove the old extension, and add the new, that would be much faster to write than even .NET. If this is what you mean, then I think I'm starting to get it now :)
penagate
Nov 16th, 2007, 09:10 AM
Yes, or searching for/replacing text in files (grep), or downloading batches of data from a remote server according to some algorithm (wget).
Basically, shell scripting is best for automation of everyday tasks; scripting languages are best where flexibility and versatility are more important than ultimate performance (e.g. web applications) and compiled languages are best for more rigid architectures—tools that are used often but changed infrequently.
tr333
Nov 24th, 2007, 07:20 AM
I would not use a scripting language to make a GUI application. I would use some kind of compiled language with a GUI framework.
I have seen many linux programs with a GUI written in python using GTK or similar. FYI, PyGTK (http://en.wikipedia.org/wiki/PyGTK) is the preferred choice for applications running on the OLPC (http://en.wikipedia.org/wiki/OLPC).
As for the languages, i've heard that python is easier to learn than Perl, but it all depends on what you like better.
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.