News for hackers. Stuff that matters.
Re:How is Ruby different in Japan? by Lordarminius on Sunday June 18, 2017 @05:11PM (#14582964)
So thankfully, it would appear that Ruby is kept alive by the Japanese.

I have never really understood the craze for Python . I am by no means a guru, but I consider Ruby a far superior language; ( yes, I recognize that the numerous scientific and ML libraries of python make it a logical choice for many projects, but this is sort of like a self fulfilling prophesy)

My love for Ruby declared, I have on occasion wished that we had a "strict" feature in the language similar to ES5 that would permit only the use of Ruby's more straightforward features and also exclude deprecated methods and techniques. This might give the language a deserved boost.

Does anyone know what the most utilized language in Japan is ? And what framework they use there for web projects, if not Rails ?

Re:How is Ruby different in Japan? by hetman on Sunday June 18, 2017 @08:11PM (#14583743)
I used to have a preference for Ruby but Python has a single killer feature missing for me from Ruby and that is explicitly imported module symbols.

When looking at new unfamiliar code in Ruby there's just no way of instantly knowing which symbols come from which files/gems. There are conventions, sometimes these are followed well, sometimes not. Either way it adds a lot to the mental load of parsing new code or even old code you've written your self. Ruby's module import system is just too much like C's #include.

Re:How is Ruby different in Japan? by antod on Sunday June 18, 2017 @08:28PM (#14583788)
> I used to have a preference for Ruby but Python has a single killer feature missing for me from Ruby and that is explicitly imported module symbols.

As someone who has to now deal with a couple of complicated/convoluted Ruby codebases, that is one of the biggest things I miss from Python too.

Re:How is Ruby different in Japan? by sanderjd on Sunday June 18, 2017 @10:01PM (#14584163)
Yeah, I've come to think this is perhaps Ruby's biggest design miss. It can be really hard to trace dependencies in Ruby, and doing so is a prerequisite for any deep understanding of what's going on. (Granted, this is mostly a problem in Rails projects, but the fact is that Ruby makes this problem possible.)
Re:How is Ruby different in Japan? by Daishiman on Sunday June 18, 2017 @10:27PM (#14584237)
This is the number 1 failure in Ruby for me. It makes large codebases unmaintainable in the long term.
Re:How is Ruby different in Japan? by jeltz on Monday June 19, 2017 @08:11AM (#14586283)
Yes, Ruby is my favorite language but they really messed up the module system. Ruby basically has no module system at all and everything is in the global namespace.
Re:How is Ruby different in Japan? by hetman on Monday June 19, 2017 @07:53PM (#14591267)
I mean, that's not technically true, there's definitely a module system. In fact, in some ways Ruby's module system is more powerful than Python's since it's completely divorced from the concept of the file. You can split a single module across multiple files or create multiple modules in a single file. You can nest modules as well of course.

The problem is with the module import system, which as you alluded, imports the module structure in a given file into the global namespace. And it imports everything! There's simply no way to say which bits you want and where they should go.

I actually don't really see a reason why the import system could not be changed while keeping the module system in general as is. I wonder if anyone has ever tried something like that...

Re:How is Ruby different in Japan? by int_19h on Sunday June 18, 2017 @07:54PM (#14583673)
Python is arguably more "obviously readable", in a sense that when you see some construct, and you don't know what it is, but you have a guess, that guess is usually correct. It makes the grammar more verbose than Ruby in many ways, and idiomatic Python is almost always more verbose than idiomatic Ruby, but for many people, ease of reading and understanding is preferable.
Re:How is Ruby different in Japan? by vickychijwani on Sunday June 18, 2017 @09:05PM (#14583929)
Care to elaborate with an example? I use Python day-to-day and did quite a bit of Ruby a few years ago, but I fail to see significant differences in verbosity.

What I do see is that Python is somewhat less consistent and readable (list comprehensions beyond the simplest ones are unreadable, Ruby's blocks allow cleaner DSLs, len(a) vs a.size, little things like "3.times", allowing "?" and "!" in identifiers). But Python has a bigger and more diverse ecosystem. So although I would prefer Ruby over Python, the ecosystem aspect makes the point moot.

Re:How is Ruby different in Japan? by setpatchaddress on Sunday June 18, 2017 @11:56PM (#14584546)
Ruby is more concise whenever you have a need for case statements or regex.

Really wish Ruby had won this war. It's much more pleasant to use.

Re:How is Ruby different in Japan? by issaria on Monday June 19, 2017 @01:16AM (#14584744)
It can not win when there are only three people working on it part timely. Check the new feature list of Python release every few months.
Re:How is Ruby different in Japan? by Lordarminius on Monday June 19, 2017 @01:58AM (#14584851)
It boils down to an issue of funding ?
Re:How is Ruby different in Japan? by ksec on Monday June 19, 2017 @04:14AM (#14585319)
I cant , and could never understand why this is, and if it is a problem.

Github, Basecamp, Twitch, Stripe, Square, AirBnB, Shopifly, Cookpad, and many more. All these are very successful site that are using Ruby ( Not necessarily Rails ) and most of them profitable.

If each or them could fund a 20-33% Salary of an additional Core Dev you instantly have 3 - 4 people working on it Full time.

So I have been thinking on this for sometime, It is because the Ruby community and the world as a whole does not want to donate? Or are we lacking someone to push this and ask for some help when needed?

Re:How is Ruby different in Japan? by Lordarminius on Monday June 19, 2017 @05:13AM (#14585544)
> If each or them could fund a 20-33% Salary of an additional Core Dev you instantly have 3 - 4 people working on it Full time.

I came to say the same thing.

Its such an obviously good idea. It seems all that is needed is a champion for this cause.

Re:How is Ruby different in Japan? by pythonaut_16 on Monday June 19, 2017 @09:11AM (#14586638)
Especially interesting when you compare to Python, which is used extensively by Google, Dropbox, Instagram, Pinterest, Reddit, Youtube.

Of those I know both Dropbox and Google have employed Gudio Von Rossum, and various other Python core devs are also employed full time.

Overall it seems that Python is much more community driven than Ruby. Python is interesting in that it has several big camps, including web dev, systems programming/automation, scientific usage, machine learning, etc, and all of these communities are fairly self sufficient but also contribute back to the main language.

Re:How is Ruby different in Japan? by herbst on Monday June 19, 2017 @11:23AM (#14587620)
Well that's exactly what is happening these companies employ people who work more or less full time on Ruby core issues. A lot of Ruby features are funded by big corps. The 3 people are just the 'core' core team. Like Linus did for Linux for years
Re:How is Ruby different in Japan? by brazzledazzle on Monday June 19, 2017 @01:21AM (#14584755)
It's one small thing but string interpolation annoys the crap out of me when using Python and while it might tick the understandable check box I wouldn't say it's easier to read. After using Ruby it's such a chore to read or write in my opinion (which admittedly doesn't mean much having so little experience with Python).
Re:How is Ruby different in Japan? by cutler on Monday June 19, 2017 @07:05AM (#14585977)
How is "#{fname} #{surname}" better than f'{fname} {surname}' ?
Re:How is Ruby different in Japan? by klibertp on Monday June 19, 2017 @10:44AM (#14587339)
OTOH, f-strings were added to Python not long ago, and they are the third or fourth (depending on if you count `string.Template`) syntax for string interpolation in Python. Frankly, string formatting in Python is a bit of a mess right now.
Re:How is Ruby different in Japan? by iipin on Monday June 19, 2017 @10:37AM (#14587279)
By the glare of it, none. But you have to understand that ruby has that `#{}` since ways before, and python has just added that `f` syntax recently. Also in ruby it's the only way of doing string interpolation, while in python you have % and other methods.
Re:How is Ruby different in Japan? by herbst on Monday June 19, 2017 @11:26AM (#14587638)
Ruby does have % too for quite a while. As in

    '%s won $%i' % ['herbst', 5000]
Re:How is Ruby different in Japan? by int_19h on Monday June 19, 2017 @07:42PM (#14591228)
You actually want both of these. The reason why explicitly indexed placeholder syntax is still important, even if you have interpolation, is because the order in which the arguments are referenced may change when the string is localized.
Re:How is Ruby different in Japan? by ouid on Sunday June 18, 2017 @08:47PM (#14583855)
I dunno man, I don't think the languages are properly comparable for readability.

  5.times do

    print "s"  

  end
Re:How is Ruby different in Japan? by vectorpush on Sunday June 18, 2017 @09:15PM (#14583983)
It's a double-edged sword. The code's behavior is apparent in that simple example, but things get considerably more difficult to understand when you're dealing with monkey patched methods and dangerously clever method_missing magic in non standard library code.
Re:How is Ruby different in Japan? by singingfish on Monday June 19, 2017 @01:02AM (#14584716)
Yeah, I had to deal with a perl port from a ruby library that had kept most the rubyisms in. The really disturbing thing about it was the Frankenstein levels of autovivification involved. Fortunately someone (not me) is going to get paid deal with that soon.
Re:How is Ruby different in Japan? by int_19h on Monday June 19, 2017 @03:35PM (#14589752)
You can certainly find snippets that are simpler in Ruby than in Python; they're just not the majority. Consider a slightly more complicated case where you need to print out items in a range with some modification. Idiomatic Ruby:

   (0 ... 5).each do |x|
     print (x + 1)
   end
Idiomatic Python:

   for x in range(0, 5):
     print (x + 1)
To understand Ruby, you need to know what || does, and the overall sequencing of the words as you read that construct is somewhat unnatural for English. Python is comparatively easier to parse with no prior background.

It is definitely possible to write Ruby in a way that's still highly readable. But from what I've seen of real world Ruby code, that's not the way it tends to be written - idiomatic Ruby values expressiveness and DRY, so you see blocks and various terse syntactic sugar used all over the place; lots of "clever" code in general. There's nothing wrong with that - I generally prefer expressiveness over readability myself - but many people do not.

Re:How is Ruby different in Japan? by vickychijwani on Monday June 19, 2017 @07:04PM (#14591074)
I see your point. But I'll take the liberty to use part of your comment as my own response: "You can certainly find snippets that are simpler in Ruby than in Python, and vice-versa". Now that is something I 100% agree with (I added the part after the comma btw).

Basically what I'm saying is that the differences are very minor compared to differences vs, for example, other languages (Java, Scala, C++, etc). So from that perspective there's not much to complain about. I just have a slight bias towards Ruby, I find it a little more readable (in a small way).

Re:How is Ruby different in Japan? by nextlevelwizard on Tuesday June 20, 2017 @03:56AM (#14592849)
While it is true that with ruby you have to know more syntax, without previous knowledge of either language you caught on pretty fast.

To me it is more expressive of my intent to say "0 to 5, for each, do something" than "for something in the 0 to 5 range do something"

Also you happened upon what peeves me most about Python, you are not actually looping from 0 to 5 since range is inclusive at the start, but exclusive at the end. So while (0..5) gives you 0, 1, 2, 3, 4, and 5, range(0,5) will get you just 0, 1, 2, 3, and 4. Of course it's easier if you think that range() is rather "I want to take X steps", so if you just want to step 5 times range(5) does exactly what you need it to do.

Re:How is Ruby different in Japan? by camel_Snake on Tuesday June 20, 2017 @07:30AM (#14593679)
I think this is mostly to keep in line with indexing, where you have that same sort of semi-inclusion.

'example string'[3:8] # gives you 5 characters.

Re:How is Ruby different in Japan? by nextlevelwizard on Tuesday June 20, 2017 @11:32AM (#14595375)
But wouldn't you rather just say: "hey, starting from the 3rd index, give me 5 letters" like

    2.3.3 :001 > 'example string'[3, 5]
     => "mple "
Instead of having to think before hand what indexes thous would be.
Re:How is Ruby different in Japan? by int_19h on Tuesday June 20, 2017 @02:10PM (#14597006)
It depends on what you're trying to do. It's pretty common with strings to ask for "everything excluding the first and the last character", for example, and then you want the end index (counted backwards), not length. Another common case is when you looked up a substring and got an index, and now you're slicing the string around that index.

But there are also many cases where length is more desirable.

Ditto with ranges - both end-inclusive and end-exclusive ranges are useful in different cases. I kinda like the fact that Ruby lets you choose, but I think that .. vs ... syntax distinction is too subtle and likely to cause bugs.

I kinda like the way Nim does it: .. for inclusive, and ..< for exclusive - e.g. 1..<10. They also use special syntax for count-from-end, instead of negative indices, which is also a good thing IMO (the decision to index from start or from end is usually something that's not going to change at runtime; but with negative indexing, it might inadvertently do so if you underflow when computing the index).

Re:How is Ruby different in Japan? by ouid on Tuesday June 20, 2017 @04:02PM (#14598050)

  1.upto(5) do |x|
    puts x
  end
is pretty idiomatic. So I don't see your point.
Re:How is Ruby different in Japan? by zeckalpha on Friday June 23, 2017 @11:29AM (#14619856)
Or:

   print("s\n" * 5)
Which is more concise and valid in both.
Re:How is Ruby different in Japan? by yzmtf2008 on Sunday June 18, 2017 @05:57PM (#14583182)
> I consider Ruby a far superior language

Have you looked at the C source of Ruby? :) In terms of that, Python is far, far superior to ruby.

EDIT: to clarify, CPython is much cleaner than MRI, and has a much-better-documented API for extensions. This is what I believe part of the reason that Python has a much better coverage for scientific packages.

Re:How is Ruby different in Japan? by rurban on Monday June 19, 2017 @03:56AM (#14585244)
Disagree. I deal with the C parts of Perl, Ruby and Python and better VM's on a daily basis. Ruby has by far the cleanest implementation of the VM. Almost like the VM of a good Lisp/functional lang. Python and Perl are the worst of all, on par with PHP.

Ruby is unfortunately also the slowest. But not because of the VM implementation, only because of the everything is a method architecture, even for the simplest primitives. The ruby API is pure and clean, this is what makes it slow.

For the python or perl API too much inner state needs to be handled, which makes it slow also. Because you cannot use a better design for data and code. Only php made significant advantages there recently, so you don't have to worry about inefficient data and code, only about the eye blead VM.

Re:How is Ruby different in Japan? by yzmtf2008 on Monday June 19, 2017 @05:16AM (#14585561)
I don't know if I can agree that the Ruby C API implementation is the cleanest -- from my experience I'll say it's very pure, but pure does not really mean clean, and it sometimes (esp. when performance is a concern) makes writing C extensions messy.

Python's C API could be argued that it uses too much abstraction, but it definitely makes it that much easier to write extensions.

Re:How is Ruby different in Japan? by jeltz on Monday June 19, 2017 @08:08AM (#14586274)
Hm, I usually see Ruby ahead of Python in benchmarks and head to head with Perl.
Re:How is Ruby different in Japan? by jeltz on Monday June 19, 2017 @08:07AM (#14586262)
Having worked with both I found the MRI codebase very clean and nicer to work with than CPython.
Re:How is Ruby different in Japan? by ksec on Monday June 19, 2017 @03:59AM (#14585255)
I remember Charles Nutter ( Head Dev of Jruby ) Tweeted a while ago saying how clean the CRuby Code base was.
Re:How is Ruby different in Japan? by nine_k on Sunday June 18, 2017 @09:05PM (#14583931)
Ruby embraces and favors magic. Python shuns magic and goes for one correct and explicit way.

The languages are pretty similar. The community attitudes are different.

Re:How is Ruby different in Japan? by rurban on Monday June 19, 2017 @04:01AM (#14585265)
Cannot agree. Ruby loves its MOP, python loves its method overloads. Both are highly magic, but a MOP is technically superior to overloads, because you just flip the vtables and don't have to look at every single method call, if some python programmer decided to overload it. Perl has no builtin MOP, and even worse overloads than python.
Re:How is Ruby different in Japan? by kudokatz on Monday June 19, 2017 @10:27AM (#14587198)
but the ruby community takes modules to magic extremes. Just take the overload of include vs. extend as one example. Some modules don't even have any reasonable error messages or try to detect when someone stomps on their names or data. It's a madhouse with ruby modules that try to be "magic" or "easy", which is never "simple".

If you ever find yourself pulling back the curtain of many ruby modules, it's time to dig in and swear as you go.

Re:How is Ruby different in Japan? by setpatchaddress on Sunday June 18, 2017 @11:40PM (#14584495)
The languages are not very similar. What gives you that idea?
Re:How is Ruby different in Japan? by zubat on Monday June 19, 2017 @12:44AM (#14584673)
Dynamic types, OO with some extension for functional style, inherited Algol syntax with some homegrown innovations, batteries-included design. Where they differ, it's largely in whether they bend towards consistent style(Python) or more late-binding power(Ruby).
Re:How is Ruby different in Japan? by flavio81 on Sunday June 18, 2017 @05:59PM (#14583195)
Python is slightly less powerful but is pretty fine for many tasks, and much easier to learn than Ruby, with a consistent syntax. So you can quickly learn it and then spend the rest of the day focusing on getting things done.
Re:How is Ruby different in Japan? by sametmax on Sunday June 18, 2017 @06:35PM (#14583360)
How is Python less powerful ? They both have metaclasses, monkey patching, first class functions, unicode... Ruby has blocks, Python has decorators. You can solve pretty much the same problems with the same number of lines.
Re:How is Ruby different in Japan? by hetman on Sunday June 18, 2017 @11:11PM (#14584394)
I should preface this by saying that I prefer Python for my projects for a few reasons, however I agree with parent that Python is less powerful than Ruby.

Both languages have metaclasses but Ruby's are simpler to grasp and more fluid in how they're applied because they're more run time oriented rather than instantiation time oriented like Python's. In fact Python in general tries to make more of a distinction between the instantiation and runtime environments making it a bit more restricted. All this means the average Ruby coder tends to use metaclasses almost everywhere and certainly a lot more than the average Python coder.

Ironically even string processing with encodings is harder in Python 3 than Ruby 1.9 (these are the versions in which both languages modernised their Unicode support). Python's insistence on Unicode everywhere is problematic in places like Japan where there are still extant competing encoding standards that are not fully recoverable when doing a round trip via Unicode. Even ignoring Japan though, Python has had to put in all sorts of hacks to deal with corner cases like the fact that command line parameters or file system names don't always have to use Unicode encodings. 95% of the time you can be ignorant of all this in Python and stuff will just work... but it's a massive pain when you're dealing with the other 5%. I genuinely still don't know if the Python 3 or Ruby 1.9 approach is better... Python's is purer and initially I liked it better conceptually... but having had to apply it practically I'm no longer so convinced.

Finally, I assume you weren't comparing blocks and decorators as somehow equivalent features. It might be worth adding that it's pretty easy to add syntactically pleasing decorators to Ruby without needing special built in syntax, by leveraging Ruby's metaprogramming capabilities. It just tends not to be used as often in Ruby because there's usually different ways to express the equivalent concept.

But while on the topic, blocks are probably the killer feature that makes Ruby more powerful. They essentially allow you to easily change the context of an individual method call in very arbitrary ways. Yes you can do it by passing in named functions or even function pointers in C, but none of this is as syntactically coherent as blocks in Ruby.

If you want a practical example of how this makes Ruby powerful take a look at Rake. It's basically a Make equivalent written in Ruby. The nice thing is that you never leave Ruby, all you do is add a "require 'rake'" at the top of your Ruby file and you now have enough DSL machinery to be able to write pretty nice rule syntax without ever having to write a parser for a custom language (and leaving the power of Ruby behind).

I don't expect any of this to be particularly convincing. The difference in power only becomes obvious when you start writing idiomatically in both languages. When I first started writing Python I tended to write it more like idiomatic Ruby and it was not pretty. Overall Python and Ruby are at a fairly similar level to each other but Ruby definitely has a bit of an edge in terms of expressiveness.

Re:How is Ruby different in Japan? by sametmax on Monday June 19, 2017 @03:13AM (#14585090)
That's a fairly balanced answer. Thanks.

Being a Python fan myself and a hater of "DSL all the things", I still like to have a good POV from the other side.

Re:How is Ruby different in Japan? by Lordarminius on Sunday June 18, 2017 @06:08PM (#14583244)
It should be possible to delineate a "core" syntax for Ruby as well and leave the language esoterica to more adventurous practitioners.

Why is this not a thing ?

See my previous comment

Re:How is Ruby different in Japan? by zeckalpha on Friday June 23, 2017 @11:32AM (#14619878)
This is a thing. Ruby has an ISO standard: https://www.iso.org/standard/59579.html
Re:How is Ruby different in Japan? by owebmaster on Sunday June 18, 2017 @06:38PM (#14583371)
This is a thing. Most "railers" use a very strict subset of ruby features, although Rails itself uses a lot.
Re:How is Ruby different in Japan? by Lordarminius on Sunday June 18, 2017 @06:51PM (#14583420)
I would disagree. For instance, there are at least two syntaxes in use to describe hashes; parentheses are optionally (and inconsistently) used and so on. Rails suffers from the same issues as does the language
Re:How is Ruby different in Japan? by cutler on Sunday June 18, 2017 @08:04PM (#14583713)
According to Indeed.com (title search) there are 4 PHP jobs to every Ruby job in Japan and 15 Java jobs to every 2 Ruby jobs.