News for hackers. Stuff that matters.
Re:JavaScript Is C by truth_seeker on Tuesday October 29, 2019 @04:58AM (#21385215)
> Earlier this week, I was working on a problem in the Ember app where I spend most of my day job, and realized: JavaScript is the same as C.

No sir, you have realized that Ember is promoting JS as C.

Throughout the whole article the author is trying to shift responsibilities to compiler or he is seeking a solution which is closer to DSL.

If compiler or typechecker disciplines are more important, why not explore eslint plugins and typescript advance types and use them appropriately before jumping directly to new programming language and relatively limited community ?

Re:JavaScript Is C by jdance on Tuesday October 29, 2019 @05:31AM (#21385358)
I would guess whatever you do on top of typescript, its still a superset of javascript, which will always have holes in it. Its that 100% guarantee that the author is looking for, and that Elm provides.

The difference between 99% and 100% is enormous in my experience. A part of your brain that constantly evaluated the situation can now be totally at rest, spending that energy at other things.

Note that I have not used Elm myself, but looking at it I get the point. I have the 99/100% experience in other things

Re:JavaScript Is C by tekkk on Tuesday October 29, 2019 @05:50AM (#21385444)
Yes, precisely so. Type definitions are as good as the programmers who wrote them, and since humans are imperfect they make mistakes. After you have defined your types wrong, there are devious bugs in your code that you have no way of knowing (until you step on that mine and the program hopefully crashes). Although every language by design is mostly bug-free, it's that in JS/TS there is a much greater human factor (similar to C/C++) that just adds a large error margin for the correctness of the application. Especially when there are very loose runtime guarantees for type-safety, there is always a chance for something ugly to happen.
Re:JavaScript Is C by Fellshard on Tuesday October 29, 2019 @10:13AM (#21387366)
This is especially true when it comes to working with JS libraries. Since no two libraries or JS developers have the same set of ideas for how the language's components work and fit together - how objects are intended to be used, standard ordering of arguments, whether to use a functional or an OO style, etc. - your application will be torn between the dozens of wildly different libraries you end up selecting, or worse, by those you have no choice but to select. Every crack in JS will be pulled wide open by that tension, and even TS' attempt at some normalization will not fully erase that.
Re:JavaScript Is C by hombre_fatal on Tuesday October 29, 2019 @10:26AM (#21387500)
Sounds like every language I've used, from Python to Java to Rust.

JS actually has an improvement to offer here with its async-everything concurrency model taking away one degree of ecosystem fragmentation.

Re:JavaScript Is C by Fellshard on Tuesday October 29, 2019 @03:24PM (#21391072)
No.

In general, there is a sense among Python coders of at least concrete schools of thought for these kinds of abstractions. Java certainly is looser, since it never clung tightly enough to 'pure OO' principles. Rust is young, and - I expect - is still developing its standard idioms and common abstractions, though it has certainly settled on a broad swathe of it already, and holds strong opinions on what good Rust code looks like.

If I asked something similar of Javascript, you would see very little commonality between people. It's designed as a Self-y language with functional leanings, and gives far too unopinionated and broad a leeway to nudge its developers in any one direction. Furthermore, early browser APIs for JavaScript - especially when it came to features like window and cookie interaction - pulled the rug out from under every reasonable abstraction the language could have been geared towards, choosing unreasonable over reasonable abstractions.

This leaves the language where it is now - incohesive, incoherent, unsound when it comes to stitching multiple parts together, because each developer behind each of those components has a wildly different perception of how the JavaScript world 'ought to work'.

Re:JavaScript Is C by Touche on Tuesday October 29, 2019 @06:16AM (#21385550)
Doesn't Rust have unsafe?
Re:JavaScript Is C by Sindisil on Tuesday October 29, 2019 @09:01AM (#21386603)
Your point being?
Re:JavaScript Is C by Touche on Tuesday October 29, 2019 @11:57AM (#21388616)
You don't have a 100% guarantee if unsafe is being used.
Re:JavaScript Is C by cinnamonheart on Tuesday October 29, 2019 @01:38PM (#21389868)
Among others, Haskell has bottom, unsafeCoerce, unsafePerformIO, and Data.Dynamic. Even in the dependently typed Agda, you have postulates and pragmas like NON_TERMINATING and NO_POSITIVITY_CHECK. Is there any language out there with no unsafe hatches? Even in the most rigorous languages I'm aware of, I don't think 100% guarantees exist.

Some languages get a lot closer than others, though -- I think Elm, Rust, Haskell, and so on are still a big improvement over the status quo of languages. I'd rather get 90% of the way there than 10%.

Re:JavaScript Is C by Touche on Tuesday October 29, 2019 @03:45PM (#21391239)
I don't disagree, seems weird that the author made such a big deal of the 99% vs 100% thing when 100% is not something Rust has.
Re:JavaScript Is C by Sindisil on Tuesday October 29, 2019 @01:57PM (#21390131)
No. But you the areas of unsafety are explicitly indicated, of limited scope, and not the default.

Also, even in unsafe code, Rust offers more guarantees than many (most?) languages.

Re:JavaScript Is C by Touche on Tuesday October 29, 2019 @03:44PM (#21391234)
So not 100%. Kind of defeats the argument, imo. Now we're just talking about shades of grey.
Re:JavaScript Is C by chriskrycho on Tuesday October 29, 2019 @10:19AM (#21387428)
Well… I have. I helped bootstrap the TypeScript community in Ember back in 2017 (it existed before that, but I pushed hard and slowly pulled together a small team that works on it). I've written ridiculously advanced types with TS to solve problems (and experienced the compile time pain that can come with that). I'm deeply familiar with TS's strengths and weaknesses. I love TS. I'm working on paving the path to land it in one of the largest JS apps in the world. So when I say that Rust and Elm do things TS doesn't and can't, I'm speaking from experience. Lots of it! And that's not a dig on JS (or C), which I do actually like. It's just that I see how things can be better, and look forward to a world where we have yet nicer things.