Earlier quoted context omitted.
OTOH, sometimes the CSV munger one writes today is still in use five years later, when the input CSV has a UTF-8 character for the first time, and suddenly it crashes and no-one knows where the bug could even be.
UTF-8 support is completely orthogonal to static typing. There are dynamically typed languages that handle it great, and statically typed languages which have garbage support for it. In general I know what you mean though. “What if this CSV parser turns out to be really important?” If you think there’s a high probability of that, do it in a statically typed language then. 99.9% of data munging I’ve done have been thr…
Things I Was Wrong About: Types
461–468 of 468 posts
Re: Things I Was Wrong About: Types
#462Earlier quoted context omitted.
I think there are a few reasons why people develop an impression that types are overhead: * People who are learning to code are writing lots of code but not reading very much code. I think types do the most work when trying to understand existing code. * Lots of people's first experience with typed languages was something like C++ or Java back when they had much worse error messages. * The kind of mistakes you make w…
Also, many beginner programmers work on small code bases in every sense of the word. These days I will often have to glue together some tiny part of two or three enormous APIs, some of which are "auto generated" from some other system. Think LINQ-to-SQL or WCF. It's amazing when you can take a 100 MB chunk of code, and simply "navigate" to the thing that you want using tab-complete, in the sense that "somefactory.som…
The last couple of years I’ve developed stuff in haskell and elm, but I’m currently getting back into python and javascript. And I’m sniffing around, trying to figure out how to utilize typescript and python type annotations in an ergonomic way, that doesn’t feel like too much overhead.
I’ll easily admit that it’s not as easy to reach the same kind of benefit in those languages.
The magic sauce really is (ideally as global as possible) type inference combined with programming primarily via expressions instead of primarily via statements, with appropriate language support of course.
Re: Things I Was Wrong About: Types
#463Earlier quoted context omitted.
It can still feel that way. Take C++ for instance: Foo f = fooFromElsewhere; // explicit typing (old) auto f = fooFromElsewhere; // type inference (new) Now what happens if we change the type of `fooFromElsewhere` from `Foo` to `Bar`? With the old way, we need to change the code to: Bar f = fooFromElsewhere; With type inference however, you won't need to change that line at all. And if the new type has enough in comm…
In cases where Foo and Bar are stricly incompatible, auto is fine here. In cases where Foo and Bar are similar and might cause trouble, auto shouldn't be used here.
Re: Things I Was Wrong About: Types
#464Earlier quoted context omitted.
I went a similar path, PHP to C#, and never looked back. When I had to switch to Node for one job I was pulling my hair out constantly (and quite literally) because of stupid things that would never have happened in what I called a “real” language (that being a typed, compiled one). I mean for $deity’s sake, there weren’t even any dependency injection options at the time and many many times it turned out a bug I intr…
The other issue with dynamically-typed languages is that the language sometimes "helpfully" fixes the types for you. I came across one JS project that said this: for (var i = 1; i != Math.pow(2, 16); i Replacing Math.pow(2, 16) with 1 (It's been a while since I coded PHP, but my recollection is that PHP tries to pull a strings-are-integer tricks a few times).
Re: Things I Was Wrong About: Types
#465Earlier quoted context omitted.
Php is dying? Didnt know.
PHP is literally the only language banned in some major tech companies because of how dysfunctional it is.
Re: Things I Was Wrong About: Types
#466Earlier quoted context omitted.
PHP is literally the only language banned in some major tech companies because of how dysfunctional it is.
PHP is quite weak in the U.S, I can only assume that's why you got the impression it's dying. In Europe it couldn't be more popular. I'm not here to "defend" PHP, I use Ruby, but living in the Netherlands you'd be amazed how many companies use it. Ruby is a very small niche here in comparison.
Re: Things I Was Wrong About: Types
#467Earlier quoted context omitted.
> The thing was 50 lines, and I was lost. The key to writing type-less code is making it so simple that you could cry. Avoid being clever at all costs. However, it's almost the exact opposite when you have a nice compiler checking everything, you can be mighty clever and know that it will work. I'm lucky in that we can solve a problem in a myriad of languages, depending on if it needs to be "realtime", or can be prec…
> The key to writing type-less code is making it so simple that you could cry. I can't help but interpret this as "the key to writing type-less code is choosing problems so simple that you could cry" . In other words, dynamic typing doesn't scale. When I have a very simple problem to solve, sure, I won't mind dynamic typing. For anything worth more than an hour of coding however, I'll definitely reach for more reliab…
Re: Things I Was Wrong About: Types
#468Earlier quoted context omitted.
I'm not trying to deny Java's influence, just saying that it's bad. I do think it was worth bringing up (I upvoted your top-level comment), but mostly because we need to recognize the damage it has caused to the discussion around typing. People try to talk about "dynamic vs static", or worse run studies, when their only static language is Java. Their arguments are nonsense and their studies are wasted as far as I'm c…
Seems fair. What I wonder though is what about Java is bad? Like, is the lack of inference the key differentiator between good static type systems that help, and those that get in your way and slow you down? Or are we actually claiming something more, that the paradigm of Java prevents its type system from being useful. Thus we're as much having a conversation about type systems as we are about functional vs imperati…
Lack of type inference is part of it - Java's type system gets in your way more than better type systems due to it. But the bigger part is that Java's type system doesn't give you the tools to model things properly. One big issue is nulls - no matter what you do with types, you have the possibility of null constantly in your way. The other is the lack of sum types, without which many things that you want to model become difficult, verbose, and error-prone.