News for hackers. Stuff that matters.
Re:After a year of using Node.js in production by beders on Monday May 02, 2016 @06:51PM (#11616388)
Now all of a sudden, having types and some standards to gather around doesn't sound like a bad idea anymore ;)

I agree with one of the commenters: Lessons already learned by older engineers (who went through similar woes with other languages/tools) are being re-learned again and again.

The software industry is in a sorry state.

Unless you are a very disciplined team with a very strong sense of writing modular code, don't use Node.js for any larger project. And even then, the single-most useful function in an IDE 'Show Call Hierarchy' will never be available when using a dynamically typed language.

That is not an issue for smaller projects. However, long before you even get close to the the million lines of code project size, your tools will fail you. Your debugging/refactoring times will explode and adding a new feature will seem unsurmountable.

Instead, let's just re-write everything from scratch because the cool hipster that wrote your backend a year ago has left for greener pastures...

I won't even try to guess the amount of technical debt produced with Node.js and the likes each day in the bay area.

And, yes, I just used Node.js to write a Slack-bot. It was fun, took me two hours and got me up and running quickly. That's the beauty of it. Just be aware of the dangers.

Re:After a year of using Node.js in production by athenot on Monday May 02, 2016 @07:12PM (#11616532)
Those are all very valid points.

However, having witnessed (different shapes of) the wheel being reinvented over the past 2 decades, my take is slightly different: each language/environment has its strengths. If you have the luxury of having a senior team that's decently versed in several environments, then you can have your cake and eat it too: for each tool, micro-service, component... use the right language for that. Then tie it all together on the network. Since the system as a whole is likely to be a network product anyways, embrace it to your advantage.

Joe Armstrong wrote a good post[1] about connecting programs a few months ago, that's quite relevant.

Node.js is a great environment for many microservices. Got a task to do which is 80% done in some npm module? Make a node.js service around it. Same idea for Perl & CPAN, C libs, Java tools, etc.

[1] http://joearms.github.io/2016/01/28/A-Badass-Way-To-Connect-...

Re:After a year of using Node.js in production by encoderer on Monday May 02, 2016 @07:17PM (#11616561)
I've worked in three million+ loc codebases, in PHP, Python and Java. I don't share your opinion that you need static types in these circumstances. You need discipline, modularity, and most importantly you need to have been blessed with gardeners and maintainers throughout the life of a project and not just after a mess has already taken hold.
Re:After a year of using Node.js in production by beders on Tuesday May 03, 2016 @01:24PM (#11622583)
Did you read what I wrote? I already said that you need a disciplined team. Good luck keeping that team together for years to come. Not sure if you are disputing the fact that keeping code around is a challenge, or not.
Re:After a year of using Node.js in production by Klathmon on Tuesday May 03, 2016 @06:39AM (#11619377)
Damn sorry I accidentally downvoted you on mobile... I really wish HN would fix that.
Re:After a year of using Node.js in production by mpweiher on Tuesday May 03, 2016 @02:20AM (#11618346)
> And even then, the single-most useful function in an IDE

> 'Show Call Hierarchy' will never be available when

> using a dynamically typed language.

True when "never" = "40 years ago". Smalltalk IDEs have had features for displaying call hierarchies statically and dynamically since essentially forever. And of course, in a dynamic environment the IDE vs. program distinction doesn't matter, so if you want to really know what's going on, just insert a self halt. and check in the debugger.

Smalltalk also introduced automatic refactoring, another canard of the "impossible to do in a dynamic language" variety. Really weird when "impossible in" = "invented there".

Yes, we can talk about how static type information can make some of this easier, but it also makes other parts harder (and the RB guys did talk about this, so the information is out there).

Please: if you want to diss JavaScript, diss JavaScript, don't say "dynamic languages". If you want to diss dynamic languages (please do!), inform yourself first.

Re:After a year of using Node.js in production by beders on Tuesday May 03, 2016 @01:23PM (#11622574)
If your IDE is your runtime environment. Sure.

I've started with Allegro Common Lisp, so i kinda know a thing or two about that.

The success of Smalltalk then speaks for itself?

Re:After a year of using Node.js in production by mpweiher on Tuesday May 03, 2016 @03:36PM (#11623559)
So much the worse if you actually knew that what you claimed was factually wrong.
Re:After a year of using Node.js in production by Silhouette on Monday May 02, 2016 @07:02PM (#11616451)
Lessons already learned by older engineers (who went through similar woes with other languages/tools) are being re-learned again and again.

If only that were true! I think the JS (and more generally web development) ecosystem today is more a case of those who do not learn from history being doomed to repeat it. The thing is, if you actually are Google or Facebook or Microsoft or Mozilla or Apple, you can throw huge amounts of resources at problems and produce sufficiently useful solutions regardless, and then you can do the same again a few months later if you need to. These are the kinds of organisations that set the tone for the whole community because of their sheer size and influence. However, their goals are not necessarily aligned with the rest of the web development community, nor will their approach necessarily work well for someone else.

Re:After a year of using Node.js in production by beders on Monday May 02, 2016 @07:08PM (#11616502)
I think I didn't express myself correctly. Younger engineers are ignoring lessons learned and are thus forced to learn them again :)
Re:After a year of using Node.js in production by Silhouette on Monday May 02, 2016 @07:17PM (#11616566)
Ah, I see. In that case, I think we agree!
Re:After a year of using Node.js in production by mgkimsal on Tuesday May 03, 2016 @07:59AM (#11619739)
I think you're both saying something similar, but there's a "why" in there to connect:

> Younger engineers are ignoring lessons learned

Why ignoring them? Beyond the 'youth' factor directly, the signaling from the larger companies mentioned (google, etc) is that those lessons don't necessarily matter, and... look, google did XYZ, you can too (ignoring that they threw potentially 3-5x as many people at problem XYZ than you even have, much less justify).

Maybe neither of you meant that, but that was the connection I just saw between your two comments.

Re:After a year of using Node.js in production by Silhouette on Tuesday May 03, 2016 @09:40AM (#11620503)
Yes, that's basically what I meant. I think some of the highly visible projects from tech giants today are succeeding despite their approach to software development, not necessarily because of it, but a lot of the new developers coming into the industry lack the experience to realise that and think of these projects as examples of how things should be done.

Every time I see some young developer posting on HN about how the code we write today only has to work for a year or maybe two at most, or how 10,000 lines of code is a large program, or how some high profile company's web site that is still fundamentally just forms and tables and an API for talking to a database is a complicated UI, I weep a little for the future of our industry and our lack of ambition. Of course things like performance and stability and standardisation and portability don't matter very much if all you ever do is hop from one small throwaway project to the next every few months.

I think the culture around HN is unfortunate in this respect, because from a commercial point of view, it is an alluring idea to build some sort of trivial MVP, try and get crazy amounts of funding, and then if (and only if) you succeed, to throw it all out and start over. As a business strategy for building the next WhatsApp or Instagram, that's rational and perhaps quite effective. But it also contributes to the everything-is-expendable mindset that plagues our industry, and since the overwhelming majority of software development projects don't have the luxury of starting over every five minutes, I think it breeds a lack of respect for professional programming and the skills required to build good software without the benefit of an effectively infinite funding source from benevolent investors (or from the goose that keeps laying golden eggs elsewhere in the organisation).

That might be OK for Facebook or Google, but I wonder how many other startups that fail could still have been very successful, albeit not in unicorn territory, if their developers had paid more attention to some of these issues. I wonder how much time humanity collectively wastes today just because software quality and reliability aren't taken seriously by too much of the industry.

Re:After a year of using Node.js in production by auvrw on Tuesday May 03, 2016 @10:53AM (#11621186)
maybe i haven't read this thread closely enough ... the parent to this post mentions "lessons of the past" and its parent mentions typed languages, so uh, what lessons are being discussed here? certainty not "the past teaches that typed languages are best," b/c lisp
Re:After a year of using Node.js in production by Silhouette on Tuesday May 03, 2016 @02:49PM (#11623200)
For what it's worth, I don't think Lisp is a very convincing example of how useful a language with a limited type system can be, because to a first approximation no-one uses it.

But more generally, the modern web development world is only just waking up to the idea that if you want to build software sensibly beyond a very small scale, you need tools for modularity and composition. Separation of concerns is important to preserve developer sanity and keep maintenance manageable. It is helpful to have well-defined, stable interfaces, whatever the current underlying implementation. Having an expressive language is good, but having an expressive language built on sound foundations and with consistent patterns and clean semantics is much better. Standards for protocols and formats are important. Performance matters, in many different ways. Quality matters. Portability and standards compliance matter. Longevity and stability and backward compatibility matter. Having a few good tools that work well and offer substantial benefits is much more valuable than having a million tiny things that change or become unsupported within weeks. Frameworks can be useful for getting going quickly, but you lose flexibility down the line if your requirements evolve beyond what the framework was designed to support and that can hurt. Libraries offer more flexibility, but you often incur overheads converting to and from their conventions and those overheads need to be reasonable if the library is going to be useful. Reuse is good but not always the best choice.

These and many other lessons in real world software development were brought to you by the words "developers older than", the number 30, and experience of programming outside the JS bubble. :-)

Re:After a year of using Node.js in production by auvrw on Tuesday May 17, 2016 @10:11AM (#11713764)
> to a first approximation

late reply, but something occurred to me to say more as a (hopefully funny) witticism than an actual talking point:

if we approximate usage in terms of a poly sum w/ coeff derivatives wrt time (Taylor series is the word, I think) then one might estimate lisp to be a very much used language

Re:After a year of using Node.js in production by beders on Tuesday May 03, 2016 @01:32PM (#11622644)
I'm mostly lamenting the overall lack of progress in creating reliable, bug-free software.

You would never let a software engineer build a house, would you? For some reason, the discipline of architecting and building houses is far more advanced than building software.

Why is that? We keep inventing new programming languages to tackle various aspects of making software better (safe concurrency, preventing memory leaks, etc. etc.), but we keep introducing 5 bugs per Function Point and the rate of finding and removing bugs has stayed pretty much the same the last 20 years.

There needs to be a fundamental change in how we create software.

Re:After a year of using Node.js in production by MBCook on Monday May 02, 2016 @09:05PM (#11617091)
A lot of the Node issues seems to be due to the fact that it's a very new language. Sure JS has been around for a long time but the problem domain was small and very different from what Node is trying to achieve. Couple that with some issues other languages don't have (JS's standard library is quite thin) and I'm not surprised at these issues. I felt bits of this playing with Clojure and Go when they were new.

I imagine a lot of these issues will settle down in the next few years as one or two sets of conventions become de facto standards.

Re:After a year of using Node.js in production by spion on Monday May 02, 2016 @07:53PM (#11616778)
The main problem with most typed languages is basically that types are nominal by default.

What I want is free-form records and structural types by default, nominal types only when necessary. I get more than half of that with TypeScript (it does lack nominal types but there are ways to get around that), and honestly its the half I prefer having.

Re:After a year of using Node.js in production by majewsky on Tuesday May 03, 2016 @04:18AM (#11618823)
Most serious statically-typed languages have some sort of "anything" type where you can check the actual value type at runtime using some sort of reflection. For example, the direct Golang equivalent of a Javascript object is a map[string]interface{}.
Re:After a year of using Node.js in production by spion on Tuesday May 03, 2016 @05:41PM (#11624465)
I'm not looking for an `any` type, but for structural types: Go interfaces are already a basic form of that, although a bit too basic.

And I hate to say it, but Go doesn't qualify as a serious statically typed language. No language without generics does.

Re:After a year of using Node.js in production by spion on Monday May 02, 2016 @07:01PM (#11616446)
With node, at least you have the option to easily migrate to TypeScript and get excellent tooling.
Re:After a year of using Node.js in production by beders on Monday May 02, 2016 @07:08PM (#11616498)
if all the libraries you are using are as well...maybe.
Re:After a year of using Node.js in production by spion on Monday May 02, 2016 @07:12PM (#11616531)
You can write definition files for libraries. A lot of libraries already have such files: https://github.com/borisyankov/DefinitelyTyped

If a particular library doesn't have one, you can write it yourself. In that case theres no need to model the entire library - you can only model the subset of functions / methods that you use.

Re:After a year of using Node.js in production by popmystack on Monday May 02, 2016 @07:25PM (#11616619)
Or what if, hear me out, everyone just did that thing from the start?
Re:After a year of using Node.js in production by spion on Monday May 02, 2016 @07:31PM (#11616657)
I do tend to start all my new node projects in TypeScript, yes.
Re:After a year of using Node.js in production by Tarks on Tuesday May 03, 2016 @04:28AM (#11618856)
With TS do I have to have a spec for every third party code or can I import something and use it as-is, but not get the benefits of TS on that part of the code?
Re:After a year of using Node.js in production by maattdd on Tuesday May 03, 2016 @05:43AM (#11619127)
You can do both.
Re:After a year of using Node.js in production by popmystack on Tuesday May 03, 2016 @06:53PM (#11624892)
Seems like a silly conundrum to be in.