HNHacker News
TopNewBestAskShowJobs

ReflectedImage

476 karma · joined May 12, 2020

submissionscomments
ReflectedImage··on Strong static typing, a hill I'm willing to die on
No the dynamically typed language is not typed, the variable grows in size indefinitely to fit the number.

Dynamically typed languages are more powerful languages that can handle problems like this correctly.

ReflectedImage··on Strong static typing, a hill I'm willing to die on
I think we are at max reply depth but here is the trivial dynamically typed solution to the problem: https://pastebin.com/UZvB5YD1

It's a little bit simpler than anything you will get in an statically typed language. It works for integer and floats of any size. It even works for lists!

You can't do that in a statically typed language without a ton of code.

ReflectedImage··on Strong static typing, a hill I'm willing to die on
The code you posted is incorrect and full of bugs. For example, if A is 9223372036854775807 and B is 10, then you will get the incorrect answer. Try it out if you don't believe me.

Another example is A is -9223372036854775807 and B is -10. Again you will get an incorrect result.

Once you finish fixing these bugs it will be at least 100 lines long. The dynamically typed version of the code is just A + B.

"a lot of this debate just ends up being dynamic programmers who are unaccustomed to using static types at all"

Static typing is objectively the inferior approach. It's just that people are too lazy to learn how to code with two different typing systems.

Overall statically typed programmers only code at 1/3 of the speed as their dynamically typed counterparts. Of course, if you have only ever done statically typed programming, you are not going to understand how bad it is in comparsion.

ReflectedImage··on Strong static typing, a hill I'm willing to die on
Roughly stuff like templating, abstract base classes, generics and non-trivial user defined types.

Consider a simple program that adds 2 numbers: a & b together. In a dynamically typed language, this would be a + b. In a statically typed language, once you consider overflow and underflow, you will likely have a hundred lines of code.

This creeps up again in JSON parsing where the types really are defined at runtime.

But the most general case is people creating complex and hard to understand types in their code, which they then export to unsuspecting developers to use. e.g. The type of stuff that forced C++ to introduce the auto keyword.

ReflectedImage··on Strong static typing, a hill I'm willing to die on
Well Java syntax is very verbose, but I'm referring to the effects of static typing on the program structure.

Dynamically typed programs have much simpler structures and are much easier to reason about and test than their static typed counterparts.

The larger the program you write with static typing, the worse it becomes compared to it's dynamically typed counterpart. The internal complexity of statically typed programs grows at a much higher rate. This increases development times and decreases program correctness.

Through I don't think I can really do a fair comparsion with a functional language like Scala. I've only used Scala for 2 weeks on a single project. Functional languages tend to increase code correctness by trading away performance.

ReflectedImage··on Strong static typing, a hill I'm willing to die on
I'm too lazy to learn how to use something isn't a very good argument :)
ReflectedImage··on Strong static typing, a hill I'm willing to die on
It actually does.
ReflectedImage··on Strong static typing, a hill I'm willing to die on
There are tons of other sources saying the same thing. Static typing might be the popular fad on Hacker News but all the evidence points against it.
ReflectedImage··on Strong static typing, a hill I'm willing to die on
Sadly, it still took 4 days to clear the deadlocks out of my Rust program.

No, my mental model is removing the type checker allows me to write shorter, more concise and higher quality code. Dynamic typing enables much better code styles than static typing.

> the type systems helps drive design

Ahh you are an complexity merchant, if only I made my code more complicated all my problems would be solved. I'm afraid not, the more complicated your code the worse it is.

No I'm afraid, I have actual real commercial experience of doing both styles of software development, the dynamically typed code is the better approach by far.

It's not that I don't understand you, it's just what you are saying is a load of rubbish. :p

ReflectedImage··on Strong static typing, a hill I'm willing to die on
"you should, because in production your program must endure orders of magnitude more variety in inputs, uptime, and runtime conditions than the test suite can exercise. it can and will get into weird states you didn't anticipate. yes, you can fuzz, yes you can property test, I know all about that. those things are good. but I don't get why you wouldn't also use a static type system to provably rule out classes of problem across all possible code paths. why settle for less?"

Because type errors in unit tested code are basically non existent. It's a fictional problem and as such there is no point in spending real resources chasing fictional problems.

There is plenty of research that shows that static typing gives no benefits (statistically insignificant) when it comes to software correctness.

What you are asking is why shouldn't the local government spend money on a Yeti patrol to protect the general public against Yeti's? The Yeti patrol will eliminate an entire class of problem (Yeti attacks).

ReflectedImage··on Strong static typing, a hill I'm willing to die on
*statistically insignificant
ReflectedImage··on Strong static typing, a hill I'm willing to die on
Dynamic typing triples your software development speed and decreases bugs in delivered software by two thirds.

You can either hire 10 dynamic typing software developers or 30 static typing software developers. Businesses which choose to hire 30 static typing software developers will fall to the companies which hired 10 dynamic typing software developers. It's pure economics.

Static typing fills your codebase with bugs. Whilst an inexperienced software developer might not understand why static typing increases rather than decreases bugs, you can see the increase in bugs in research papers on the topic. As plan as day.

