News for hackers. Stuff that matters.
Re:Where is Ruby Headed in 2021? by eropple on Thursday November 18, 2021 @09:39PM (#29273173)
This is a set of statements that strike me as pretty unreflective of the state of things these days. I have slung a lot of Ruby in my life and I literally-not-figuratively stopped the second I laid my hands on TypeScript because we've hit the point where gradual static typing is both easily available and super easy to work with. (And there's also Rust, which can scratch a whole different set of itches that I don't happen to personally have.)

If your idea of static typing is Java or Go or "something", if your idea of it is that it's for "giant orgs" and not improving your own correctness and throughput of code (I write better code, faster, in TypeScript than I ever did in Ruby!), yeah, it might not make sense. But that's a pretty out-of-date take, I think, and the wins the suitably plastic individual can get, even on a solo or small-team project, are significant.

Re:Where is Ruby Headed in 2021? by Mikeb85 on Thursday November 18, 2021 @09:50PM (#29273238)
The static languages I've used most are actually Haskell and recently Pony (mostly for things that involve a bunch of maths and processing in parallel). Just brought Go/Java up because it seems everyone is trying to turn every language into those.

I don't want Ruby to become another TS because I'd use a typed language if I wanted one. The problems I use Ruby for don't need the speed of a statically typed language and it's nice using a dynamic one for.

Re:Where is Ruby Headed in 2021? by abstract_put on Thursday November 18, 2021 @10:36PM (#29273524)
I think what the parent comment is saying (that I agree with) is that it's easy to over-estimate the cost and under-estimate the value. You don't _have_ to do anything with types, but it's another tool to use where it makes sense. Or put another way, provided it's not mandatory what's the downside to having another tool in the toolbox?
Re:Where is Ruby Headed in 2021? by Mikeb85 on Thursday November 18, 2021 @10:46PM (#29273590)
The downside is the ecosystem turning into the JS/TS ecosystem. Where the zealots have pushed TS to the point it all just looks like C# and what makes JS nice is being lost.
Re:Where is Ruby Headed in 2021? by abstract_put on Thursday November 18, 2021 @11:40PM (#29273904)
Do you have any specific examples of things that make JS nice that have been lost because of the popularity of TS? As with types in Ruby, I was under the impression nothing was really lost as TS could be added incrementally as developers saw value.

I don't think I've talked to anyone who has gotten "over the hump" with TS and felt like they were missing something from JS - I may be in a bubble though. It's almost frustratingly beloved in my experience.

Re:Where is Ruby Headed in 2021? by fiddlerwoaroof on Friday November 19, 2021 @12:18AM (#29274071)
I’ve been writing TS for a year now and I find TS annoying. Especially for react components with state management of some kind, the types get so complex you almost need unit tests to assert they are what you think they are. Additionally, TS being a structural type system with no access to nominal types at all eliminates a whole class of “ghosts of departed proofs” modeling techniques. (And, I know you can work around this, but those workarounds are ugly.)

My view is that I’d use TS if I have to but I’d pick either plain JS / CLJS or something like purescript if I really wanted types.

Re:Where is Ruby Headed in 2021? by arcanon on Friday November 19, 2021 @01:04AM (#29274308)
The year is 2021.

People argue for a toolchain that takes a static language, compiles it to a dynamic one, then runs it with an interpreter on the server side.

Humanity ended shortly thereafter.

Re:Where is Ruby Headed in 2021? by jamil7 on Friday November 19, 2021 @04:11AM (#29275257)
I haven’t touched the ecosystem really for a number of years but my last JS project was in TS and I hated it for the same reason. The overhead of bringing in yet more npm modules and types and build steps for questionable levels type safety. Languages with much better type systems exist.
Re:Where is Ruby Headed in 2021? by canaus on Friday November 19, 2021 @10:03AM (#29277878)
Such as?
Re:Where is Ruby Headed in 2021? by zerocount on Friday November 19, 2021 @03:54AM (#29275169)
The dynamic nature of JavaScript is lost when using TypeScript.

Although TypeScript can be added incrementally, in practice I've only seen it totally replace JavaScript.

While I do believe more people prefer TypeScript over JavaScript, I think it's because those people never deep dived JavaScript or bothered to learn it enough to see how powerful it really is. There are also people that just prefer typed languages and will shun languages without static types.

This really is a religious war and boils down to one's opinion. I like JavaScript without typing.

Re:Where is Ruby Headed in 2021? by regularfry on Friday November 19, 2021 @10:01AM (#29277847)
Once you have more than one team in the same codebase the opinions start to line up as people start to think the types will save them from stepping on each others' toes. Which it might! Publishing types is also a poor-man's contract testing, so people who like that sort of thing will like that sort of thing.
Re:Where is Ruby Headed in 2021? by eropple on Friday November 19, 2021 @01:57PM (#29280863)
I have implemented a JavaScript virtual machine. I feel confident in my knowledge of JavaScript as a language and as an operating environment.

What power am I no longer able to leverage using TypeScript when it's appropriate to do so?

Re:Where is Ruby Headed in 2021? by joelbluminator on Friday November 19, 2021 @07:17AM (#29276428)
Why the downvoting? You somehow upset the typed mob I guess...
Re:Where is Ruby Headed in 2021? by fastball on Thursday November 18, 2021 @11:36PM (#29273889)
1. What's wrong with C#?

2. What made JS uniquely nice?

I wanted to leave these questions entirely open to answer, but I'll add my own opinion on (2) because I feel compelled: nothing, JS is quite possibly the worst language ever designed. Certainly the worst in widespread use.

Re:Where is Ruby Headed in 2021? by zarzavat on Friday November 19, 2021 @02:52AM (#29274841)
Why is JS one of the worst languages ever designed? I've used many languages and JS is one of the better designed ones in my opinion.
Re:Where is Ruby Headed in 2021? by tonyedgecombe on Friday November 19, 2021 @03:37AM (#29275069)
>Why is JS one of the worst languages ever designed?

Implicit type conversions.

Function scoping.

Null and undefined, what is the difference?

Accessing an undefined variable doesn't throw an exception.

Assigning to an undefined variable without var puts it in the global scope.

No integer type.

I could go on and on. The only reason it has become successful is because it has a monopoly in the browser.

Re:Where is Ruby Headed in 2021? by mypalmike on Friday November 19, 2021 @07:25AM (#29276468)
My favorite recent discovery is calling a js function with too many or too few parameters. It'll just go ahead and do it.
Re:Where is Ruby Headed in 2021? by phyrex on Friday November 19, 2021 @10:00AM (#29277841)
There’s an implicit “arguments” function argument through which you can access the extra parameters. It’s JSs way of function overloading
Re:Where is Ruby Headed in 2021? by tonyedgecombe on Friday November 19, 2021 @12:13PM (#29279554)
Which looks like an array but isn't.
Re:Where is Ruby Headed in 2021? by phyrex on Friday November 19, 2021 @01:28PM (#29280557)
There’s a lot of that kind of thing in JS, isn’t there? :(
Re:Where is Ruby Headed in 2021? by handrous on Friday November 19, 2021 @11:57AM (#29279308)
I'd add

- Actually using any of the distinguishing features of prototypical inheritance is nearly always a bad idea, which makes the use of that model in the first place very questionable. One of the cornerstones of the language is pretty much one big foot-gun, to be wholly avoided.

Re:Where is Ruby Headed in 2021? by mypalmike on Friday November 19, 2021 @07:22AM (#29276456)
What is [] + [] in JavaScript?
Re:Where is Ruby Headed in 2021? by regularfry on Friday November 19, 2021 @10:03AM (#29277871)
There is the kernel of a nice idea in JS but so many bad early design decisions can never be walked back.
Re:Where is Ruby Headed in 2021? by eropple on Friday November 19, 2021 @06:59PM (#29284232)
I would argue that TypeScript does yeoman's work in doing much of that walking back.

I plumb forgot that assigning a variable without `var` or `let` put it in the global scope because TypeScript yells at you for it.

Re:Where is Ruby Headed in 2021? by lucideer on Friday November 19, 2021 @07:00AM (#29276328)
> I'd use a typed language if I wanted one.

I think the general point the above commenter is trying to make is that not all typed languages are equivalent: i.e. if you're avoiding TS/typed ruby/etc. because you don't want something like Haskell/Java, then that's not a well-informed decision as they're (all) radically different approaches to static typing, each with their own unique benefits and drawbacks.

TS is nothing like Java nor Haskell. Nor Rust.

(I can't personally speak to Ruby/Pony yet)

Re:Where is Ruby Headed in 2021? by JBits on Friday November 19, 2021 @12:59AM (#29274289)
Wait, Pony as in https://www.ponylang.io/ ? Since this is the first time I've seen someone bring it up, can I what your experience using it has been like? And also what you were using it for?
Re:Where is Ruby Headed in 2021? by Mikeb85 on Friday November 19, 2021 @10:38AM (#29278262)
That's the one. Experience is that it's very good at what it does: multithreaded/distributed programs. Good C interop. It forces you into it's paradigm, but it's a good one for creating performant code across cores.

Tooling isn't great, it's missing things like a language server (compiler gives good error messages at least), but it's also quite simple (whole syntax fits into a smallish page) and the documentation is decent.

Playing around with it for doing economic simulations. Actors + good multithreaded performance = pretty much perfect for the domain. Makes sense too, the creator and half the core members came from the financial field.

Ruby is my go-to for scripting, one off programs, and anything web-related (blog, putting together a small crud site). For things where I want performance, I just use a compiled/static language.

Re:Where is Ruby Headed in 2021? by imachine1980_ on Thursday November 18, 2021 @10:39PM (#29273539)
you don't use static type for speed, the first time i write some code in TS(wh compile to js) i typed something of web-storage the editor say this function assume string and you put a num, if i use js i need to run the program to know that. is cool ultra expressive typing(haskell) but you don need nothing so fancy to have huge gains in productivity. ruby and python are grate langues to write scripts and rails make a lot for you but having the compiler take your hand slaps bugs like nothing
Re:Where is Ruby Headed in 2021? by tambourine_man on Thursday November 18, 2021 @10:37PM (#29273527)
> But that's a pretty out-of-date take

Gradual/optional static typing are not new ideias. It’s just that they are fashionable now.

It used to be that not having to deal with types at all was the cool place to be in. Our computers were getting so much faster every year, why would performance be a concern? Programmers are more productive in dynamic languages and computer time is cheap, etc, etc.

The “correctness” pitch, the required for larger projects, compiletime vs runtime errors are all discussable, even though they are often thrown in the conversation as irrefutable advantages of static typing.

The performance angle, not so much. Static will almost always be faster then dynamic typing, even with all the crazy tricks we’ve developed over the decades.

Re:Where is Ruby Headed in 2021? by HeyImAlex on Thursday November 18, 2021 @10:48PM (#29273600)
It’s not that they’re fashionable, it’s that their ergonomics have improved significantly over the past decade. I saw dynamic types as a response to cumbersome static type systems, but increasingly type systems are becoming more expressive and less cumbersome.
Re:Where is Ruby Headed in 2021? by eldavido on Thursday November 18, 2021 @11:34PM (#29273875)
Yeah, this is how I see it, too. Sort of a gradual convergence.

On the static side, Java and especially C# are simply _better_ than they used to be. Type inference is great - I can just write var x = new List<Thing>() rather than having to stupidly repeat the type e.g. List<Thing> x = new List<Thing>(). Add in generics, and lambdas, and about a dozen other things that have now become widespread, and it's really a different game than 10 years ago.

Coming the other way, I never expected to see Intellisense-like autocompletion for languages like Ruby or Python. It honestly feels magical. Refactoring has gotten much better to where I can pull methods up and down inheritance chains using PyCharm or other mainstream IDEs.

I actually think it's mobile that's pushed people back toward static. Swift, ObjC, Java, and Kotlin are all static and there's less emphasis on this "one language" idea that drove a lot of people toward trying to use the same language (JS/TS) for their React front-ends and node backends.

Re:Where is Ruby Headed in 2021? by bcrosby95 on Friday November 19, 2021 @12:33AM (#29274156)
But C# has had everything you've listed for over 10 years. Along with a great IDE that has provided very useful intellisense since pretty much the beginning.
Re:Where is Ruby Headed in 2021? by eropple on Friday November 19, 2021 @10:57AM (#29278475)
You couldn't (easily) use C# to write the frontend for a web application that you wanted to use as either a developer or a user, though (which is to say sit down, ASP.NET Web Pages, nobody ever liked you).

That's the lock that TypeScript turns, IMO.

Re:Where is Ruby Headed in 2021? by bcrosby95 on Saturday November 20, 2021 @08:40PM (#29293439)
There aren't that many languages that do this even today, much less 10 years ago. You've basically turned what was a discussion about static typing in general into Javascript vs Typescript.
Re:Where is Ruby Headed in 2021? by DeathArrow on Friday November 19, 2021 @06:08AM (#29276016)
Not only C# and Java, but C++ has auto, Typescript has let, Rust has let and I think many other languages have type inference.
Re:Where is Ruby Headed in 2021? by fastball on Thursday November 18, 2021 @11:30PM (#29273854)
When it comes to code, I'm fairly certain "correctness" is in fact an irrefutable advantage.

The argument has always been whether or not the price of that correctness is too high.

But at this point if you're using a modern IDE / code editor (e.g. VSCode), it's actually easier to write statically typed code because the inference / auto-completion / etc is so much better when you do.

At least with TypeScript in VSCode.

Re:Where is Ruby Headed in 2021? by dragonwriter on Friday November 19, 2021 @12:31AM (#29274143)
> The argument has always been whether or not the price of that correctness is too high.

No. I mean, that's been part of the argument, but so has whether static typing actually gave you useful correctness. Many static languages have had type systems that are more designed around convenience of compilation (and performance of compiled code) than correctness; the type systems of the optional typecheckers of modern dynamic languages are leaps and bounds better than static type systems of most popular static languages a couple decades ago, and have been for some time.

> But at this point if you're using a modern IDE / code editor (e.g. VSCode), it's actually easier to write statically typed code because the inference / auto-completion / etc is so much better when you do.

If you have good inference, statically typed and dynamically typed code is virtually indistinguishable TypeProf-IDE for Ruby, discussed in TFA, generates type signatures by inference from plain Ruby code.

Re:Where is Ruby Headed in 2021? by eropple on Friday November 19, 2021 @07:01PM (#29284249)
Strong disagree with the idea that dynamic inference steps to static declarations, particularly for Ruby and especially if you're using anything that expects you to write code inside of its DSL. The inference tends to fall off and because it isn't expected of you, nobody's doing anything to help there.

Maybe Rails is special-cased enough to get away with it, but I still maintain a project in Grape and none of the autocomplete solutions I have found for Ruby help significantly at all. Meanwhile over in TypeScript, I literally can't remember the last time I used `any` or `unknown` except at a module's edge during validation of untrusted input, and autocomplete is awesome.

Re:Where is Ruby Headed in 2021? by Mikeb85 on Friday November 19, 2021 @12:36AM (#29274165)
> it's actually easier to write statically typed code because the inference / auto-completion / etc is so much better when you do.

Ruby has a pretty nice language server, nice linter, REPL (Pry), many other tools.

The best development experience IMO is still stuff like SLIME or Smalltalk environments.

"Intellisence" just makes using statically typed languages bearable. It's not a unique feature.

Re:Where is Ruby Headed in 2021? by kaba0 on Friday November 19, 2021 @06:58AM (#29276309)
Intellisense will allow you to do explorative programming, finding what method is callable on a given object. It’s much easier to look up n methods than to try to guess what is the whole state of the program where it may accept this and that, where even in the best case you might get a fraction of what a statically typed language’s autocompletion allows for.

Like just seriously try intellij with java and pycharm for a php code.

Re:Where is Ruby Headed in 2021? by Mikeb85 on Friday November 19, 2021 @10:45AM (#29278330)
Ruby has (always had) a REPL and .methods gives you all possible methods you can call on an object. Editors with completion have been around forever too.

"Intellisence" is just what MS calls it. It's not unique to statically typed languages. Completion has existed for dynamic languages probably longer than I've been alive. In fact, the reason tooling for Java/C# is so good is because the VM can feed it info as it's running, since even though the language is static the runtime is dynamic.

Re:Where is Ruby Headed in 2021? by eropple on Friday November 19, 2021 @10:07PM (#29285225)
I have used that REPL extensively. I've written plugins for Pry for my personal usage. There are absolutely cases I've run into where it is nice to break into code, write it inline, and save the buffer. This is true. But I've run into more cases where having to do that to know what I'm working with in the first place is a tiresome slog.
Re:Where is Ruby Headed in 2021? by kaba0 on Friday November 19, 2021 @10:49AM (#29278374)
Please try one out, the difference in quality is staggering. Also, .methods is a runtime thing, that’s hardly useful. Of course at runtime you must know the available methods.
Re:Where is Ruby Headed in 2021? by Mikeb85 on Friday November 19, 2021 @11:45AM (#29279167)
I do write code in statically typed languages (C++, Haskell, have done Java before, etc...).

> Also, .methods is a runtime thing, that’s hardly useful

I think you missed the whole point of a REPL and dynamic languages... Developing while program is running = runtime things are definitely useful, they provide instant feedback (including completions, linting, that sort of thing).

Re:Where is Ruby Headed in 2021? by sparker72678 on Friday November 19, 2021 @10:49AM (#29278375)
Or try RubyMine for Ruby.

The challenge of providing a list of available methods in a dynamic environment is real, for sure, but there are great tools out there doing it right now.

Re:Where is Ruby Headed in 2021? by tambourine_man on Friday November 19, 2021 @11:38AM (#29279064)
That’s why I used correctness in quotes, because it’s no guarantee.
Re:Where is Ruby Headed in 2021? by fastball on Friday November 19, 2021 @07:20PM (#29284389)
It's not a guarantee, but an environment/language that yells at you when you try to pass a boolean to a function that should only ever accept a string is going to result in a more correct program than one that just... doesn't say anything and lets you happily do things that make zero sense.
Re:Where is Ruby Headed in 2021? by DeathArrow on Friday November 19, 2021 @06:10AM (#29276026)
With Visual Studio also. Intellisense works wonders.
Re:Where is Ruby Headed in 2021? by hajile on Friday November 19, 2021 @09:41AM (#29277638)
> Gradual/optional static typing are not new ideias. It’s just that they are fashionable now.

I'd add that Common Lisp has had optional type hints (as both documentation and performance improvement) for getting close to 40 years now.

Re:Where is Ruby Headed in 2021? by DeathArrow on Friday November 19, 2021 @06:13AM (#29276035)
You might not care about types but the computer you are running your code on, cares very much.
Re:Where is Ruby Headed in 2021? by islon on Friday November 19, 2021 @08:00AM (#29276687)
Are they releasing processors with typed registers now?

AFAIK registers and assembly is untyped.

Re:Where is Ruby Headed in 2021? by phendrenad2 on Friday November 19, 2021 @03:00PM (#29281597)
That's true, however I think you're misunderstanding how languages work. The Ruby interpreter knows the "type" of everything. How could it not? It was there when you defined a variable, and it was there when you added data to it. It's there when you define interfaces and other things that might affect the type of something. It's perfectly capable of holding all of that information. And there's no meaningful difference between parsing "int x = 3;" and "var x = 3;" in a program.
Re:Where is Ruby Headed in 2021? by zomgwat on Thursday November 18, 2021 @09:56PM (#29273273)
I've gotten a lot of value from integrating Sorbet into a non-trival 15 year old Rails app. The gradual nature of the typing is very nice.

I've never written TypeScript but I suspect the tooling around Sorbet is pretty far behind at this point but it's still worth it. For example, there are is a whole class of unit tests that no longer need to be written. In addition to the gradual typing, having access to interfaces, typed structs and enums is all nice too.

Re:Where is Ruby Headed in 2021? by eropple on Thursday November 18, 2021 @10:51PM (#29273617)
Yeah, Sorbet and the progress being made in Ruby-land makes me want to go back and give it a good look. I really like Ruby. I just really like writing silly in/out tests less.
Re:Where is Ruby Headed in 2021? by JohnBooty on Thursday November 18, 2021 @10:55PM (#29273649)

    I just really like writing silly in/out tests less.
Were you writing a bunch of tests to make sure that A is passing arguments of the right type to B?

I'm not sure that's a great use of time. If A is passing the wrong thing to B, B will throw a `NoMethodError` anyway once it tries to do anything with the arguments, which will make the spec test fail anyway.

But maybe I'm misunderstanding what you mean by "silly in/out tests"...

Re:Where is Ruby Headed in 2021? by eropple on Thursday November 18, 2021 @11:28PM (#29273832)
You can get away with that if you're writing something for immediate delivery, though I think it leads to a lot of not-my-problem thinking in teams that have to scale. On the other hand, I write a lot of libraries, both for internal and external consumption, and there are a lot of operations, in that context, where you won't get a `NoMethodError`--serialization, for example. You can happily serialize an integer if it's passed instead of a string. That doesn't mean it makes sense, or whatever is consuming it is going to be able to make heads or tails of it, and having to run code in order to know whether you've made trivial mistakes is shitty and demoralizing to an end user when they have to divine what a `NoMethodError` means when it's thrown deep inside of a library.

It can also then create security issues around untrusted input; you should be sanitizing at module boundaries any time something might be sensibly used with rando input, IMO, rather than relying on web developers who may or may not be competent enough to duplicate other consumers' effort to do it.

Having to do less work to enforce sanity at module boundaries, and having it tied in with the type system when you do have to do it, is a powerful force-multiplier. For example: I use `runtypes` to create validators in TypeScript when I must handle untrusted input and it's smart enough to take the validator I specify and create a type of the same shape for use at compile-time, so users who aren't dealing with untrusted input just have the nice computer cross the T's and dot the I's for them.

Re:Where is Ruby Headed in 2021? by JohnBooty on Friday November 19, 2021 @12:08AM (#29274028)
Those are really good counterexamples and I love your points.

However... just kidding, there's no "however." Great reply.

    You can get away with that if you're writing 
    something for immediate delivery, 
I've worked on some big Rails monoliths and this just wasn't an issue very often.

But as you say, I think library code is another story.

Incidentally, whether library or application code, I've found that keyword arguments with well-chosen names have reduced this problem even further. It's not clear that `do_something("blue")` is incorrect, but `do_something(user_age: "blue")` is self-evidently bad.

Re:Where is Ruby Headed in 2021? by joelbluminator on Friday November 19, 2021 @12:55AM (#29274274)
Out of date how? Tons of people write pure javascript and not typescript. They are all not as productive as you?
Re:Where is Ruby Headed in 2021? by eropple on Friday November 19, 2021 @04:00PM (#29282412)
I'm saying that I am significantly faster and more correct TypeScript than JavaScript, and I know literally no people who are starting greenfield projects in JavaScript today.

People choosing to write JavaScript in 2021 might be plenty productive. I trust their code much less, though, unless they're writing a battery of tests to establish sanity at their module boundaries and making the extra effort to ensure correctness that you get very cheaply with TypeScript.

Re:Where is Ruby Headed in 2021? by joelbluminator on Saturday November 20, 2021 @02:18AM (#29286210)
YOU are faster with Typescript. Can you accept the fact that certain people are not and do not like Typescript? You live in a Typescript bubble so you conclude everyone is doing that. Just open a jobs board and see for yourself not everyone is doing Typescript.