[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y ] [Home]
4chanarchives logo
Dynamic typing - Why?
Images are sometimes not shown due to bandwidth/network limitations. Refreshing the page usually helps.

You are currently reading a thread in /g/ - Technology

Thread replies: 22
Thread images: 1
File: python.png (80 KB, 1055x587) Image search: [Google]
python.png
80 KB, 1055x587
>Productivity

Daily reminder that if you don't know what type your function should be returning, you shouldn't be programming
>>
>>51521357
Fuck you and your toy language, whiny ML faggot.
>>
>>51521357
And yet indeed productivity
>>
>>51521357
> if you don't know what type your function should be returning
... then dynamic typing won't help you. It will just delay the inevitable error until the relevant code actually gets run.

Most of the time I prefer static typing, but dynamic typing has one concrete advantage: it doesn't stop you from writing correctly-typed functions just because their type isn't something which the language's type system can express.

Even Haskell, even a hypothetical version which contained *all* of the myriad extensions to its type system, still imposes limitations on types. Whereas a dynamically-typed language lets you tell the language "butt out, I know what I'm doing".
>>
>>51523559
>>
>Even Haskell, even a hypothetical version which contained *all* of the myriad extensions to its type system, still imposes limitations on types. Whereas a dynamically-typed language lets you tell the language "butt out, I know what I'm doing".
wouldn't the best solution be something like C where it's statically typed, and the compiler checks your work, but lets some things slide (like promoting an into to a long int) and lets you tell it to go away and let you do what you want if you really need to by casting to void* and such?
>>
>>51521357

>not using ROOT's C++ interpreter to prototype your C++ projects, completely deprecating python's pro of 'easy prototyping'
>>
>>51521357

One could write python like:
def foo(name: str, age: int) -> str:
print('Hello {0}, you are {1} years old'.format(name, age))


It works, but for some obscure reason, there is no option for the interpreter to check type integrity, even at a warning level. I don't get it, you could write safer code this way, if you wanted.
>>
>>51524010
>It works
No it doesn't
>>
>>51521357
Well, you can write recursive anonymous functions with it(otherwise they'd require infinite expansion of an argument's type)
>>
>>51524036
It does with version 3.5, just tested the code snippet.

However, the "type declarations" are just syntactic details, benefiting the human writing and reading the code.
>>
>>51524051
fix :: (a -> a) -> a
fix f = let x = f x in x
>>
>>51524133
Don't U MENA
newtype Fix f = Fix { unFix :: f (Fix f) }
>>
>>51524196
not really
>>
Easy to implement duck typing.
http://ideone.com/WdujFO
>>
>>51524214
Mr >>51524051 is talking about types, you posted value-level generic recursion.
>>
>>51524242
He was talking about writing recursive anonymous functions, and that's what fix is for.
>>
>>51521357
Daily reminder you should kill yourself.
>>
>>51524258
Oh you're right. Type-level fix does resolves his assumption of
>(otherwise they'd require infinite expansion of an argument's type)
though.
>>
>>51524380
Oh, yeah, it's right. There's no theorical limitation for avoiding infinite types though, it would even be possible to teach GHC to reason about them (according to Richard iirc).
>>
>>51524010
Please refrain from using Python 3 because it's deprecated by Python 2.7
>>
>>51524051
You can easily write recursive anonymous functions in Haskell and have them infer.
It has been proven undecidable to infer polymorphic recursion, but we can quite happily type check it in Haskell if there's a type annotation.
>>
>>51524010
The one thing I actually like about java other python is the ability to define multiple versions of a method with different types in each constructor.
You can do the same thing in python by checking isinstance() for all the different combinations, but it can quickly turn into a mess.
Thread replies: 22
Thread images: 1

banner
banner
[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y] [Home]

All trademarks and copyrights on this page are owned by their respective parties. Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
If a post contains personal/copyrighted/illegal content you can contact me at [email protected] with that post and thread number and it will be removed as soon as possible.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com, send takedown notices to them.
This is a 4chan archive - all of the content originated from them. If you need IP information for a Poster - you need to contact them. This website shows only archived content.