This week's book giveaways are in the Jython/Python and Object-Oriented programming forums.
We're giving away four copies each of Machine Learning for Business: Using Amazon SageMaker and Jupyter and Object Design Style Guide and have the authors on-line!
See this thread and this one for details.
Win a copy of Machine Learning for Business: Using Amazon SageMaker and JupyterE this week in the Jython/Python forum
or Object Design Style Guide in the Object-Oriented programming forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Paul Clapham
  • Jeanne Boyarsky
  • Knute Snortum
Sheriffs:
  • Liutauras Vilda
  • Tim Cooke
  • Junilu Lacar
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Joe Ess
  • salvin francis
  • fred rosenberger

Your experiences with scripting languages

 
Ranch Hand
Posts: 389
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am not starting a war! I need some light!

I have started programming in Python and I found a few (no, many) things very weird and sometimes meaningless when I compare it with Java or C#. And there are so many things lurking in my mind these days that I want to get cleared for my lifetime.

--> Why are the scripting languages so hyped?

I just don't understand why. Of course, they are easy to program, you don't have to declare variables, you don't have to catch exceptions, hell, you don't even have to compile. Though it seems like exciting for people who don't know any programming language before, it seems like a recipe for disaster to me.

Let me give a small example:

I have a small program that tries and opens a socket or prints a message if the socket can't be opened. My Python program looks something like this:

I was happily using this code for one month till I hit a point where I couldn't open the socket and blow, I got a syntax error (at runtime, you hear me? RUNTIME) because I didn't import the 'socket' module. I was disgusted with myself and then with my scripting language. If I were to write the same program in Java, I would have compiled the code (no, eclipse will do it for me) and I would have been told by javac that, "You idiot, import the class before you try to do anything with it or go to hell."

I am using an IDE for Python which is just a fancy editor. Again I am NOT blaming the IDE because it has it's own limitations due to the language itself. Huh! I can't even get auto-complete for all the variables. There are so many things like type-safety, checked exceptions (even though people still argue over this), enums, interfaces that I'm missing while programming in a scripting language.

And many of the example say that Java gets really bigger and bigger and you will have a huge code to manage with, but I think Java with it's classes, packages, jar files makes it very easy to maintain and we always have our best friend 'ant' to make our builds. And the example I saw on most of the web-pages that talks about how tough and cumbersome it is to program Java give the "Hello world program" as their example.

Java:

Python:

Yes, I agree, scripting languages are the best ones for 'Hello World' programs but how many of us write "Hello World" programs in our daily life? Give me a break.

And about declaring variables, if you don't do it in Java, your IDE will complain as soon as you finished typing it. I use eclipse and I never declared a variable. This is how:

I just assign a value to a variable --> Eclipse points me the error --> I hit Ctrl + 1 (Quick Fix) --> I hit Enter (here my IDE declares the variable at the top or whichever scope you chose). And because my language is strongly-typed, I have auto-complete and I will never have a syntax error ever in my life programming in Java.

Many method calls in most of the scripting languages are determined at runtime, but what happens if we misspell the method name? I am having sleepless nights because of this. I would like to know the reason why scripting languages like Ruby (which doesn't care about types) are becoming popular nowadays while Java is becoming more and more strongly typed (with the addition of Generics). I always like to catch the errors as close to the problem as possible and as early in the development life-cycle as possible. With compile time safety, I can achieve this but still why are the scripting languages beating Java? Or are they really doing?

I am not against Python or any scripting language for the matter, but I would like to know how to avoid these things and how my programming approach must be while writing programs using these languages. And I would like to know why this kind of programming is really picking up nowadays.

Please share your opinions and give me your suggestions.

Thank you,
Srikanth
[ March 07, 2007: Message edited by: Srikanth Raghavan ]
 
Bartender
Posts: 9612
16
Mac OS X Linux Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Originally posted by Srikanth Raghavan:

--> Why are the scripting languages so hyped?


You answer your own question here:

Originally posted by Srikanth Raghavan:

they are easy to program, you don't have to declare variables, you don't have to catch exceptions, hell, you don't even have to compile.



It is up to the programmer to determine where these pros outweigh the rich language features of Java.

Originally posted by Srikanth Raghavan:

Many method calls in most of the scripting languages are determined at runtime, but what happens if we misspell the method name?



You cannot tell me that you just whip out some code and it runs flawlessly in any language. You code, compile in some cases, test, and repeat. If you aren't getting full code coverage in your test scenarios, that's a problem with your tests, not with the implementation language.
 
Bartender
Posts: 6663
5
MyEclipse IDE Firefox Browser Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

"You idiot, import the class before you try to do anything with it or go to hell."



Ah ! but at runtime lurks the NoClassDefFoundError if your jar file is not in your class path. Yes, atleast it is compile time safe. I have not tried scripting as yet. I did write basic unix scripts once.
 
author and iconoclast
Posts: 24203
43
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Remember that Extreme Programming was born out of practices established by a Smalltalk programming team. Smalltalk is also a weakly-typed, late-bound language, and many errors that would be found at compile-time in Java are found at runtime in Smalltalk. Does that make Java "better"? No, it really doesn't. Does that mean that excellent test coverage is important in Smalltalk, and that the way you program in Smalltalk is different from the way you program in Java? Yes, it does.

If you're using a weakly-typed, late-binding language, then it's important to get as close to 100% test coverage as possible. You did not do that with your socket program; you had 50% coverage at best, which is not good.
 
ranger
Posts: 17344
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sure, leave it to EFH to come in here and take it to a real technical level that makes sense. Stop hijacking these threads.

Mark
 
Put a gun against his head, pulled my trigger, now he's dead, that tiny ad sure bled
Sauce Labs - World's Largest Continuous Testing Cloud for Websites and Mobile Apps
https://coderanch.com/t/722574/Sauce-Labs-World-Largest-Continuous
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!