4 ms·
With a proper type system you don’t need to run your code 50 times a minute.
by the_gipsy 5y ago
With a proper type system you don’t need to run your code 50 times a minute.
- Implicated 5y agoAs someone who isn't perfect, it's nice to be able to quickly iterate on ideas.
- rbanffy 5y agoYou still can. It’ll just stop you before you get to a running web application that may be doing something wrong with the data that goes through it.
- smt88 5y agoIterating on ideas is much quicker when the compiler tells you when you made a mistake or failed to change your code after changing your mind.
- thevagrant 5y agoHonestly, I don't see much difference. You learn either way. People may have preferences, that's fine. A compiler isn't a magical tool that creates bug free code.
- root_axis 5y agoThe difference is massive. Computers are many orders of magnitude better at this kind of thing than humans, especially in a large application where changing the shape of a single data structure can have cascading effects throughout the entire code base; you simply will not catch things a typechecker will.
- thevagrant 5y agoAn IDE does provide some help. Certainly, I'm not arguing against compilers. I was merely commenting on the "iterating on ideas is much quicker".
- smt88 5y agoA compiler with a good type system catches a mistake instantly instead of at runtime. The difference in time it saves the dev can be anywhere from a few seconds to minutes per mistake. Multiplied by hundreds of mistakes, it makes a huge difference. And that's not even getting into the advantages of better autocomplete for external libraries. As someone who has written many thousands of lines of PHP, JS, TS, C#, Java, and Python, I now find it baffling that someone would start a project in 2021 without a great type system as a safety net.
- djbusby 5y agoHello me! Nice to meet me!
- Lhiw 5y agoWith a proper type system you can't. What a useless thing to say. The ap is talking about a tight feedback loop and you decide to make a condescending comment about type systems. Go back to twitter.
- chubot 5y agoCode that passes type checks can also fail to solve the user's problem, make 10,000 database calls, or render a page that is completely unreadable. The human in the loop is a good thing. All things being equal, the type system is also a good thing, but what usually happens is that you end up checking your page once a minute or once every 10 minutes, not 50 times in a minute. That difference can make or break a project.
- the_gipsy 5y agoAnd for those cases you should use tests, not a manual procedure. Of course you will need some manual procedure, and e2e tests, but not “50 times a minute”. That is just frustrating.
- lolinder 5y agoIt depends a lot on what you're working on. If you are building a front end with PHP as your templating language, then yes, the ability to instantly see your changes is huge. In my experience, when working on back end, the difference isn't that significant because you really want to be using unit tests anyway, not constantly interacting with the front end to test your work. In those back end cases, having a strong type system makes a huge difference. I'm working on a project that has a legacy PHP code base and a new JVM code base. What kind of naturally happened is that we end up doing most of our front end work in PHP and all of our new backend work on the JVM.
- noduerme 5y agoI've rewritten a ton of legacy PHP services / page generation code into NodeJS over the last couple years. I know PHP inside-out and love it the way you love... um, something fugly like an old futon. It's really nice to be working in Typescript on both ends now, to have share modules and data models between server and client codebases. But one thing I do miss about PHP is not needing to make sure the server restarts on every backend code change. Nodemon and PM2 are both pretty good about this, but it's that one out of ten times they don't restart and I spend a minute or two wondering what I missed before realizing they didn't restart; happens a few times a week and drives me up the wall.
- smsm42 5y agoI never seen any practical proof of that often repeated claim. Unless you define "proper" in an absurd way that has absence of bugs as the part of its definition, I've seen roughly as many bugs and as much time spent debugging in strongly typed languages as I have in weakly typed ones. Sure, some kinds of bugs go away, but they're replaced with different ones.
- the_gipsy 5y agoJust try it out. I am not saying that a type system will find all bugs. It will stop you from running incorrect code “50 times a minute”. Then you should have tests. Lastly you must also do some manual procedure (or run slower e2e tests). Doing all this yourself constantly is just frustrating.
- smsm42 5y agoI did. I've been doing it for over 3 decades, and worked with all kinds of languages. Of course, it's only my own anecdotal data set, but no, "once you try strongly typed language you'll see how magnificent it is" doesn't work anymore. I tried, and it's not that it's bad - it has its advantages - but it's not the bugless paradise that fanboys promise. And also I learned that running incorrect code 50 times a minute is not bad at all - actually, it's a pretty good rapid prototyping technique. Some people never launch their code until they are sure it's 100% perfect, I am not one of those people.
- path411 5y agoWell php has strong typing built in now and they have been iterating on it every release. It's well ahead of native js. I can't imagine having any real complaints on using 8.x php for a back end these days.
- bardan 5y agoI still dislike the constant $ and ->, today it just feels like extra typing. Otherwise I agree with you.
- thinkindie 5y agoI'm with you. This is the only complaint I have about the language itself.
- jv22222 5y agoTrying to imagine php without $ and all I can think is... :o
- jhgb 5y agoShow me a practical type system that rejects all programs with logical bugs.