News for hackers. Stuff that matters.
Re:Ask HN: What are your favorite developer-efficiency tips? by city41 on Friday May 08, 2020 @10:36PM (#23121722)
The biggest boost in productivity I've had in recent years is switching back to a statically typed language. TypeScript in my case. You can absolutely refactor and change course _so_ much quicker and with virtually no regressions at all. Just the other day we realized a feature I was building didn't handle an important case, and I had to really change the approach. Doing it in a JavaScript would have been dramatically harder.

The investment you have to make to really grok static typing is quite large. It took about 2 years for me to be really comfortable in TS. But you'll have to claw it out of my cold dead hands now.

Before switching to web dev, I used to work in Java, C#, C++, etc. But I've been away from static typing for about a decade now. I completely forgot how beneficial it is.

Re:Ask HN: What are your favorite developer-efficiency tips? by ggregoire on Friday May 08, 2020 @11:54PM (#23122161)
> The investment you have to make to really grok static typing is quite large. It took about 2 years for me to be really comfortable in TS.

That sounds a bit exaggerated from my experience. If anyone interested in TS got discouraged reading your comment, it took between like 2 days and 2 weeks for my team to be really comfortable in TS. If you already know JavaScript and if you already have some experience with statically-typed languages, TS is literally JS with static types.

Re:Ask HN: What are your favorite developer-efficiency tips? by city41 on Saturday May 09, 2020 @12:25AM (#23122312)
Maybe my choice of the word "comfortable" was incorrect (although I would say "grok" was a spot on word choice in this context). It took me a good while to get the point where no matter what I encounter in TS, I feel pretty confident I can arrive at understanding it. The type system is very powerful and there are some deep rabbit holes you can find yourself in.

For example, if you can follow this blog post after only two weeks then you are much smarter than me: https://medium.com/free-code-camp/typescript-curry-ramda-typ.... This is a pretty extreme example, but sometimes you hit crazy types or crazy type errors like this.

But I would agree it doesn't take all that long to feel comfortable enough with TS to be productive with it.

Re:Ask HN: What are your favorite developer-efficiency tips? by ggregoire on Saturday May 09, 2020 @01:00AM (#23122438)
Interesting article. :)

And there is a useful library linked at the end: https://github.com/pirix-gh/ts-toolbelt.

Re:Ask HN: What are your favorite developer-efficiency tips? by lostmsu on Saturday May 09, 2020 @12:12AM (#23122252)
To be fair, TypeScript's typing is very overloaded with stuff, and is much more complicated than Java or C#'s.
Re:Ask HN: What are your favorite developer-efficiency tips? by deathtrader666 on Saturday May 09, 2020 @04:03AM (#23123031)
Hence my love for ReasonML / OCaml with the Bucklescript compiler.
Re:Ask HN: What are your favorite developer-efficiency tips? by rhlsthrm on Saturday May 09, 2020 @05:01AM (#23123204)
Do you use ReasonML on the backend as well? Or just something like ReasonReact? I've been interested in Reason and still wondering the best way to work it into my NodeJS/React/Typescript stack.
Re:Ask HN: What are your favorite developer-efficiency tips? by itsArtur on Saturday May 09, 2020 @06:41AM (#23123616)
I am not parent comment's author, but I use TS on the backend and I did look into ReasonML. I love most of Reason's syntax and FP in general, but unfortunately, reason/bucklescript ecosystem just isn't mature enough for a serious project. I'd recommend against using it unless you are in some megacorp and you can afford to build general-purpose tooling.
Re:Ask HN: What are your favorite developer-efficiency tips? by mekster on Saturday May 09, 2020 @06:00AM (#23123434)
Doesn't mean it's hard to get started. It only means, if you want to type everything to the detail, you can do it.
Re:Ask HN: What are your favorite developer-efficiency tips? by kortex on Friday May 08, 2020 @10:42PM (#23121744)
Used to love Python. Now, unless it has type hints, not so much. Used to hate static types, or at least I thought I did. Really, I just hated C++ and Java. Go is Bae, trying to learn some rust.

Computers are rigid. The more rigid the lang you talk to them, the less you get bitten.

Untyped python, bash, javascript, just not worth it imho.

Re:Ask HN: What are your favorite developer-efficiency tips? by redis_mlc on Friday May 08, 2020 @10:58PM (#23121819)
FYI: Perl has moderately strong typing, as well as forward references, an excellent debugger and probably the most powerful web framework, mojolicious.

If you're unhappy with how loose python and js are, you might find happiness with Perl.

To enable the checking:

use strict;

use diagnostics;

Re:Ask HN: What are your favorite developer-efficiency tips? by Parazitull on Saturday May 09, 2020 @02:55AM (#23122827)
TL,DR: Try F# or other "impure" ML languages if you want the security of types but you don't like actually typing the types.

I also used to love js / php because because I thought types make the code unnecessarily verbose. After some pet projects with a strongly typed lang (c#) I realized the peace of mind that using types gives. But I still maintain my opinion that types make the code too verbose.

But then I saw the "light" that is F# and I'm here to preach:

F# has types BUT you don't need to type them (most of the time) because it has type inference. F# can be used in the .net ecosystem and most of the time it can replace C#. F# can be compiled to js (although the interop is a bit messy). F# is a better typed javascript than typescript. F# is predominantly functional but you can also write code in the non-functional(ha!) style of your choice. F# discourages you from coding mutable spaghetti F# has decent tooling: VSCode + Ionide + dotnet + paket F# has pipes |>

The bad parts:

F# is not a hard-core functional language like Haskell, but for me this is a positive F# is a functional language which requires a change about how you think about a program. F# doesn't have a huge community F# doesn't give you a lot of job prospects F# doesn't have a lot of 3rd party libraries (but you can use c# libraries in .net or js libraries with fable. You can also mostly port libraries from other functional languages) F# requires you to think about the order of your declaration. Cyclic dependencies are harder to accomplish although this might be a good thing.

Re:Ask HN: What are your favorite developer-efficiency tips? by mjul on Saturday May 09, 2020 @04:41AM (#23123140)
For the good parts, I would add the effortless type declarations to overcome “Primitive Obsession”, the immensely useful pattern matching to ensure you cover all edge cases and what I really found to be the killer feature: Type Providers to enable typed data wrangling in just a few lines.
Re:Ask HN: What are your favorite developer-efficiency tips? by vulcan01 on Saturday May 09, 2020 @12:48PM (#23126237)
It's not exactly what you're looking for, but have you checked out mypy[1]? It is basically static typing for python.

[1] https://pypi.org/project/mypy/

Re:Ask HN: What are your favorite developer-efficiency tips? by kortex on Saturday May 09, 2020 @05:46PM (#23128556)
That's what I meant with "unless it has type hints" but thanks for the link :)

Blue ocean python I pretty much start with hints and interface definitions, the logic follows. Helps me through writing the logic when I have autocompletion of methods.

Re:Ask HN: What are your favorite developer-efficiency tips? by mekster on Saturday May 09, 2020 @06:02AM (#23123444)
It seems type hinting is coming to Ruby 3, which im looking forward to.
Re:Ask HN: What are your favorite developer-efficiency tips? by ProZsolt on Saturday May 09, 2020 @11:21AM (#23125422)
I like Ruby for prototyping and quick throwaway scrips. I can write code really fast in it. Still my favorite language. But reading unfamiliar code or cooperating with others is hard. This is a good step forward in that direction.
Re:Ask HN: What are your favorite developer-efficiency tips? by ric2b on Monday May 11, 2020 @11:49AM (#23143393)
Not in the source code itself, it will be in separate files according to Matt. If you want it in the source code you can use Sorbet today.
Re:Ask HN: What are your favorite developer-efficiency tips? by mekster on Monday May 11, 2020 @02:07PM (#23145124)
Sorbet syntax is like a hack bolted on... I'm not really a fan of it.
Re:Ask HN: What are your favorite developer-efficiency tips? by ric2b on Tuesday May 19, 2020 @07:25AM (#23233647)
Yeah, it's limited by being a library instead of being part of the language itself.
Re:Ask HN: What are your favorite developer-efficiency tips? by mpoteat on Saturday May 09, 2020 @12:22AM (#23122297)
Yeah, TS has one of the most powerful type systems I've come across, with its distributive conditional types and type narrowing logic. Recently I've been using type predicates to "dynamically" expand 'this' in specific clauses.

It's very fun to work with and allows for really safe code.

Re:Ask HN: What are your favorite developer-efficiency tips? by rovr138 on Saturday May 09, 2020 @02:28AM (#23122746)
I can understand the appeal but I sometimes have to work in old code bases where you can’t simply swap things.

What I’ve done is switch whatever I work with to Hungarian Notation.

You know what the variable can hold. You can easily add a test for it. Someone that comes after will be able to know what it is.

It won’t complain, but since you know the type, you can add a quick if to validate that it is what you expect it to be.

It‘s actually working for us.

Re:Ask HN: What are your favorite developer-efficiency tips? by decentralised on Saturday May 09, 2020 @05:11AM (#23123243)
Just curious but have you tried Hegel (https://hegel.js.org/)?

I've only just started playing with it but it already feels superior to Typescript (for my needs)

Re:Ask HN: What are your favorite developer-efficiency tips? by lloeki on Saturday May 09, 2020 @05:36AM (#23123320)
Incrementally adding Sorbet to some Ruby projects has been so. good.
Re:Ask HN: What are your favorite developer-efficiency tips? by olalonde on Friday May 08, 2020 @11:40PM (#23122092)
Same realization here, but from JavaScript to Rust. I'm still a bit more productive in JavaScript but I now regard it as technical debt to be rewritten in TypeScript/Rust as soon as possible.
Re:Ask HN: What are your favorite developer-efficiency tips? by syldor on Saturday May 09, 2020 @07:29AM (#23123828)
What kind of systems are you developping with rust? Especially if you also do javascript? Genuinely curious as I also want to start working with some lower level languages.
Re:Ask HN: What are your favorite developer-efficiency tips? by bgorman on Friday May 08, 2020 @11:44PM (#23122110)
If you like rust you may love ReasonML