News for hackers. Stuff that matters.
Re:Creating a Virtual Printer Using Node.js [video] by creshal on Tuesday December 22, 2015 @10:30AM (#10778258)
Printers and Javascript, a match made in hell.
Re:Creating a Virtual Printer Using Node.js [video] by tomswartz07 on Tuesday December 22, 2015 @11:02AM (#10778426)

    `Uncaught TypeError: PC Load Letter?` 
What the fuck does that mean?

https://www.youtube.com/watch?v=5QQdNbvSGok

Re:Creating a Virtual Printer Using Node.js [video] by jbuzbee on Tuesday December 22, 2015 @07:04PM (#10781198)
That's boring. Hopefully he's implemented "Lp0 on fire"

https://en.wikipedia.org/wiki/Lp0_on_fire

Re:Creating a Virtual Printer Using Node.js [video] by wavefunction on Tuesday December 22, 2015 @10:40AM (#10778315)
JavaScript is great. I do enjoy all the posts about how it sucks. First it was a toy language. Now people complain that it's a weakly typed language replacing strongly-typed languages they prefer... I'm interested to see the next iteration of this phenomenon.

Meanwhile I just enjoy developing in it every day. Other than having to maintain the odd ExtJS app, it's simply the best. cue triumphant sax

Re:Creating a Virtual Printer Using Node.js [video] by _pmf_ on Tuesday December 22, 2015 @11:30AM (#10778599)
> Now people complain that it's a weakly typed language replacing strongly-typed languages they prefer...

The first step would be to understand the difference between weak/strong and dynamic/static typing.

Re:Creating a Virtual Printer Using Node.js [video] by krisdol on Tuesday December 22, 2015 @12:18PM (#10778932)
Can we just use the term "duck-typed" already? There's a significant difference between weakly-typed C, strongly-typed rust, and "strongly"-typed JavaScript/Ruby. Besides, weak-typing is relative. Javascript does some type conversion, but because it does less than C, it is more strongly typed than C, but it is more weakly typed than some other languages.
Re:Creating a Virtual Printer Using Node.js [video] by jerf on Tuesday December 22, 2015 @12:22PM (#10778973)
No, duck typing is not a very good distinguishing characteristic anymore. "Interfaces", "traits", and "concepts", to say nothing of other things, all in various ways make static languages have something that looks something like statically-checked duck typing. Duck typing isn't unique to dynamic languages.
Re:Creating a Virtual Printer Using Node.js [video] by monk_e_boy on Tuesday December 22, 2015 @11:26AM (#10778574)
The first 30 lines of this file are a 'joy'

https://github.com/js-cookie/js-cookie/blob/master/src/js.co...

I'm sure js could be nice, but it never seems to be.

Re:Creating a Virtual Printer Using Node.js [video] by tracker1 on Tuesday December 22, 2015 @03:16PM (#10780103)
The syntax could be a lot cleaner... the Universal Module Definition (UMD) pattern at the top makes it a bit quirky... A lot of people have moved towards using CommonJS (cjs/node-style) exports with tooling such as browserift/webpack and/or babel (for es6 modules) in order to clean up the source syntax.

What you're looking at is a relatively poor example. In es6, that could be ...

    exports default function...
without all the cruft around it, also the module itself could be cleaner. Similar to:

    var cookies = parse();

    export function set({key, value, days=null}) {
      ...
    }

    export function get(key) {
      ...
    }

    export const remove = (key) => set({key, value:null});

    export function parse(values = document && document.cookie || '') {
       ...
    }
Re:Creating a Virtual Printer Using Node.js [video] by monk_e_boy on Tuesday December 22, 2015 @06:00PM (#10780949)
Classes and modules in almost any other modern language are much easier to read and write. Ruby, python, heck even php are better than JS. That's my real issue with JS. If we had a browser that had lots of languages baked into it, none of use would choose to use JS ;) node.js would never have been invented...
Re:Creating a Virtual Printer Using Node.js [video] by nanny on Tuesday December 22, 2015 @11:37AM (#10778640)
>Now people complain that it's a weakly typed language replacing strongly-typed languages they prefer

Firstly, that's a strawman. I prefer strongly-typed dynamic languages and I still think JavaScript sucks.

Secondly, I think you're confusing strong vs. weak with dynamic vs. static. JavaScript's weak typing is unequivocally one of the worst things about the language.

Re:Creating a Virtual Printer Using Node.js [video] by adrusi on Tuesday December 22, 2015 @12:18PM (#10778943)
I'm not Javascript's biggest fan, but the weak typing argument is a little... weak. You never run into problems with weak typing as long as you follow a few rules like using === over ==. Javascript is poorly designed because there are these rules you need to learn and because there are some language features that you just don't use. Some other reasons too, but the way people write it, Javascript may as well be strongly typed.
Re:Creating a Virtual Printer Using Node.js [video] by nanny on Wednesday December 23, 2015 @08:53AM (#10783230)
>the weak typing argument is a little... weak.

I think you contradict this in the rest of your comment:

>Javascript is poorly designed because there are these rules you need to learn and because there are some language features that you just don't use.

One rule you've mentioned:

>using === over ==

Which is a result of weak typing. So maybe weak typing is a language feature "that you just don't use"? Which, according to you, makes weak typing a reason why JavaScript is poorly designed.

Re:Creating a Virtual Printer Using Node.js [video] by adrusi on Wednesday December 23, 2015 @09:16AM (#10783346)
It was not my intention to imply that javascript is not weakly typed. And I think we have collectively determined (correctly) that weak typing is a burden in a general-purpose language. So yes, your conclusion is correct, weak typing is "a reason" that javascript is poorly designed.

But your claim wasn't "weak typing was a bad design decision", it was "JavaScript's weak typing is unequivocally one of the worst things about the language". I think it's silly to call a mis-feature "unequivocally one of the worst things" when people who write javascript basically never run into, and when it can be completely avoided by using unintrusive tooling like a linter.

Re:Creating a Virtual Printer Using Node.js [video] by Kurtz79 on Tuesday December 22, 2015 @11:43AM (#10778682)
The "problem" I have with Javascript is when people try to use it for everything.

https://en.wikipedia.org/wiki/Law_of_the_instrument

Re:Creating a Virtual Printer Using Node.js [video] by diek on Tuesday December 22, 2015 @12:31PM (#10779015)
Just out of curiosity, what other languages do you have experience with?
Re:Creating a Virtual Printer Using Node.js [video] by wavefunction on Tuesday December 22, 2015 @02:42PM (#10779849)
C++, Java, Groovy, C#, Perl, Python, PHP, Ruby, Smalltalk, Objective-C, *86 Assembly, and played around with Go, Swift, Lisp and Haskell

oh, and Visual Basic!!!

I didn't say JavaScript is all anyone needs for every situation, just that it's great imo.

Re:Creating a Virtual Printer Using Node.js [video] by moosterv on Tuesday December 22, 2015 @12:52PM (#10779150)
I started off developing in C, then C++. Then I did Java (late 90's till 2010 or so). I toyed around with PHP and perl somewhere in between. I love modern Javascript, and would be hard pressed to go back to something else.
Re:Creating a Virtual Printer Using Node.js [video] by mhd on Tuesday December 22, 2015 @10:52AM (#10778376)
I remember having to debug the printing system (lpq, converters etc.) on my first Slackware system back in the early years of the second age, with plenty of shell scripts and literal postscript output. So I regard this with a certain amount of schadenfreude.

(Although the "printer" part of the headline makes this sound much more fancy and hardware-oriented than what it is, yet another HTTP-based protocol that's parsed enough to work for a few use cases).

Re:Creating a Virtual Printer Using Node.js [video] by brudgers on Tuesday December 22, 2015 @01:50PM (#10779505)
It is Atwood's law in action:

any application that can be written in JavaScript, will eventually be written in JavaScript.

http://blog.codinghorror.com/the-principle-of-least-power/

Re:Creating a Virtual Printer Using Node.js [video] by mvonthron on Tuesday December 22, 2015 @10:49AM (#10778357)
It can only print text in Comic Sans!
Re:Creating a Virtual Printer Using Node.js [video] by watson on Tuesday December 22, 2015 @11:08AM (#10778465)
Funny you mention that :) I was actually thinking of creating a version of the printer where all print jobs would have the typeface swapped for Comic Sans.

It's been pretty hard so far though to figure out how to do this replacement in PostScript :(

Re:Creating a Virtual Printer Using Node.js [video] by tlrobinson on Tuesday December 22, 2015 @11:25AM (#10778562)
If you could make a proxy to your office's printer that would be a fantastic April fools joke, actually.