Hacker News new | comments | ask | show | jobs | submit login

What do strong types get you? Being I write a bunch of C# at work and almost all JavaScript at home I find types very limiting, so I still don't get why?

When I implement a type zoo that models the problem I am solving I do not need to spend as much time reasoning about the semantics (with a good IDE) and the compiler warns me if I've done something odd and won't run the program if I've done something wrong.

With a strong typesystem I can first figure out what I need to do, then write it (like a fews of hundreds of lines), compile it and be fairly confident that the program runs almost correctly. Static typesystem does not help with the bugs that have to do with bugs in algorithms (wrong iteration order etc.) but it let's me concentrate on those parts mostly.

Static typing also functions as a self documentation - I see the intended program flow from the type signatures and do not need other means necessarily to figure out what the program flow is.

To me types are like lego bricks and dynamic languages are like ducktape - both have their uses.

I just find them hand holding and limiting.

Well said!

I love it when I can get the computer to hold my hand and limit my actions. Personally I feel the limits of my cognition and enjoy when the computer assists in proofing the correctness of my programs.

That way I can be more sure I don't do anything that breaks the program logic and that developers that come after me remain within the boundaries of correctness when modifying my code. Types don't help in design but they help in forming a coherent whole.

I've figured out there are two constraint systems I can use to effectively write correct programs. One of them is a typesystem and the second is set theory.

Granted, the most mainstream statically typed languages come with so much syntactical baggage and lack type hinting (C++, Java, C#) that they can effectively hide the elegance of types as a problem modeling tool.

Types can be used just as a non-value adding anal-retentive bureaucratic baggage but that's not how they should be used.

I'm professionally mostly a C++ programmer but did not really 'get it' until I familiarized myself with functional languages (Ocaml, F#) which helped me understand how to actually leverage a typesystem to help me write correct code instead of 'just using typedeclarations because the compiler is too stupid to figure out what I want to do'. To be precise, the languages themselves did not really teach me that much but the learning materials I used with those language did.

When I need to do something small data processing in a jiffy I usually pick Python. For small programs few-liners in dynamic languages are usually a win.

>One of them is a typesystem and the second is set theory.

What do you mean with set theory? I'm asking because languages like Ceylon and Whiley have union and intersection types which are basicially set theory.

Sorry, that was a bit odd way of putting it, perhaps.

What I mean that I first model a particular problem on pen and paper as a group of set operations and identities and then implement that using container operations. I.e. a set as a container, or a particular subset of the elements in the container. I totally depends on the program whether that simplifies things or not.

But for instance, I usually find that rather than adding lots of state variables to entities I model state as those objects belonging to various sets. I.e. store object Id in a list pertaining to a particular property.

This way subsystems can be implemented in a non-invasive, and extensible way. The set operators (union, difference etc.) do not need to be implemented explicitly, rather just figure out what is the most simple isomorphic routine to compute the output for that particular operation.

I find Typescript catches all sorts of typos that get missed in pure JS because I don't have 100% code coverage tests. Sure a JSLinter might catch some of those, but it won't find mis-spelled method names.

Other benefits include not having to remember the 'interesting' rules around 'this' in pure JS (though that occassionally slips through in libraries that use it). Having saner (to my eyes) syntax for modules and encapsulation. And having intellisense support in Visual Studio reduces the effort of writing the code.

Both great points!

> all JavaScript at home

Every language works pretty well for solo personal projects. It's when you scale up to dozens of team members and millions of lines of code that some things don't work as well.

I'm sorry, are you hoping I provide an all encompassing answer that convinces you of its usefulness? I can't provide that. Like I said, its simply a matter of personal preference. You find types limiting, others find them helpful.

Applications are open for YC Summer 2019

Guidelines | FAQ | Support | API | Security | Lists | Bookmarklet | Legal | Apply to YC | Contact