News for hackers. Stuff that matters.
Re:Why the New V8 Is So Damn Fast by sbjs on Monday July 30, 2018 @06:32PM (#17648768)
Just use Express.js or Sails.js, they're 1:1 to Sinatra or Rails. Join us!
Re:Why the New V8 Is So Damn Fast by nicoburns on Monday July 30, 2018 @06:54PM (#17648935)
Unfortunately Sails is nowhere near as good as Rails. Which is kind of strange given the size of the JavaScript community, and the fact that PHP has Laravel and Python has Django, both of which are comparable to Rails.

Amusingly given all the PHP hate, if you want a faster rails-like framework, Laravel might be your best bet.

Re:Why the New V8 Is So Damn Fast by pmontra on Monday July 30, 2018 @10:26PM (#17650077)
I don't know anything about Laravel but I've been working with Rails since 2006 and with Django since 2016. Django has little to do with Rails. It's much more similar to Java Struts from 2005 (when I left it for Rails), form objects and template tags among the other nuisances. No XML thanks god, but a weak deployment story (no Capistrano or Mina, I built my own tool). I'd pick Django over Struts without thinking (I don't do Java anymore, even with morr modern frameworks), but I pick Rails over Django any time customers give me the choice. Django (and Struts) are optimized for large projects at the cost of developer time but very few projects grow even to medium sized. Django has a decent admin tool. That's the only advantage I can think it has over Rails for the typical project I do. I also worked with Phoenix (Elixir) in the last 12 months. It's kind of midway between Rails and Django in terms of framework and language complexity.
Re:Why the New V8 Is So Damn Fast by mikermcneil on Tuesday July 31, 2018 @04:39PM (#17656874)
Have you tried Sails 1.0? (There’s always more to do, but we’re working to improve the framework a little more every day.)
Re:Why the New V8 Is So Damn Fast by sbjs on Tuesday July 31, 2018 @05:25PM (#17657320)
Awesome to see the creator of Sails here! And awesome that you have such a positive and constructive response to criticisms! I see that Sails is also a company and not just an open source project, are you a full time company living off of using your open source work? If so can you give any advice to someone who is trying to learn how to make a living with open source? I am full of energy and passion for software and want to put that towards open source, but it would be much nicer to also get paid while doing so!
Re:Why the New V8 Is So Damn Fast by out_of_protocol on Monday July 30, 2018 @06:35PM (#17648784)
Not true unfortunately. Rails quality unreachable for current js frameworks. Well, i hope situation will change in the future
Re:Why the New V8 Is So Damn Fast by sbjs on Monday July 30, 2018 @06:57PM (#17648961)
Does that mean there's still room in the JS ecosystem for a Rails-alike? Maybe one that could become very popular? Because I am looking for a major open source project to create and spearhead, something that could get hundreds of thousands of active users and a thriving subcommunity, but I've been holding off until I find just the right project.
Re:Why the New V8 Is So Damn Fast by vinceguidry on Monday July 30, 2018 @08:05PM (#17649411)
Personally, having developed in both Rails and Node, I now believe that trying to recreate Rails in JS is a foolish effort. Rails is a huge project with a ton of weight behind it and unless you can generate a massive amount of corporate investment, you won't ever be able to really catch up.

I'm not saying that there's no room in the JS ecosystem for another web framework, what I'm saying is that if your design goal is re-implementing Rails, you're already setting yourself up for failure. Sequelize has tried to be ActiveRecord for how long? The only thing it makes me do is want to go back to Ruby and Rails.

No, what you have to figure out if you want to do a JavaScript web framework is how to get me to actually want to use JavaScript to program a website. How can prototypical inheritance actually contribute to a workflow as opposed to a more conventional inheritance scheme.

But honestly, quite frankly, I can't tell what anyone would want to use JavaScript on the server at all for.

Re:Why the New V8 Is So Damn Fast by tlrobinson on Tuesday July 31, 2018 @01:20AM (#17650726)
Apparently Steve Yegge ported much of Rails to JavaScript (on Rhino, at the time) back in 2007 at Google, but it was never open sourced AFAIK: https://steve-yegge.blogspot.com/2007/06/rhino-on-rails.html

For comparison, (according to `find . -name "*.rb" | xargs wc -l`) Rails back then was about 66K LOC (plus 38K LOC of tests) and is now 137K LOC (plus 216K LOC of tests).

However, Steve says he only ported "essentially all of ActionView, ActionController and Railties, plus a teeny bit of ActiveRecord", so maybe half of the total.

Re:Why the New V8 Is So Damn Fast by tlrobinson on Tuesday July 31, 2018 @01:26AM (#17650747)
As for the second half of your comment, it sounds like you haven't used JavaScript in awhile. ES6 introduced syntax for classical inheritance, and a bunch of other nice features.
Re:Why the New V8 Is So Damn Fast by vinceguidry on Tuesday July 31, 2018 @07:25AM (#17652244)
I use ES6 at my job, daily. There are some things about it that make me really hate it. First, no, it doesn't introduce classical inheritance. It introduced syntax that looks like classical inheritance. It's still prototypal inheritance under the hood. I'm not entirely sure what this means yet from the standpoint of building things with it, but I'm not enthused at the prospect.

What I find happens fairly frequently with ES6 that I never found with Vanilla JS is that the extra features built on top of JS 'break'. If you add syntax to a language, that syntax needs to work. I need to be able to rely on it working. I run into constant little issues that make me think I'm missing something about scoping, when really it's some under-the-hood issue with a library or something I just don't have the time to pin down.

One example is I tried using the spread operator to add keys to an object. But the spread simply, well, failed. Passing in the object worked fine. Passing in a spread version of the same object failed. I haven't resolved it yet, got pulled onto another feature. This sort of breakage is hard to Google, when I run into it again, and I'm sure I will, I may have to troubleshoot it all the way to Babel.

Error reporting in Node with ES6 is garbage. Worse than garbage, it's a veritable dumpster fire. Ideally the error points to the problem, when it doesn't point to the problem you have to rely on experience and intuition to lead you to the issue. Many many errors I come across in JS are of this sort.

I think most of these issues come down to the fact that ES6 is a transpiled language. This makes me long for the days of good old CoffeeScript. At least CS was close enough to Vanilla that it was easy to determine when you had an issue with the transpiler, simply grab the snippet of code and paste it into the online transpiler, look at the generated JS and work out your issue from there. It wasn't the smoothest workflow but it was effective.

ES6 is stupid in ways that make building an effective workflow unreasonably difficult. I can't wait to get back to Rails. Vanilla JS wasn't that bad. It was well-understood and you could work with it effectively on the front-end. It certainly wasn't as pleasant as Ruby, but it didn't feel like the pile of hacks that ES6 does. Maybe once it stops being transpiled it'll get better.

Re:Why the New V8 Is So Damn Fast by vimslayer on Tuesday July 31, 2018 @09:39AM (#17653010)
Indeed, JS does not have classical inheritance. IMO introducing a class syntax that looks so much like the classes from other languages and yet behaves differently was a mistake.

The rest of your comment sounds a bit misinformed to me. You seem to have decided that prototypical inheritance is somehow inherently worse than classical inheritance, but don't mention why that would be. I have found very little practical difference between the classes in JS and other languages in everyday use, and can't quite imagine what the problems with it might be.

Furthermore, ES6 (ES2015) is not a "transpiled language". I think it's obvious that if you take a very new language, say, ES2018 and want to run it on your toaster that doesn't have support for such new languages, you are going to have to do some kind of precompilation step. That is true for ES2018 today and it will be true for ES2019 next year and for ES2020 the year after that.

ES2015, however, has been around for several years. All the modern browsers (that is, all major browsers except IE) support it already. Node 10 even supports the new module loading syntax (behind a flag), or you can use a very lightweight transformer like esm[1] for older Node versions.

And if you do end up using and having problems with, say, Babel, it would be more constructive to give concrete examples of the issues you've had. I personally have never faced a syntax problem where the issue would've been due to a bug in Babel instead of just my incorrect understanding of the language feature.

[1]: https://github.com/standard-things/esm

Re:Why the New V8 Is So Damn Fast by vinceguidry on Tuesday July 31, 2018 @09:51AM (#17653080)
I didn't intend to argue that prototypal inheritance was bad, just that I didn't relish the prospect of building something in it, in the context of a discussion about reinventing Rails in Javascript. The argument is that with the amount of time and effort that went into Rails, the new framework has to offer something a lot more unique than just "Rails in JS" if it wants to be relevant, because you'll never even get remotely close to the maturity of Rails.

The problem is that I can't give concrete examples because we're under the gun of a deadline and I can't afford to spend the time to troubleshoot down to root causes rather than just work around the problem and move onto another feature.

I'd love to be able to tell you why the spread operator didn't work in that case. But it didn't, and I made sure to get the whole team around me to tell me I wasn't being crazy. The syntax simply didn't create the needed semantics, and that means that something got messed up in the design of the language. I'm pointing to Babel because that's the only thing I can point to as a root cause.

Rails is nowhere even close to this level of broken. You can rely on the syntax and semantics of Ruby, sometimes gem authors play nasty games with metaprogramming, I saw an example where someone monkey-patched Symbol to get a more declarative method for describing SQL Where Conditions, but at least that crap wasn't in ActiveRecord.

Rails, as a stack, fits together and experience with the framework will allow you to trust it.

Syntax is the foundation of a programming language. If it doesn't work, if it doesn't produce precisely the input that's being described, your language is broken. We're not talking standard library here, we're talking about `{...object}` not being the same as `object`. I don't have time right now to dive into why, but that's the kind of shit I run into when I deal with ES6. When syntax breaks, you can't trust the language anymore. It's a pile of hacks and I wish it had never been invented. Coffeescript was better.

Re:Why the New V8 Is So Damn Fast by kwood on Wednesday August 01, 2018 @11:05AM (#17663121)
From what I remember, object spread came a year later and is ES7 (in case you need a starting point for research)
Re:Why the New V8 Is So Damn Fast by crooked-v on Tuesday July 31, 2018 @03:03AM (#17651111)
It sounds like you're looking for Ember. https://www.emberjs.com
Re:Why the New V8 Is So Damn Fast by sbjs on Tuesday July 31, 2018 @10:09AM (#17653229)
Ember is a front-end framework, Rails is back-end.
Re:Why the New V8 Is So Damn Fast by gunn on Monday July 30, 2018 @08:06PM (#17649415)
Definitely. And using these technologies, there are some cool possibilities beyond what rails is capable of.

For instance if you used typescript (still allows devs to use plain JS), you could use types to check that forms send all the required params. For example, a login page might require:

    interface LoginParams {
      username: string;
      password: string;
      rememberMe?: boolean;
    }
Having the typescript compiler check for inconsistencies with form data would save a lot of the troubles I've seen in rails apps.
Re:Why the New V8 Is So Damn Fast by nicoburns on Monday July 30, 2018 @08:30PM (#17649556)
Unfortunately TypeScript doesn't do runtime checks like this. It assumes that incoming data conforms to the type spec! However, you might be interested in the Rocket framework (written in Rust), which does do exactly that:

https://rocket.rs/

Re:Why the New V8 Is So Damn Fast by sbjs on Monday July 30, 2018 @08:54PM (#17649695)
TypeScript can do runtime checks like this! Granted it uses a TypeScript framework (similar to AJV) that both does the runtime checks and preserves type information for your IDE and type checker. I wrote about it here:

https://medium.com/@stevenbradleyconsulting/from-0-to-type-s...

Re:Why the New V8 Is So Damn Fast by eropple on Tuesday July 31, 2018 @01:13AM (#17650698)
Aw, man - I'd hoped you'd found something to make this less of a stone-cold pain to do. Instead, it's io-ts again. Which is...interesting...but it really sucks to actually use when you have to manually define every in/out yourself. It's 2018. There's no good reason TypeScript can't emit the type information to just build these (and I don't really mean decorator metadata).
Re:Why the New V8 Is So Damn Fast by sbjs on Tuesday July 31, 2018 @10:12AM (#17653259)
You can add another build step right after the `tsc -w` compilation phase, which takes your .ts files, parses them to find our your types, and emits runtime code that checks your types. That's what you're describing that TypeScript should be doing on its own. But I don't see why you'd want to do this instead of using io-ts? This is more complicated overall.
Re:Why the New V8 Is So Damn Fast by eropple on Wednesday August 01, 2018 @01:38PM (#17664837)
Runtime type information is important. TypeScript is in the best place to provide it. So...it should. Boilerplating our way through io-ts is a waste of my time and yours.
Re:Why the New V8 Is So Damn Fast by bazza451 on Tuesday July 31, 2018 @02:49AM (#17651061)
been using io-to in my latest project, fantastic bit of code hats off to gcanti...Only thing is IntelliJ can’t keep up with the types generated (got an open bug with them)
Re:Why the New V8 Is So Damn Fast by savanaly on Monday July 30, 2018 @07:39PM (#17649247)
There's definitely the need for this in JS. It would be extremely difficult to do, though.
Re:Why the New V8 Is So Damn Fast by skunkworker on Monday July 30, 2018 @06:49PM (#17648895)
With 2.6 JIT Ruby should be much quicker this fall. It'll be interesting to come back around once they have method inlining.
Re:Why the New V8 Is So Damn Fast by kowdermeister on Monday July 30, 2018 @07:14PM (#17649063)
What Rails features do you miss from which framework?
Re:Why the New V8 Is So Damn Fast by axlee on Monday July 30, 2018 @07:12PM (#17649047)
How is Express even remotely close to Rails? Express is a glorified router.
Re:Why the New V8 Is So Damn Fast by thomasfoster96 on Monday July 30, 2018 @07:20PM (#17649102)
I think the parent comment was comparing Express to Sinatra and Sails.js to Rails respectively, not altogether.
Re:Why the New V8 Is So Damn Fast by iammiles on Monday July 30, 2018 @07:20PM (#17649111)
I believe parent's intention was to say that Express is like Sinatra and Sails is like Rails.

To which I agree with the Express / Sinatra similarity.

Re:Why the New V8 Is So Damn Fast by EduardoBautista on Monday July 30, 2018 @07:21PM (#17649112)
Express -> Sinatra

Sails -> Rails