Posts: 409 / Nickname: bv / Registered: January 17, 2002 4:28 PM
Use the Best Tool for the Job
March 2, 2003 8:01 PM
|
Artima.com has published a short article that recommends that programmers who use a systems language learn a scripting language too.---xj40dkcfea73---Artima.com has published a short article that recommends that programmers who use a systems language learn a scripting language too.
http://www.artima.com/commentary/langtool.html Here's an excerpt: To me, attempting to use one language for every programming task is like attempting to use one tool for every carpentry task. You may really like screwdrivers, and your screwdriver may work great for a job like inserting screws into wood. But what if you're handed a nail? You could conceivably use the butt of the screwdriver's handle and pound that nail into the wood. The trouble is, a) you are likely to put an eye out, and b) you won't be as productive pounding in that nail with a screwdriver as you would with a hammer. Because learning a new programming language requires so much time and effort, most programmers find it impractical to learn many languages well. But I think most programmers could learn two languages well. If you program primarily in a systems language, find a scripting language that suits you and learn it well enough to use it regularly. I have found that having both a systems and a scripting language in the toolbox is a powerful combination. You can apply the most appropriate tool to the programming job at hand. What's your opinion? |
Posts: 2 / Nickname: phraktle / Registered: March 2, 2003 6:42 PM
Re: Use the Best Tool for the Job
March 2, 2003 11:59 PM
|
The tool/product analogy is unfortunate, because it doesn't capture a critical element of software development (as it is today :) - the tool you use, is also the product itself. It will have an effect on the entire lifecycle of the product, not just building it.
|
Posts: 25 / Nickname: hlovatt / Registered: March 3, 2003 1:20 PM
Re: Use the Best Tool for the Job
March 3, 2003 6:53 PM
|
I use both scripting and strongly typed languages and generally find I make less mistakes in strongly typed languages and therefore favour these.
One interesting alternative is type inferring languages, e.g.: http://www.haskell.org/ Type inferring languagesare less verbose than strongly typed languages but still type check. You need to define method argument types and return types but generally not variable types, they are inferred, e.g.: x = 1; the language would infer that xwas of type intand if you did: x = 'a'; this would be an error since xis an int. Another more complicated example is: class Example { x; Example(int x) { this.x = x; } } would infer that field xis of type intfrom its use inside the constructor, note the constructor argument is typed. What do you think, do you like typing inferring? Note I have used Java like syntax in the examples above; the syntax of type inferring languages is generally more Python like, e.g. Haskell. |
Posts: 409 / Nickname: bv / Registered: January 17, 2002 4:28 PM
Re: Use the Best Tool for the Job
March 3, 2003 8:22 PM
|
I think inferring types is a great technique, because it yields less finger typing, and less code to look at, but not I suspect in a way that makes the code cryptic.
Nevertheless, I think I would be inclined to apply a type-inferrence language in the same way I use Java right now, to build things. When it comes to doing quick little jobs that require code, such as processing strings in files, I don't feel the need for statically typed variables. |
Posts: 1 / Nickname: jirilundak / Registered: January 27, 2003 7:15 PM
Re: Use the Best Tool for the Job
March 4, 2003 0:08 AM
|
I think it is important to facilitate also the maintenance of a system.
If I a have a system that is a patchwork of HTML, JavaScript, Java and some proprietary regex-like command line scripts, with business logic dispersed throughout the system, I have very likely created a system that is hard to maintain. I find it to be really helpful and important to have a solid and wide toolset at hand as individual developer, but it must be applied with care. In the corporate environment sometimes sticking with some standard (but deliberately limited) toolset must be enforced. My 2c. |
Posts: 2 / Nickname: ejain / Registered: March 3, 2003 9:38 PM
Re: Use the Best Tool for the Job
March 4, 2003 3:25 AM
|
Scripting languages may not be a good choice for anything beyond small to medium sized tasks.
One issue that is rarely mentioned is that it is very hard to create tools for working with the code itself. Consider the support for refactoring: Example: A class Order has a method check(). This method needs to be renamed (or its signature changes etc). Thanks to strong typing, editors such as Eclipse or IDEA are able to automatically fix any references to the changed method. On the other hand it is not possible for a Python editor to know whether it may safely modify the following function:
Of course I strongly agree that scripting languages are the preferred tool for small tasks, unless you have too many programmers that need to be kept busy :-) A very effective approach is to develop the core of your application in Java, and use Jython for small day to day tasks (you can transparently use your Java classes). Perhaps every future language (or platform, more accurately) should support at least two syntaxes, full-blown and scripting level. (For certain applications a third, low level syntax might also be usefull.) |
Posts: 1 / Nickname: alaneustac / Registered: February 11, 2003 0:11 PM
Re: Use the Best Tool for the Job
March 4, 2003 5:38 AM
|
An acquaintance of mine who is an experienced C++ engineer and who is a Perl fanatic, developed a distributed payment system a few years back that's still in daily operation.
Obviously he used C++ to develop such a system, right? Nope :) He wrote it in Perl. His motivation was the speed of development that it facilitated, and he wrote it according to OO principles- not sure if he used OO Perl or just designed it that way. He did say that this approach would only work with a small development team (which was the case here, 3 or 4 developers) because it would be impossible to enforce standards in a large team. I also suspect that only he or his team could successfully maintain the subsequent code. This highlights to me the trade-off between speed of development and maintainability of scripting languages. I don't know enough about Python yet (although I'm impressed by what I've read) but I'd be nervous about using a language like Perl for a major project. I use Perl for day to day tasks (mostly regex and file-parsing), Java for system development. Going back to Java code after a few months, or looking at someone else's code, I can quickly pick up what's there in front of me. With Perl, even with a one file program, it takes me a good bit longer. However, I don't use Perl as much as Java I love Perl, and I'd be happy to see a language like Python become a de-facto systems development language. Speed of development and ease of use are all good things. But maintainability has to be part of the package. Perhaps it already is... |
Posts: 4 / Nickname: dlpierson / Registered: March 6, 2003 8:17 AM
Re: Use the Best Tool for the Job
March 6, 2003 1:24 PM
|
The problem with this argument is that the refactoring tools
that started the current trend were written in and for a dynamically typed language: Smalltalk. It is perfectly possible to create similar tools for Python. One example under construction can be found at http://sourceforge.net/projects/bicyclerepair. |
Posts: 15 / Nickname: jcheng / Registered: October 16, 2002 8:08 AM
Re: Use the Best Tool for the Job
March 4, 2003 0:18 PM
|
What scripting language would be a good one for a Java programmer to start on? The three I hear mentioned most these days are Perl, Python, and Ruby... I've dabbled a bit in all three but not enough to get a strong grasp on what the day-to-day advantages are between one and the next. It does seem to me that Python and Ruby are more readable than Perl, and Ruby professes to be more purely object oriented than Python.
However, from a Java programmer's point of view who only is interested in taking "short hikes" with these languages, it seems like the main goal should be speed of development and not necessarily OO purity or readability. And Perl's ubiquity on Unix systems is hard to ignore. However, I also heard that Perl 6 will be a ground-up overhaul of the language...? Thoughts? |
Posts: 62 / Nickname: matt / Registered: February 6, 2002 7:27 AM
Re: Use the Best Tool for the Job
March 4, 2003 6:10 PM
|
> What scripting language would be a good one for a Java
> programmer to start on? The three I hear mentioned most > these days are Perl, Python, and Ruby... I've dabbled a > bit in all three but not enough to get a strong grasp on > what the day-to-day advantages are between one and the > next. It does seem to me that Python and Ruby are more > readable than Perl, and Ruby professes to be more purely > object oriented than Python. > > However, from a Java programmer's point of view who only > is interested in taking "short hikes" with these > languages, it seems like the main goal should be speed of > development and not necessarily OO purity or readability. > And Perl's ubiquity on Unix systems is hard to ignore. > However, I also heard that Perl 6 will be a ground-up > p overhaul of the language...? For a Java programmer, I'd say the hands-down choice is Python: - Ruby's old claim that it is "more OO" is no longer the case anyway. - Perl is infamously cryptic and Ruby has quirky syntax (looks like BASIC without the BEGIN keyword). - Jython. This Python/Java synthesis allows you to use Java classes in Python, among other things. (maybe there is something similar for Perl or Ruby?) - Python has a ton of useful libraries (in fact, one of Ruby's saving graces is the fact that it can use Python libraries). - I found that Python was very easy to learn and that it does most things in a way that are brilliantly simple. |
Posts: 62 / Nickname: matt / Registered: February 6, 2002 7:27 AM
Re: Use the Best Tool for the Job
March 5, 2003 0:28 AM
|
An interesting addendum to the "strong versus weak typing" discussion:
One example of an error case that Python uncovered for us was caused by an external prediction program that would usually return a numerical error code but in some cases was found to return the string "error" instead. In Perl, strings and numbers are converted automatically, for example the string "123" becomes the integer 123. Unfortunately, Perl also converts non-numerical strings, such as "error", to 0. As a result of this, Drone was treating "error" as a successful return value, leading to incorrect results. Python's stronger typing uncovered the error as soon as the rare case that caused it was executed. From "AstraZeneca Uses Python for Collaborative Drug Discovery" at http://pythonology.com/success&story=astra This helps to illustrate the contrast between weak typing and dynamic typing. |
Posts: 4 / Nickname: dlpierson / Registered: March 6, 2003 8:17 AM
Re: Use the Best Tool for the Job
March 6, 2003 1:28 PM
|
What scripting language would be a good one for a Java programmer to start on?
I would recommend Python to a Java programmer for two reasons: 1. The Jython implementation. This is Python written in Java. It can subclass and be subclassed by Java and is compatible with the main Python implementation ("CPython") at the language level. The C implementation does have a lot more standard library modules. 2. While Python programs can easily be purely object oriented, they don't have to me. This is useful to jobs where an object oriented solution is not an advantage. |
Posts: 3 / Nickname: javidjamae / Registered: January 31, 2003 0:23 PM
Re: Use the Best Tool for the Job
March 3, 2003 11:04 PM
|
So what is the argument against using a scripting language to build a "system"? I've been loosely following the articles on this site, and I haven't heard a strong argument for not just using a language like Python to build a system.
And since you could build a system out of a scripting language, would that make a scripting language a system language as well? Also, is a scripting language dynamically typed by definition? |
Posts: 409 / Nickname: bv / Registered: January 17, 2002 4:28 PM
Re: Use the Best Tool for the Job
March 4, 2003 0:42 PM
|
> So what is the argument against using a scripting language
> to build a "system"? I've been loosely following the > articles on this site, and I haven't heard a strong > argument for not just using a language like Python to > build a system. > Well, there are at least two schools of thought. The strong-typer's view is that you can't get as robust an end product without strong static type checking at compile time. The weak-typer's view is that you can get as much robustness through testing, and that you get to start testing sooner. I have attempted to publish both sides of this argument on Artima.com so that readers can judge for themselves (and discuss the issue with each other in this forum). For the quickest overview of the debate, check out page one of the Strong versus Weak Typing installment of the Guido van Rossum interview: http://www.artima.com/intv/strongweak.html On that page, I present Guido with quotes from earlier interviews with James Gosling and Josh Bloch in which they give the strong-typer viewpoint. Links to the interviews containing those quotes are available in the resources section of the Van Rossum interview: http://www.artima.com/intv/strongweak4.html#resources So in short, the answer to your question is that there isn't a consensus in the industry. In the Use the Appropriate Tool for the Job article, I describe the ways in which I apply systems and scripting languages, but there I'm talking about me. I don't believe everyone should use tools the way I do. Nevertheless, I do recommend to systems language enthusiasts that they also learn a scripting language well enough to use regularly. I have found that knowing a scripting language makes me much more productive for the "short hikes." |
Posts: 4 / Nickname: dlpierson / Registered: March 6, 2003 8:17 AM
Re: Use the Best Tool for the Job
March 6, 2003 1:33 PM
|
For the quickest overview of the debate, check out page one of the Strong versus Weak Typing installment of the Guido van Rossum interview:
I think that the weakest part of that interview section is that neither of you mentioned real contracts (as in Eiffel). While I agree that the "contract enforcement" benefits of strong typing are generally overstated, the I suspect that the benefits of real Design by Contract support are substantially greater. |
Posts: 409 / Nickname: bv / Registered: January 17, 2002 4:28 PM
Re: Use the Best Tool for the Job
March 6, 2003 10:38 PM
|
> I think that the weakest part of that interview section is
> that neither of you mentioned real contracts (as in > Eiffel). While I agree that the "contract enforcement" > benefits of strong typing are generally overstated, the I > suspect that the benefits of real Design by Contract > support are substantially greater. I actually asked Guido a lot about contracts, but in the "Contracts in Python" installment: http://www.artima.com/intv/pycontract.html |
Posts: 40 / Nickname: vincent / Registered: November 13, 2002 7:25 AM
Re: Use the Best Tool for the Job
March 8, 2003 10:24 AM
|
> > So what is the argument against using a scripting
> language > > to build a "system"? > > The weak-typer's view is that you can get as much > robustness through testing, and that you get to start > testing sooner. This sound like a rather weak argument to me. It implies that robustness is achieved through the requirement for extra disipline by the programmer having to compensate for the weakness of the language. It also misses the fact that there is nothing stopping you putting an equal amount of testing into Java development as into Python development with the added benefit of not having to test types (so rigourously) in Java. Vince. |
Posts: 1 / Nickname: larsd / Registered: March 4, 2003 10:30 AM
Re: Use the Best Tool for the Job
March 18, 2003 10:26 AM
|
This topic is almost two weeks old, but still...
So what is the argument against using a scripting language to build a "system"? It might be instructional to take a look at the development of LPMuds here. LPMuds are muds implemented in an interpreted C-dialect, called 'LPC'. LPC is runtime-typed and in the beginning contained no compiler type checks whatsoever. However, as the muds, and especially the core game mechanics, grew in size (up to 300 concurrent users and hundreds MB of game code), LPC added more and more type checking to the language (it can be bypassed, though). The reason for this, as I see it, is that with a large system you as a single programmer can't know any longer every aspect of the existing code. In a small system you can keep in mind that womble() calls frog() with is second argument which therefore must not be a float; but in large system the compiler is better suited to keep track of these details. |
Posts: 1 / Nickname: malus / Registered: August 15, 2003 1:55 PM
Re: Use the Best Tool for the Job
December 1, 2003 9:29 PM
|
I find many programmers don't understand the relationship between their code and the systems their code rides. They overdo it, driving up costs and the time of delivery for the sake of bullet proofing.
The reality is the correct tool for the job not only encompasses the choice of language, but also the hardware and network environment the resultant application will reside. They must complement each other for the task at hand. For example, lets say we have an internal application that at most 50 people will use in your organization. Response times are not critical (we are not building the space shuttle here). Now given that the worse case senario is 50 connections, and more likely an average of about 5 or 6 connections at any given point in time, what would be the correct solution? Many times this ends up being a java or C++ application running on a fully redundant mirrored environment (perhaps MC Service Guard environment on a high end HP). In reality, the application could be emplemented on a Sun Blade/Ultra single processor box with an automated backup routine using readily available Zope and Python. It would be implemented quicker, the users would be able to give more immediate feedback, changes would be trivial, and the developer would really serve the users what they need when they need it. The problem is we think in terms of gold plating and bullet proofing our applications in various ways - at both ends of the spectrum. Not only do we use the most 'stable' and/or 'efficient' language implementation, we then further elimenate all possible exposure by over engineering the hardware solution. I think some of this stems from the overspecialization of programmers. I often question the motivations of anyone who refuses to learn new languages, and other aspects of system development outside of their area of expertise. Every project is not the space shuttle - in fact, <i>most</i> are not. Outside of mission critical code (such as nuclear reactor code, or code that controls the space shuttle engines), imperfect working code in the hands of users now beats perfect code 14 months from now. (To toot my own horn, I have built programs using the following languages: basic, fortran, C, C++, Java, Perl, Python, sed, awk, sh, csh, tcl/tk/expect, x86 assembler, sparc assembler, and lisp) |
Posts: 7 / Nickname: viewpoint / Registered: February 16, 2004 0:09 PM
Re: Use the Best Tool for the Job
March 12, 2005 9:33 AM
|
Quote from article:
"To me, attempting to use one language for every programming task is like attempting to use one tool for every carpentry task. You may really like screwdrivers, and your screwdriver may work great for a job like inserting screws into wood. But what if you're handed a nail? You could conceivably use the butt of the screwdriver's handle and pound that nail into the wood. The trouble is, a) you are likely to put an eye out, and b) you won't be as productive pounding in that nail with a screwdriver as you would with a hammer." My reply : I think ability to code plays a part in whether to use another language and or script instead of the language the developer is skilled with. Still learning another language can be of great value. Here are some thoughts (abstact or not) towards this view and in practical terms. Please consider. 1): retention of language semantics and its usage. An efficient programmer with one specific language should be able to do about anything whether strongly typed or not. Why? There is an ease of use reference within the mind which the coder develops as the continue to use the language. Like lifting weights at first, your muscles find it difficult and you tire easily. Later ease of use and enhanced efficiency develop that you become more intense with lifting heavier weights (if desired) and your speed in lifting improves as well. So why consider another language.? 2): Use a script language: The coder could create his own simple script language for specific duties they might have in mind. If setting the languages real code to the text editor is difficult, I agree it may be at times especially when your at the top end of your performance threshold and it is the end of the day or the middle of the week. It is good to use another language as a distraction while the formulation of code references set up in the brain. Again , it may be just as well to create your own script. 3): Change attitude towards existing language the coder may be enriched by it. How about applying a changed attitude towards the way you code when using the same language. Since the tasks your thinking about are less important and could be done with the language your using but at the time your language is too difficult to work with then enhance your skillset by starting to or create a library (if there is time) to objectify the specific tasks code. Keep adding to your library of less importance. You then are creating a new level of expertise which will enrich the flavour of your ability. As well you may develop a more diversified perspective on how to code. Like a window refresh if you will of your own disposition. cleaner , crisper - leaner - meaner. It is an intersting topic with many appropriate answers and I have wished to and have learned other languages too. I found in my specific instance (of being human) that selecting another language was because I was too tired to make the language I was seemingly skilled to work with work the way I wanted it too. It is interesting that I got over it. Thanks for reading David W. Stubbs |