Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

General Discussions


You are currently viewing our General Discussions as a guest. Please register to participate.
Login



Reply
Strong vs. Weak type checking
Old 02-25-2008, 01:40 AM Strong vs. Weak type checking
NullPointer's Avatar
Will Code for Food

Posts: 2,815
Name: Matt
Location: Irvine, CA
Trades: 0
When I first picked up programming it was in a language called scheme (one of the several flavors of Lisp). In scheme there are no types, in fact there are no variables. Everything is a function, so you really didn't have to worry about what type of data you were feeding it. You could make a function that could take in a single element, a list of elements, a list of lists of element, all in a single pass.

During my second quarter of college, I was force fed java. Suddenly everything has a type. Methods have return types and input types, variables had to be declared as either int, boolean, long, short, tall, red, white, whatever. I despised it at first.

Now I seem to like it so much that I don't really like it when a language lets you get away with not stating your intent immediatly. PHP for example will let you assign just about anything to a variable without declaring anything. $x could hold the int value 1 at one point then hold a string value or point to an object. When I see code that takes advantage of this feature I feel the need to say thats wrong, or at the very least not good coding.

Which do you guys prefer, strong or weak type checking.
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
NullPointer is online now
Reply With Quote
View Public Profile Visit NullPointer's homepage!
 
 
Register now for full access!
Old 02-25-2008, 02:07 PM Re: Strong vs. Weak type checking
Learning Newbie's Avatar
Defies a Status

Latest Blog Post:
Astounding Republican Paranoia
Posts: 5,662
Name: John Alexander
Trades: 0
Typeless coding is wrong.

When your PHP variable $x holds an int, then a string, it's not really the same variable. It looks like it in code, but it points to 2 different memory locations, changing the variable completely into another in all but name. This hides what's truly going on from the programmer. This is wrong.

I like that you dont' have to do mallocs and everything, and you could argue when you assign one string then a different string in .NET that the same thing happens because strings are immutable, so a new reference is created. That's an exception to the rule, tho, and normally you have to create a new instance of something which reassigns the pointer using the new keyword.

How can a person write high performance code if their compiler hides the true execution logic from them?
__________________

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE
Learning Newbie is offline
Reply With Quote
View Public Profile
 
Old 02-25-2008, 02:25 PM Re: Strong vs. Weak type checking
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,377
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
Even though I code mainly in VB and VBScript I prefer strong typing

having weak typing means so much more type checking and casting has to be written especially when gathering user input.

At least with strong typing you can catch the exception and return it back to the user without needing 10 more lines of code before telling the user what the problem might be.
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Reply     « Reply to Strong vs. Weak type checking
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 1.02169 seconds with 12 queries