(Hint: You have made your code more complex by using static typing and more complex code contains more bugs.)

ReflectedImage··on Strong static typing, a hill I'm willing to die on
You fill your codebase with additional information for the compilers' benefit and not the benefit of the software developer.

In any large statically typed program, 2 out of the 3 lines exist to make the compiler happy rather than the software developer.

Static typing is a terrible terrible way to develop code once you start measuring it objectively.

ReflectedImage··on Strong static typing, a hill I'm willing to die on
As someone who codes in both static and dynamic typed languages commercially, 3x is around the correct figure.
ReflectedImage··on Strong static typing, a hill I'm willing to die on
Type bugs are so rare in regular code that it's significantly insignificant when measured during research studies. From a code correctness point of view, static typing is simply speaking useless.

You should have spent the time statically typing your code on writing more tests.

ReflectedImage··on Strong static typing, a hill I'm willing to die on
Yes but if you were Tabula Rasa you would ship out software features 3x faster with significantly less bugs using dynamic typing than if you used static typing.
ReflectedImage··on Strong static typing, a hill I'm willing to die on
You restrict the code area you need to search via strong encapsulation.
ReflectedImage··on Strong static typing, a hill I'm willing to die on
Yeah but IReadOnlyStream relies on the developer knowing what an IReadOnlyStream actually is.

You would be better off using dynamic typing and returning an Iterator.

The dynamic typing route of a small number of language defined types is far better than any developer declaring their own types whenever they want.

Why? Because it's simpler and simpler code is faster to write and easier to test.

ReflectedImage··on Strong static typing, a hill I'm willing to die on
Static typing sounds great to Junior Software Developers, who don't properly understand what the problems the software they write needs to solve.

Static typing allows me to check the types are correct! In practice, typing related errors are a very rare bug so it isn't very useful.

Static typing allows me to check things at compile type. In practice, this means waiting around for things to compile and lots of dead time. The larger the project get the longer the compiles times.

If performance doesn't matter, dynamic typing is pretty much always the way to go. You get the code out faster, so you have time to write more tests and you can throw away the code faster. Cause in the real world, code is a churning thing that evoles with the business requirements. Not some static build once thing that static typing and Junior Software Developers assume.

ReflectedImage··on Strong static typing, a hill I'm willing to die on
Statements like: "The fact that strong static types makes the code self-documenting is the reason I vastly prefer it."

is exactly the reason why you shouldn't be use static typing. We have a developer here who doesn't document any of their code and thinks that a good thing. Whereas in the dynamic typing world, they would be forced to use the good practice of documenting their code.

Code is never self-documenting, there are research studies on it.

ReflectedImage··on Strong static typing, a hill I'm willing to die on
What you are complaining about is completely solved via microservices.
ReflectedImage··on Strong static typing, a hill I'm willing to die on
Nope, static typing triples the average bug count of a piece of software. Using static typing add complexity to your code and complexity leads to more bugs.

Static typing is where you significantly decrease your development speed and significantly increase your bug count in order to increase the performance of your software.

ReflectedImage··on DHH removes TypeScript from Turbo framework
DHH made a good decision and hopefully more framework developers will follow in time.

Now, I'm sure there are a lot of bad software developers out there who don't understand why it's a good decision but there are always going to be bad software developers out there, it doesn't mean you should listen to them.

ReflectedImage··on Germany, Switzerland, Austria join call for return to budgetary discipline
Ahh the UK destroy your economy approach. Hint: It's a bad idea.
ReflectedImage··on CNET is deleting old articles to try to improve its Google Search ranking
Several reasons why it works. First is the page rank algorithm will give the other pages on the site a higher score. Per the spec.

Second is there could be spam links pointing to old CNET articles that need to be wiped from CNETs site spam score.

ReflectedImage··on Thames Water to datacenters: Cut water use or we will
The plan is not to have water in London? I'm not sure where you are going with this?
ReflectedImage··on The C Programming Language: Myths and Reality
It's not my solution, it's just something I've seen done in commercial C software.
ReflectedImage··on Analysis of whether unit testing obviates static type checking (2012)
Static type checking takes a long longer developer time wise and does a much worse job than unit tests.
ReflectedImage··on Analysis of whether unit testing obviates static type checking (2012)
So I think you are running on a false premise here efarrer.

The false premises is that anyone ships bug free code. It can be done but it's stupidly expensive. Formal methods Z proofs, etc.

Unit testing and static typing are 2 different techniques which eliminate bugs.

The question that needs to be answered is which of the 2 techniques is the most effective per developer hour spent.

Unit tests do not caught all the bugs that static typing would catch nor does static typing catch all the bugs unit tests would catch. That's not an useful observation.

Nor is there a moral here that you should be doing both, doing both is expensive and costs $$$.

ReflectedImage··on Analysis of whether unit testing obviates static type checking (2012)
If you spent a day writing unit tests you will eliminate more bugs than if you spent a day writing types.

And that's all that matters. Unit tests are the more effective technique.

Yes obviously static typing doesn't catch all the bugs caught by unit tests or vice versa. But it's a meaningless thing to say.

← PreviousPage 7 of 19Next →