Earlier quoted context omitted.
I think you’re mistaking C-style syntax for what modern C languages have adopted and become. How many C style context even really exist today? The block separation by single characters is ok. Using (), [] and {} to separate things makes things easier on the compiler, but it’s probably down to personal preference whether you like that syntax or not. I certainly vastly prefer the more simplistic approach where you don’…
> I guess {} is better than BEGIN END, but maybe not in terms of readability. AFAIK, {} lacks initialization and finalization blocks, like a sql statement without transaction wrapper. Example is awk: https://www.gnu.org/software/gawk/manual/html_node/Using-BEG...
Ruby vs. Python comes down to the for loop (2021)
131–140 of 193 posts
Re: Ruby vs. Python comes down to the for loop (2021)
#132Earlier quoted context omitted.
> Similarly I prefer Pythons indent to {}’s. Which can technically make your code harder to read I started out having a similar opinion to you, and have completely flipped. 1. There's very little advantage to the whitespace option apart from aesthetics. Depending on your coding style, you gain 0-2 vertical lines. 2. Meaningful whitespace makes it more difficult to write code that writes code. Is it possible to manage…
I don’t mind the {}s too much, maybe the primary reason I dislike them is actually more to do with the fact that I’m Danish and I’ll need to press option+shift+7 to make a { on my Mac… or similarly annoying combinations depending on the machine/OS. I think I once had a windows laptop where I needed to press FN + something. Anyway, when your language adds extra letters to the keyboard ÆØÅ in my case then they have to…
By defining a compose key, you can type á, é, å, ø, ß, §, plus many other symbols, with relative ease, while still having all keys in the right place to program.
For instance, using Emacs with any ISO layout is much harder.
Re: Ruby vs. Python comes down to the for loop (2021)
#133Earlier quoted context omitted.
[flagged]
Ah, a brilliant idea, design all languages so people who only know C can make small changes to existing Ruby code without getting confused. Definitely don't want to enable different abstractions or models of computation. Are these core principles in codebases you mentioned mostly "how to write stuff using C paradigms"? After all, "the Real Programmer can write FORTRAN in any language"
Re: Ruby vs. Python comes down to the for loop (2021)
#134The whole premise here IMO is quite flawed. In real Ruby code I almost never use a for-loop. I can't think of a single use base for it. You always use .each or one of the other methods like .map or .select. while loops might get used, but I'm not sure I've ever seen a for loop in Ruby on any of the projects I've worked on with the exception of PRs from people who are brand new to Ruby Edit: much more interesting woul…
Have you never used C#, C++, or Java?
Re: Ruby vs. Python comes down to the for loop (2021)
#135This is because Ruby inherits it's approach to flow control from Smalltalk, while Python comes from a C/Algol-like heritage. In fact, Smalltalk takes this much further, such that basically all flow control (including if-then-else) is handled as message sends (e.g. if-then is just a message sent to the Boolean object taking a block as it's argument). The downside is the syntax can feel a tad clunky. The upside is incr…
> The upside is incredibly simple and consistent language grammar I hope you don't mean Ruby (I haven't investigated Smalltalk grammar). Ruby grammar is atrocious due to string interpolation stuff. Nothing to do with handling loops or conditionals, but still... Ruby is not at all an example of a language with good grammar. Unfortunately, it's surprisingly rare for popular languages to have good grammar. If you look a…
https://richardeng.medium.com/syntax-on-a-post-card-cb6d85fa...
Re: Ruby vs. Python comes down to the for loop (2021)
#136Ruby always seems so appealing. Can anybody tell me how the Ruby ecosystem looks like w.r.t. - (Desktop) GUI - Natural language processing I would really like to learn Ruby, but I can only justify the effort if I can use its ecosystems for some private projects, and I often have been burned by languages not offering too much in those two areas. And speed-wise, as I understand, Ruby is the same ball-park as Python?
Ruby is only relevant because of Rails, and if those two things are your use-cases then you’ll be better off with Python
Unfortunately the ecosystem suffers from rot because it was a language for trend-followers at one point. But it is still a better developer experience than just about everything else I’ve worked with.
Re: Ruby vs. Python comes down to the for loop (2021)
#137The whole premise here IMO is quite flawed. In real Ruby code I almost never use a for-loop. I can't think of a single use base for it. You always use .each or one of the other methods like .map or .select. while loops might get used, but I'm not sure I've ever seen a for loop in Ruby on any of the projects I've worked on with the exception of PRs from people who are brand new to Ruby Edit: much more interesting woul…
Re: Ruby vs. Python comes down to the for loop (2021)
#138What I like in Ruby: Every expression returns a value. In Python my_list.sort() will return `none`. So if I do `sorted_list = my_list.sort()`, my `sorted_list` will be `none`. And I have been shooting a lot in my foot in the beginning. - I love Python now, but not because I find it aesthetically appealing (I prefer Lisps or functional languages) but because it is ubiquitously available, the ecosystem is phantastic, a…
sorted_list = sorted(my_list)
sorted() also has a reverse option and a key option to specify the keys to sort by.And the sort is guaranteed to be stable.
Re: Ruby vs. Python comes down to the for loop (2021)
#139First impressions apply to languages too. A lot of mathematicians went into AI but didn't start out with any programming experience. They dabbled in some languages and gravitated toward the one(s) they found most useful. Paraphrasing Guy Steele [1]: > It's important that when you design a language that does a familiar thing, that you do the familiar thing exactly... it's criminal that you can write 1/2 and get values…
Python 2.x
>>> 1/2
0
Python 3.x
>>> 1/2
0.5
Re: Ruby vs. Python comes down to the for loop (2021)
#140Earlier quoted context omitted.
I would argue that the main selling point of using Ruby is Rails, for sure there are a lot of things you do in Ruby, but for sure in 2024 there are more performant alternatives.
Performance is worth infinitely less than the sheer developer productivity of Ruby, at least when used by experienced engineers capable of restraint.