Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

Static AND Dynamic Typing?

Name: Anonymous 2007-09-09 13:02 ID:p5jks6Ym

Is it possible to create a language where it's statically typed (preferably with inference) by default, but can drop to dynamic typing for bits where you need it. I seem to remember someone saying this wouldn't work. Can anyone explain why?

Name: Anonymous 2007-09-09 13:09 ID:Heaven

sage

Name: Anonymous 2007-09-09 14:00 ID:Heaven

VISUAL BASIC, Perl.

Name: Anonymous 2007-09-09 19:00 ID:nWkDjLTQ

This would work. In Haskell you can have values of type Dynamic. However, you have to unwrap them explicitly (conceptually not unlike unboxing in C#, or dynamic_cast<> in C++) and catch the cases when the contents are not of the type you expected.

Generally type inference is about as good, except for heterogenous collections. But I think there's a Haskell library for those, too, and for simple collections (i.e. ones that don't operate on the "leaves" of the structure) you can just use Dynamic or define a datatype with as many distinct leaves as you have types.

In the end, good design tends to make dynamic typing unnecessary. Unify your data model at a higher level, and refactor to fit.

Name: Anonymous 2007-09-09 19:01 ID:5ubs151P

and for simple collections (i.e. ones that don't operate on the "leaves" of the structure)
Please could you explain further?

Name: Anonymous 2007-09-09 19:08 ID:b5zfKe/+

PHP does this

Name: Anonymous 2007-09-09 19:48 ID:Heaven

>>6
are you talking about the == === bullshit?

Name: Anonymous 2007-09-09 21:12 ID:YpkS9RFj

>>1
Why would you mix stupid and smart typing? For OMG OPTIMIZED? It's no point, really. And why are some people so obsessed with data types? It's better to have fewer, more useful, rich and tested data types with an extensive library of anything you'll ever need to do with them. There's no need to shoot your foot with explicit or static data types, especially when you can do all sorts of magic with dynamic data types, which adapts better to reality. Most of the times, one type and another are like a hammer and a hammer for left-handed people. And don't throw me the "error checking" bullshit because if the type of a variable is not obvious given its name it's your fault, not the type system's, and the rare cases where you could genuinely fuck up take much less time to fix than the time you take defining or dealing with types.

>>4
In the end, good design tends to make dynamic typing unnecessary.
In the end, good design tends to make static typing unnecessary. Just call the fucking function, nobody gives a shit it's a refrigerator or a lift as long as it can "Open()"! By using types you limit yourself; you degeneralize your functions and make them less useful.

>>7
No, he's talking about the retarded type hinting. For more fail, PHP didn't rip Python's object system off, but Java's, and as a result, it's full of faggotry such as type hinting. Expect a new generation of "designers" writing bullshit because of this.

Name: Anonymous 2007-09-09 21:41 ID:nWkDjLTQ

>>5
Sets based on red-black trees that are keyed using the Ord instance of a datatype cannot be used in conjunction with Dynamic, since Dynamic is not an Ord-ered type. Also can't use them as keys in a red-black tree map.

>>8
Doesn't understand type inference.

Name: Anonymous 2007-09-09 21:47 ID:Heaven

>>8
Are you a furry or something? "Stupid and smart typing"? Yiff harder.

Name: Anonymous 2007-09-09 22:52 ID:gopzCWr4

>>8
Static typing is indispensable when you're modifying code and APIs, letting the compiler and editor flag stuff in realtime, even when refactoring tools are used.  Real code is maintained, bedroom coder faggot.

Name: Anonymous 2007-09-09 23:29 ID:BCCKmclY

I like both. Surely there is a middleground?

Name: Anonymous 2007-09-09 23:37 ID:DRf37g9f

oh for fucks sake
ITT idiots, Go read a few books on type theory and you might get a clue, might. I saw might because you are all fucking idiots

Name: Anonymous 2007-09-10 0:03 ID:oQRchLcl

Real code is maintained, bedroom coder faggot.

Signed.

I prefer dynamic typing for small projects, but hot damn it hurts maintaining a code-base at work. You know, the place were mistakes actually come back and bite you in the ass. Unit tests and the ilk aren't as good as unit tests and static typing, not to mention finding stupid bugs often takes longer.

Also, I agree with >>12.

Name: Anonymous 2007-09-10 0:32 ID:JKZCpops

YOU SOUND LIKE LIKE FUCKING CLUELESS MICROSOFT FANBOYS THE DAY AFTER MICROSOFT ANNOUNCED ITS OK TO CARE ABOUT TYPE SYSTEMS


FUCK OFF

Name: Anonymous 2007-09-10 1:19 ID:uq8waC6K

make an interpretter.

Name: Anonymous 2007-09-10 1:26 ID:Heaven

>>15
o rly?

Name: Anonymous 2007-09-10 2:53 ID:VsohnFXz

>>15
Shut up, pops.

Name: Anonymous 2007-09-10 5:44 ID:Heaven

>>17
>>18
MICROSOFT FANBOYS

Name: Anonymous 2007-09-10 7:01 ID:4BVqvs/8

>>11
Static typing is indispensable when you're modifying code and APIs
Only not

letting the compiler
Fail

and editor
Even more fail, gb2/Visual Studio, IDEfag

Real code is maintained
And especially because of that, you don't want to shoot your foot with unnecessary particularization.

Name: Anonymous 2007-09-10 10:51 ID:Heaven

>>20
I'm pretty sure we in the real world call it "specialization", rather than "particularization". The latter must be some sort of a... furfag programmer's word or something.

Name: Anonymous 2009-03-06 15:16

The friends and comments sections down below.

Name: Anonymous 2010-12-25 12:07

Don't change these.
Name: Email:
Entire Thread Thread List