My Secret Life as a Spaghetti Coder
home | about | contact | privacy statement
I've been thinking about it lately, and I cant't seem to think of any (in my admittedly small set of knowledge) other language that allows you to be dynamic by leaving out language constructs (such as the type and returntype attributes of parameters and functions), but that, when you do decide to use them, the language acts statically (and is CF even acting statically when it checks the arguments, or is it acting strongly?).

For all you supermultilingual coders out there: do you know of any other language which is dynamic, but allows you to instruct it to become static like CF does? If there are others, is CF the first?

Is it good to be such a hybrid? I would think it keeps the staticians and dynamos both happy, but I'm not sure if it can (or even should) be quantified as good/bad. Do we want it to continue down the path that leads to having complete static options available (for instance, you can type your variables if you want to, and it will provide benefits of static languages, but leaving them off keeps it dynamic)?
What if you could write Java code as: name = "Johnny"; name=3; (and switch back to having it statically typed in the same class)? What would it look like to do operations on a dyanmically declared variable when a static one is expected? I suppose this has more to do with strong vs. weak typing, really, but would the mere existence of allowing dynamic typing mean the compiler can no longer check any method call for correct argument types? Would the fact that you can declare variables without a type make statiphiles cringe (because they may intend to use the typing and leave it off, and then the compiler won't tell them)?

Does allowing any typing to be done dynamically mean all checks must be performed at runtime? If so, what is the point to adding static features into CF (to make it throw an error perhaps 2 lines prior to where it would have thrown it - at the beginning of the method rather than where the argument is used)?

Does it even make sense to classify a language as a static/dynamic hybrid? (And can I ask any more questions?)

Hey! Why don't you make your life easier and subscribe to the full post or short blurb RSS feed? I'm so confident you'll love my smelly pasta plate wisdom that I'm offering a no-strings-attached, lifetime money back guarantee!


Comments
Leave a comment

isn't actionscript 2 like this...I think so ??

Posted by stigg on May 16, 2007 at 09:08 AM UTC - 5 hrs

@stigg - it may very well be...

Posted by Sam on May 16, 2007 at 09:58 AM UTC - 5 hrs

Hi Sam, This is a bit of a badly defined space:

Wikipedia says:
http://en.wikipedia.org/wiki/Strongly_typed
"these terms have been given such a wide variety of meanings over the short history of computing that it is often difficult to know what an individual writer means by using them."

My reading is that coldfusion is weakly typed as it allows you to do things like performing arithmetic on strings as long as it is capable of converting them into ints or floats or whatever (which rocks as it saves a bunch of casting).

It is also dynamically typed as the type of a variable can be changed over its lifetime (as opposed to static typing where the type cannot be changed).

In terms of the lack of required type definitions, OCaml and Haskell are statically typed languages (just like Java and C#), but the compilers use type inference, so you don't need to explicitly document types on declaratio which is a really nice saving - many people argue that static typing isn't that bad - it is languages like Java that don't infer types that are a pain in terms of having to document every type which ends up being a lot of extra keystrokes.

Hope that helps somewhat?

Posted by Peter Bell on May 16, 2007 at 05:20 PM UTC - 5 hrs

There is boo:
http://boo.codehaus.org/Duck+Typing
A language inspired from Python for the .net framework.

Posted by Fabio Serra on May 17, 2007 at 03:06 AM UTC - 5 hrs

I've never done anything with it, but it seems like whenever someone brings up anything about dynamic typing they're either talking about CF or Ruby.

Posted by Joe on May 17, 2007 at 02:24 PM UTC - 5 hrs

@Fabio - Cool stuff! I had never actually looked at boo. So, basically I was wrong in thinking there is no point to doing hybrid - by treating everything as static and "turning on" the dynamic stuff "at compile time it simply trusts that you know what you are doing" (as they talk about in the link you provided).

@Peter - yeah, I was hoping to confuse everyone and I certainly would hate for anyone to understand what I was saying. =) For the strong/weak typing reference, what I was getting at is more referring to type-safety. I was thinking, for example, about adding 3+"G" and it would return the sum of whatever the contents of memory would be.

Posted by Sam on May 17, 2007 at 04:57 PM UTC - 5 hrs

CF is not statically typed at all. You can induce some strong(-ish) dynamic typing however.

Posted by Sean Corfield on May 18, 2007 at 03:25 AM UTC - 5 hrs

That's what I meant to get across with the Strong comment, but as Peter pointed out, it doesn't really mean anything =)

Posted by Sam on May 18, 2007 at 07:08 AM UTC - 5 hrs

I think I read somewhere (now I can't remember where) in the last couple of days that Dylan is somewhat hybrid in this aspect. (Wikipedia mentions that it is dynamic and provides "fine-grained control over dynamic and static behaviors" at http://en.wikipedia.org/wiki/Dylan_programming_lan... but that is not my original source)

Posted by Sam on May 22, 2007 at 10:55 AM UTC - 5 hrs

Leave a comment

Leave this field empty
Your Name
Email (not displayed, more info?)
Website

Comment:

Subcribe to this comment thread
Remember my details
Google
Web CodeOdor.com

Me
Picture of me

Topics
.NET (19)
AI/Machine Learning (14)
Answers To 100 Interview Questions (10)
Bioinformatics (2)
Business (1)
C and Cplusplus (6)
cfrails (22)
ColdFusion (78)
Customer Relations (15)
Databases (3)
DRY (18)
DSLs (11)
Future Tech (5)
Games (5)
Groovy/Grails (8)
Hardware (1)
IDEs (9)
Java (38)
JavaScript (4)
Linux (2)
Lisp (1)
Mac OS (4)
Management (15)
MediaServerX (1)
Miscellany (76)
OOAD (37)
Productivity (11)
Programming (168)
Programming Quotables (9)
Rails (31)
Ruby (67)
Save Your Job (58)
scriptaGulous (4)
Software Development Process (23)
TDD (41)
TDDing xorblog (6)
Tools (5)
Web Development (8)
Windows (1)
With (1)
YAGNI (10)

Resources
Agile Manifesto & Principles
Principles Of OOD
ColdFusion
CFUnit
Ruby
Ruby on Rails
JUnit



RSS 2.0: Full Post | Short Blurb
Subscribe by email:

Delivered by FeedBurner