|
|
Subscribe / Log in / New account

Missing the point of loose languages

Missing the point of loose languages

Posted Dec 17, 2021 1:38 UTC (Fri) by rdeforest (guest, #153619)
Parent article: Wrangling the typing PEPs

I've only read the intro paragraph of the article and the first comment, so this may be redundant or already refuted elsewhere, BUT!

Languages like Python, PHP and JavaScript gained enormous popularity BECAUSE the users didn't have to deal with types. The barriers to entry were low and the things type information help with didn't matter enough. Adding type information to these languages after they've become popular misses the point of how they got popular in the first place. I would even posit that it objectively worsens them. The eventual of triumph of TypeScript over JavaScript would refute my claim, if it happens.

I would suggest as an alternative to extending existing dynamic languages, that those seeking these features instead choose languages built around them. But those languages (Haskel, I'm looking at you) don't have the enormous communities and the network effects they bring...

In other words, Richard P Gabriel was right all along: "Worse Is Better".


to post comments

Missing the point of loose languages

Posted Dec 17, 2021 15:56 UTC (Fri) by tnoo (subscriber, #20427) [Link] (3 responses)

Exactly my feeling!

Python was (still mostly is) so clean and at the same time powerful enough for all my use cases (data analysis, glue language for numerical codes). And just perfect for teaching introductory classes for scientists.

I highly welcome a generic type annotation system that codes like Cython make use of. But imposing a mandatory rigid typing system is the wrong approach. If strong static typing is needed, there is a big choice of other languages out there (go, rust, C++, Java, Haskell, ....ML).

But of course, this also comes with a high cost. Besides the need for compilation, for C++ we have the Design Patterns (Gang of Four) with Facade, Adapter, Decorator patterns etc that are not necessary in Python because of Duck-Typing.

For me Python is getting less and less attractive if more line noise is added, and simple code is becoming unreadable. From a comment above

def foo(a: object, b: type[T]) -> TypeGuard[T]:

does not look and feel like Python anymore. Why not use Haskell right away?

Missing the point of loose languages

Posted Dec 17, 2021 16:57 UTC (Fri) by mpr22 (subscriber, #60784) [Link] (1 responses)

> Why not use Haskell right away?

My understanding is that a lot of people who love static typing etc. still bounce off of Haskell.

(Partly because a lot of the literature around Haskell has a reputation for using terminology that even many CS graduates are unfamiliar with.)

Missing the point of loose languages

Posted Dec 19, 2021 10:15 UTC (Sun) by smurf (subscriber, #17840) [Link]

Haskell is one of these "you need to wrap your head around these new concepts, otherwise you'll feel like bashing your noggin against a brick wall is the saner option when you actually start coding in it" languages.

That takes more up-front time and effort than most people want to spend. Plus everybody else in your team needs to do the same thing.

I was looking into using Elm (a Haskell-ish language for client-side web programming; transpiles to Javascript of course) recently. Great idea, but where do I get the month that's not in the calendar from, so that I can be up to speed on it?

Missing the point of loose languages

Posted Dec 17, 2021 19:11 UTC (Fri) by Wol (subscriber, #4433) [Link]

> I highly welcome a generic type annotation system that codes like Cython make use of. But imposing a mandatory rigid typing system is the wrong approach. If strong static typing is needed, there is a big choice of other languages out there (go, rust, C++, Java, Haskell, ....ML).

The problem with my favourite language is everything is of type string (or variant). The advantage of this same language is that everything is of type variant. It would be lovely if I could just restrict things by having the default as variant, but options like "integer", "number", and stuff like that available ...

(Said favourite language being DataBASIC, btw)

Cheers,
Wol

Missing the point of loose languages

Posted Dec 21, 2021 18:55 UTC (Tue) by tbelaire (subscriber, #141140) [Link]

I hear you, but then I had to deal with upgrading some email lib from 2 to 3 which was mixing bytes and strings and it was so much easier to do in stages by first annotating the functions with types, and fixing mistakes, then doing the py3 upgrade.

Until I started annotating with types, I was dealing with "Oh, that's a bytes regex, doesn't work on str", on line xxx. And other errors, where as being careful and making sure the encoding/decoding happened exactly once, and using the types to check that across all the functions and not playing wack-a-mole with errors is so much nicer.

And when I'm working with pandas, I do want to know if I have a DF with only one column vs a Series, as the operations are different, but it's just `df['col'] ` vs `df[['col']]` to get each one. (I think). So I already need to check and keep the types separate, why not ask the compiler for help?

Missing the point of loose languages

Posted Dec 27, 2021 8:26 UTC (Mon) by NAR (subscriber, #1313) [Link] (1 responses)

Erlang is one language where the type system was added later. In my experience it's most useful for documentation - now there's a standard way to specify the type of the arguments in an API function. There's a tool (dialyzer) that checks for type errors: I worked on a project where the type annotations were added on later, about 95% of the errors it found were in dead code (so not covered by unit tests - one such example was a branch that only executed if the current date was before 2000, and we were adding the type specs in 2010). If there is a decent test coverage, there's little (but not zero!) value the type system can add.

Missing the point of loose languages

Posted Dec 27, 2021 9:59 UTC (Mon) by smurf (subscriber, #17840) [Link]

IMHO the best thing about explicit typing is documentation. I can see what a variable/parameter is supposed to be without checking external and possibly-out-of-date docs (including broken comments right above the function in question …).

A decent set of test cases is great for checking that the expected cases work as expected. The problem is that some [ft]ools insist on tests for each and every unexpected case, even if logically impossible to reach, while the real problems (i.e. those conditions you didn't even think of being remotely possible when you wrote the code) slip under the radar.


Copyright © 2025, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds