News for hackers. Stuff that matters.
Re:The Second Edition of “Refactoring” by myth_buster on Saturday December 01, 2018 @02:08PM (#18578298)
> When I choose a language for examples in my writing, I think primarily of the reader. I picked Java because I felt the most people would be able to understand the code examples if they were written in Java. That was the case in 1997, but how about in 2017? [...] Such a language needed to be widely popular, among the top half a dozen in language popularity surveys. It really helps to have a C-based syntax, since most programmers would recognize the basic code structure. Given that, two stood out. One was Java, still widely used and easy to understand. But I went for the alternative: __JavaScript__. [...] But the compelling reason for choosing it over Java is that isn't wholly centered on classes. There are top-level functions, and use of first-class functions is common. This makes it much easier to show refactoring out of the context of classes.

This is very interesting choice of language. I wonder whether typescript could have been a candidate as well. Although not as popular as JS, I believe most of JS community has migrated to typescript (due to obvious benefits) and it is more closer to a C-based language.

Re:The Second Edition of “Refactoring” by nullandvoid on Saturday December 01, 2018 @02:50PM (#18578542)
Whilst a fan of typescript myself I think the last statement is incorrect, I'd be surprised if >20%-30% of projects started in JS this year are typescript.
Re:The Second Edition of “Refactoring” by regularfry on Saturday December 01, 2018 @06:43PM (#18579767)
I'd be shocked if it was higher than 10%, and that's not even the bulk of JS work: the vast majority is brownfield, existing projects, where changing the toolchain is decidedly nontrivial. TS is nice, but it's a long way from ubiquity.
Re:The Second Edition of “Refactoring” by chrisseaton on Saturday December 01, 2018 @02:20PM (#18578373)
> I believe most of JS community has migrated to typescript

You think the majority of JS developers have switched over to TypeScript?

Re:The Second Edition of “Refactoring” by ChristianGeek on Saturday December 01, 2018 @03:04PM (#18578612)
That (quoted) is a bubble statement if I’ve ever seen one.
Re:The Second Edition of “Refactoring” by myth_buster on Saturday December 01, 2018 @03:53PM (#18578860)
_has_ may be incorrect but I do feel the switch is happening [0]. Angular which is the most popular client side JS framework is using Typescript. React is also moving in the same direction with typescript-react-starter and tsx support.

[0] https://2018.stateofjs.com/javascript-flavors/overview/

Re:The Second Edition of “Refactoring” by BurningFrog on Saturday December 01, 2018 @04:01PM (#18578902)
In my (part of the) JS world Angular is dying and React has long since won.
Re:The Second Edition of “Refactoring” by twblalock on Saturday December 01, 2018 @05:19PM (#18579344)
I agree, I don't know any front end devs who would choose Angular for a new project. The current choice seems to be between React and Vue.
Re:The Second Edition of “Refactoring” by Geee on Saturday December 01, 2018 @08:20PM (#18580157)
Angular is not the most popular [0].

[0] https://2018.stateofjs.com/front-end-frameworks/conclusion/

Re:The Second Edition of “Refactoring” by jammygit on Saturday December 01, 2018 @02:25PM (#18578400)
If you know typescript, you're familiar enough with javascript to use the book, but if you don't know typescript then its a bit tricky for those readers. It just means fewer people have to dust off their language skills to benefit from the book.
Re:The Second Edition of “Refactoring” by ummonk on Saturday December 01, 2018 @02:34PM (#18578458)
Well, I'm very fluent in Typescript, and often find JS code extremely difficult to understand. The types are a great aid to understanding code. It also seems to be the case that a lot of JS code does not use ES6 polyfills, unlike Typescript code, so it tends to be less clean.

Edit: Upon rereading I see you are talking about the book, not actual projects, so my reply is not all that applicable. Though I'd actually say that Typescript is much more understandable than JS to someone unfamiliar with both.

Re:The Second Edition of “Refactoring” by jammygit on Saturday December 01, 2018 @03:20PM (#18578694)
"Typescript is much more understandable than JS to someone unfamiliar with both."

From that point of view, I see what you're saying.

Re:The Second Edition of “Refactoring” by azhenley on Saturday December 01, 2018 @02:19PM (#18578365)
Even more interesting is that he previously came out with a Ruby edition: https://martinfowler.com/books/refactoringRubyEd.html
Re:The Second Edition of “Refactoring” by bdcravens on Saturday December 01, 2018 @05:00PM (#18579241)
How much of it did he write?

I suspect it was much like "Agile Web Development with Rails", which up until the most recent edition, listed DHH as an author

Re:The Second Edition of “Refactoring” by genieyclo on Saturday December 01, 2018 @10:46PM (#18580668)
yeah the Ruby edition is full of errors so be careful.
Re:The Second Edition of “Refactoring” by bdcravens on Sunday December 02, 2018 @12:28PM (#18583287)
Early on in my Ruby career, I picked it up, but really couldn't get much traction with it. Hartl's book was far better.
Re:The Second Edition of “Refactoring” by genieyclo on Sunday December 02, 2018 @04:30PM (#18584666)
Hartl has a book on refactoring?

We're going through http://refactoring.guru at work right now, it's a nice modern version of Fowler's classic imo.

Re:The Second Edition of “Refactoring” by sveme on Saturday December 01, 2018 @02:47PM (#18578523)
Saw him in a talk just last week - he actually mentioned that typescript would have been an alternative, but considered it less well known yet.
[dead]
Re:The Second Edition of “Refactoring” by dang on Saturday December 01, 2018 @07:23PM (#18579958)
Please keep programming language flamewars well away from HN.
Re:The Second Edition of “Refactoring” by LolNoGenerics on Sunday December 02, 2018 @06:37PM (#18585295)
Naive fainboyism as well