by jaredcwhite · 4y ago · 0 comments
What's sad to me is that the modern follow-up to Ruby seemingly doesn't exist. Every hot "language du jour" which has come after Ruby has gone BACKWARDS. Lower-level, more systems programming oriented. Maybe even compiled. Static typing everywhere. It's utterly baffling to me.
"Why are you using Ruby? You should use…Rust! (Go! Zig! Fill-in-the-blank nerd hype!)"
Lol.
What I actually want is a new programming language/environment which makes Ruby look like programming pointer arithmetic in C by comparison. Something so advanced, so high level, that much of the time you're really just describing patterns and flows and data models and extensions, and then letting the computer determine the most efficient way to develop those code paths and execute them.
Unfortunately, I'm a bit cynical on this front. I believe the reason this doesn't exist is because it's at cross-purposes with programmer nerd culture. Many programmers enjoy the nitty-gritty of low-level coding. They fear abstraction. They fear "magic". They fear things like "implicit imports" or "duck typing" or "many ways to express the same method/function/algorithm" etc. because it's all nebulous and fuzzy compared to the safe confines of deterministic math & logic. "If I declare that this variable MUST BE AN INTEGER, then it MUST BE AN INTEGER. The idea you could pass me a string instead? UNACCEPTABLE !!!#%@!"
In other words, I don't have high hopes that great UX for forward-looking developers will come from present-day programming culture. For a quantum leap in DX, we probably need people who aren't die-hard programmers to engage in blue sky thinking. We need to talk to artists, philosophers, linguists, psychologists, and other experts in social & historical cultural dynamics. They can provide the insight we lack. Because for every "this is an integer, damnit!" type out there, there are probably many, many more who would see 123 and "123" and think THAT'S THE SAME THING. :-D
I think the industry has generally recognised that static typing makes more reliable software.
I started with PHP and have seen its type system evolve. Similarly Typescript. I since moved to other staticly typed languages. I wouldn't want to go back.
I have looked at modern Ruby projects, and my assessment is that I absolutely would never want to be responsible for code like that. It's all way too magical, if you see code that says something like "foo.bar", you really have no way of figuring out where the code for "bar" is. "bar" may not even appear as a literal sequence of characters in the application's codebase, or even in the libraries it includes.
If you like that, that's fine, but I wouldn't touch it with a ten foot pole. I don't find it that enjoyable, even if it does save me time today when I'm typing in the code.
I will admit there are certain gems which metaprogram the heck out of everything and that can get annoying, but the flipside is usually those are the gems which are hugely flexible because they're so popular and widely used (I'm looking at you Devise)—and if so there's plenty of documentation and community support out there. I'm also glad `binding.irb` is a thing now for immediately jumping into a console in the midst of your running app, and the new debug.rb gem shipping with Ruby 3.1+ is awesome as well (also with a VSCode integration).
IMO this is the strength of Ruby/Rails. You can have something up and running incredibly quickly, but for complex applications it can easily become a mess. It's not easy to know where something is defined, what type it is, if it can be nil, if you're unknowingly calling the database one or one hundred times with your fancy one-liner, etc.
Of course you CAN structure it all nicely beforehand, and even use type systems, but that's hard to get right, and at that point, you might as well use something else.
What is not debated much, AFAICT, is that it's much much easier to work on large/old codebases when you have types. That's really where Rails runs into issues.
But it's not like legacy rails monoliths start throwing NPE or other type errors everywhere. It's just that developer productivity grinds to a halt. Mostly for two reasons:
(1) You have little idea where the code your modifying is used. Metaprogramming and indirection through send and constants make it hard to find every place it's called.
(2) If you're the 5th function in the chain you have no idea where your parameters are coming from. So you have no idea what type they are and method autocompletion doesn't work. Especially annoying when things get complex and you end up with multiple similar but slightly different representations of things.
When you're programming a form on a web page? It's way-ay-ay more effort for dubious gains, with new downsides added into the mix.
Just because you tend to ignore the many complexities that are actually involved in a form on a web page. It's exactly this bias that stems from untyped languages and that needs to die. Http is a complex beast and we should either replace it with something more simple and robust or at least acknowledge the complexity in our programming.
Generally speaking, if doing something with a proof of type-safety feels complex, you probably ignored many corner cases before.
If you don't cut corners on your static typing, you're looking at 2-4 single use classes per API endpoint: 1-2 for the web layer, and 1-2 when going into the domain logic layer.
Many people skimp and just re-use the core domain class for everything, which is the worst of both worlds.
I'll take a map, spec, and select-keys over this all day long.
Although, in theory, one could write a parser to inject what form elements are available into the type system... :)
How is it way more effort? In any of the nicer languages, there's type inference.
Dubious gains? Strong static typing makes entire classes of runtime bugs impossible (null pointer exceptions, for example).
No, it's not. Initially it's not any more effort and in the long term it's significantly less effort. Having spent equal amounts of decades in static and dynamic typing (and strong/weak) I would absolutely take the former any day for both ease of development and correctness.
I hear this, as well as "eliminates whole classes of run time errors" (as if Ruby and other such codebases are just ablaze everywhere on account of this...), but I wonder if people dabbled in this and think they have it all figured out, or if they've used a modern dynamic language like Clojure that has default immutability or been in a modern Ruby codebase that wasn't cowboy-coded.
Show me an untyped program and I'll show you a program missing tests and containing bugs. Static typing saves time and money.
If you don't mean just HTML but some server side processing, yes, I would. This is still PHP's bread and butter and being able to bind a form to static types is really convenient.
In fact I use original Bill Joy vi.
I suspect for most of the people we're talking to 'I<tab>' will say Int and 'S<tab>' will sat String and that's going to make our experiences very different.
I like static typing personally, but for example have no issue with using a strongly typed language, which does not allow me to treat a number as a string or string as a number or similar. Often such a language provides means of making things safer at runtime at least. For example one can define structs and functions, which only work, when they get an instance of that struct. Any other type of value would result in an error. Then of course there are unit tests, which can cover a lot of ground, even if not all a type system can do in theory.
I find it far more baffling that people don’t want to offload the trivial parts of the mental work of ensuring the programs they write makes the minimum of sense.
I also jumped on the dynamically typed bandwagon after using low value type systems like java’s, but after using haskell, ocaml, typescript, purescript, rust, and especially elm, I realized that they let me focus on the business value over the incidental complexity from having any value potentially being anything…
(Even Agda and Idris have been amazing revelations in this context, but at that point the type theory does start to consume more time than necessary for ordinary development)
I guess Ruby or even Ruby on Rails is very similar, with the ability to monkey-patch just about everything.
Some things are just better (left) dynamically typed.
Don't get me wrong, I love me some Ruby and it makes up the majority of my income. But it would be foolish to ignore that it is indeed 100x slower (or more sometimes!) than some of the modern compiled languages. Small to medium web applications are exactly the sweet spot for Ruby because network latency hides a lot of the language slowness. Nobody cares about 20 extra milliseconds for a request to a server 100 ms away, but a lot of people care about 20 milliseconds delay in frame rendering.
EDIT: The following:
> What I actually want is a new programming language/environment which makes Ruby look like programming pointer arithmetic in C by comparison. Something so advanced, so high level, that much of the time you're really just describing patterns and flows and data models and extensions, and then letting the computer determine the most efficient way to develop those code paths and execute them.
sounds exactly how I feel when programming in Haskell, although that particular language will probably not sit well with you if you absolutely want duck typing.
Actually, static typing is describing "what you want" and leaving it up the compiler to make sure you were consistent.
Static typing is neither necessary nor sufficient here, the gradient from declarative to imperative is largely orthogonal.
Yeah. Staves with circles are something optimized for pens, and almost every modern music software uses simpler notation. Does that make music simple? Not quite, but it certainly makes it more accessible.
that's all the abstractions :-\
I believe the whole computing ecosystem is very shallow at the moment. There are lots of tools and lots of programming languages, but they are all shockingly similar. There is just too much monoculture going on. We used to have APL, Lisp, Prolog. Weird stuff. Weird OSes. We need more of that weird stuff again. But there has to be some economic incentive for that to happen and I'm not seeing it at the moment.
Stuff like Smalltalk or even something like Symbolics' machines would be a better fit for people needing a more high-level approach to computing. These tools see very little if any real funding/action and my hunch is that this will change in the future. Not now, but someday. When indeed perhaps the philosophers, artists and psychologists of this world need to do some programming. I'm not a big fan of these kinds of systems, because I am one of those grumpy bastards that don't agree with "123" == 123 but I do see how these paradigms can fit other types of people more readily.
To be honest, I don't think we've even scratched the surface of what is possible.
Edit: OK I can't resist. "012" == ? This is making me lose sleep. These things are NOT the same. There, I said it.
But it's not all bad. Elixir is pretty widely considered to be the Ruby successor. Types are replaced almost everywhere by pattern matching, the widely accepted unexpected behavior response is to just not handle it, crash the "process" (green thread) and continue on with life, integers don't overflow, and the macro system is powerful enough to do just about anything you want.
Really? That feels really odd, once you get past the surface level syntax, Elixir doesn't really resemble Ruby to me, unless you've conditioned yourself to write purely functional Ruby?
Though I'll have to defer to others if its also possible as a professional.
Ummm what? Elixir is just a friendlier Erlang. It in no way replaces anything Ruby does...
And that's why there's still plenty of legacy Java code, but legacy ruby code over the last decade has been much quicker to get thrown away and rewritten.
I once took over a Java codebase that was clearly created entirely by people who barely knew Java and I was still able to fully understand (and, in the process, refactor it to cut it in half, because half of the code was dead code by the time I encountered it, lol) in about a week. This was not a very large codebase to be honest, but it would have been impractical without static typing and a good IDE that leverages the same.
Dude, the reason programmers fear abstraction is because they've had to maintain legacy codebases. It sounds like you've been lucky enough to mostly be able to do greenfield stuff or maintaining codebases that aren't very old. I am sure you would understand their views more if you had more experience with maintenance.
You'll probably always be in the minority with your preferences because of this.
What's x + "42"?
What's x + "042"?
What's x + "a"?
What's x + "e2"?
What's x + "e2" + 12345?
What's x + "1,500"?
What's 1 / x?
Unfortunately for folks and languages with this mindset, if they need to have good performance, eventually they will need to take responsibility for the data model of their database and their codebase.
Code is data, and types are schema.
Give us something actionable and not handwavy dreaming and you might get it.
Automatic memory management became mainstream in the 90's and dynamic typing in the 2000's. But what did the 2010's give us? Github and Stackoverflow? I think we are due for another "programmer productivity" revolution but I have no idea what it will be. Statically typed programming languages that are marginal improvements on existing dominant languages for sure aren't it.
That way it could be recommended to someone who would otherwise not be willing to take on a harder language, and they have a growth path. Or for a computer science program, to grow into it all incrementally.
And then yes, make whatever improvements in the OP article, from there.
If that was the reason programming is "hard", we wouldn't ever have gotten COBOL, Basic, PHP, SalesForce, Windows, UML or any drag-and-drop query tool.
found your source of disagreement. this is, generally, not the domain anyone writing languages cares about. no one writes a language for an individual.
–Yukihiro Matsumoto, creator of Ruby https://www.artima.com/articles/the-philosophy-of-ruby
Might I suggest that you could probably try some Clojure and see how it goes.
I suppose that if somewhen you could get into it, you would find a rich toolbox with a lot of heavy lifting done under the hood and a lot of space left for you to think about application design first and foremost, with a fair performance.