Better HN
topnewbestaskshowjobs
Log inSign up

ReflectedImage

476 karma · joined May 12, 2020 (6y ago) · 570 submissions

Submissions

comment 3y ago · link · parent

Dynamically typed programs can be structured in far better ways than statically typed programs.

>Both programs have the same underlying structure No they don't, this is just a massive gap in your knowledge.

> try refactoring Python code without type hints in a large code base

I've done that on multiple occasions, the test suite is fine, thank you very much.

comment 3y ago · link · parent

You have errors coming from using static types. Static typing blew up a space rocket, if you weren't aware.

JavaScript is terrible because it was built over 3 decades by different competing browser vendors.

comment 3y ago · link · parent

That problem is also solved by dynamically typed languages. Your IDE picks it up.

comment 3y ago · link · parent

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.

comment 3y ago · link · parent

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.

comment 3y ago · link · parent

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.

comment 3y ago · link · parent

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.

comment 3y ago · link · parent

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.

comment 3y ago · link · parent

I'm too lazy to learn how to use something isn't a very good argument :)

comment 3y ago · link · parent

It actually does.

comment 3y ago · link · parent

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.

comment 3y ago · link · parent

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

comment 3y ago · link · parent

"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).

comment 3y ago · link · parent

*statistically insignificant

comment 3y ago · link · parent

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.)

comment 3y ago · link · parent

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.

comment 3y ago · link · parent

As someone who codes in both static and dynamic typed languages commercially, 3x is around the correct figure.

comment 3y ago · link · parent

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.

comment 3y ago · link · parent

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.

comment 3y ago · link · parent

You restrict the code area you need to search via strong encapsulation.

comment 3y ago · link · parent

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.

comment 3y ago · link · parent

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.

comment 3y ago · link · parent

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.

comment 3y ago · link · parent

What you are complaining about is completely solved via microservices.

comment 3y ago · link · parent

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.

comment 3y ago · link · parent

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.

comment 3y ago · link · parent

Ahh the UK destroy your economy approach. Hint: It's a bad idea.

comment 3y ago · link · parent

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.

comment 3y ago · link · parent

The plan is not to have water in London? I'm not sure where you are going with this?

comment 3y ago · link · parent

It's not my solution, it's just something I've seen done in commercial C software.
1
678
19