Re:Pike – a dynamic programming language with a syntax simil...
by 2mlWQbCK on Tuesday April 22, 2025 @01:04PM
(#43764221)
Not sure what they are referring to, but it may be that you can declare things as having one of several types (e.g. int|string|void) or even that something can be any type at all (i.e. turn off static type-checking for that thing)? I do not think the type-checker will ever randomly decide to just not check a type given that you have provided types for it to check, but it was a long time ago since I had to read or write any Pike code.
Re:Pike – a dynamic programming language with a syntax simil...
by pansa2 on Tuesday April 22, 2025 @01:26PM
(#43764410)
Looks like there’s a `mixed` type, variables of which can hold values of any type. But at least that’s something you can `grep` for.
A more subtle issue with type hints (as in TypeScript/Python, not sure if this applies to Pike) is that there are ways to work around the type system. You can get, for example, a variable of type `int` that actually holds a `list`:
Re:Pike – a dynamic programming language with a syntax simil...
by metalliqaz on Tuesday April 22, 2025 @01:08PM
(#43764263)
I can turn off static type checking for a thing in C by using `void*`
Re:Pike – a dynamic programming language with a syntax simil...
by speed_spread on Tuesday April 22, 2025 @12:46PM
(#43764074)
Groovy has that too and it's quite the anti-feature. Pretend static typing is worse than useless, it's the MAC-10 of footguns.
Re:Pike – a dynamic programming language with a syntax simil...
by ch4s3 on Tuesday April 22, 2025 @01:09PM
(#43764265)
> it's the MAC-10 of footguns
At least it might be shooting Nulls.
Re:Pike – a dynamic programming language with a syntax simil...
by cmrdporcupine on Tuesday April 22, 2025 @02:02PM
(#43764730)
Sounds like Julia, too.
Also you'd think having the type signature would help with performance, but in some cases it can cause the VM to enforce a runtime type check where it wouldn't have before, imposing worse performance.
Re:Pike – a dynamic programming language with a syntax simil...
by yobbo on Wednesday April 23, 2025 @01:07AM
(#43768781)
The compiler will complain about incorrect types and (?) infer types where possible. "Mixed" types are resolved at runtime.
There is a strict_types mode that will increase warnings/errors.
One of the problems with Pike is that the mechanics of this and other things are effectively undocumented so you have to learn by experimenting and reading the source.
It seems that these are (unsound) type hints, years before TypeScript made them cool:
> "If your program tries to put one type of value in a variable which was designed to hold another type of value, Pike may detect this" [emphasis mine]
https://pike.lysator.liu.se/docs/tut/fundamentals/index.md#t...