Ruby General (technically better than Python edition)

Everything about the Ruby language and ecosystem

can't let those python fags have their own thread while we have nothing

Other urls found in this thread:

jstorimer.com/blogs/workingwithcode/8085491-nobody-understands-the-gil
jstorimer.com/blogs/workingwithcode/8100871-nobody-understands-the-gil-part-2-implementation
jstorimer.com/blogs/workingwithcode/8158971-nobody-understands-the-gil-part-3-thread-safety
quora.com/What-happened-to-the-wonderful-RubyMonk-online-Ruby-tutorial
rubykoans.com/
ruby.bastardsbook.com/chapters/web-crawling/
randomhacks.net/2005/12/03/why-ruby-is-an-acceptable-lisp/
cs.princeton.edu/~dpw/courses/cos326-12/lec/15-parallel-intro.pdf
ideals.illinois.edu/bitstream/handle/2142/72643/technical-report.pdf?sequence=2
people.eecs.berkeley.edu/~krste/papers/parallelbrowser-hotpar2009.pdf
twitter.com/NSFWRedditGif

Anyone knows what parts of the standard libraries are in by default in mruby?

So if I understand correctly, the only way to have some real threading is to use something like JRuby?

I would like to learn Ruby, I know up to Arrays when it comes to concepts for Java so I have a tiny bit of experience. What are some great resources for learning Ruby?

Addendum: On a scale from 0 to 8, how hard is it to integrate mruby - how CRuby should have been option A - into Crystal - how CRuby should have been option B?

Serious question: why would I use Ruby over Python?

Because you'd appretiate better engineering in implementations, for example, getting strings right.
Language wise they are both meh and both ecosystems are ok.

Depends.

Techincally Ruby has Threads and Fibres and they work just fine. But I guess you are talking about green threads?

I highly recommend this article, it might give you some insights:
>jstorimer.com/blogs/workingwithcode/8085491-nobody-understands-the-gil
>jstorimer.com/blogs/workingwithcode/8100871-nobody-understands-the-gil-part-2-implementation
>jstorimer.com/blogs/workingwithcode/8158971-nobody-understands-the-gil-part-3-thread-safety


Generally I would learn 1 langauge at a time, so IMHO it's better to focus 6 month on Java and then focus 6 month on Ruby. Some Java and C always come in handy!

But if you want to learn Ruby right now, the best ressource is actually rubymonk.com - unfortunately the website is currently down, but you might check it every now and then to see if it's up again. They will probably be back in some weeks (hopefully??).

>quora.com/What-happened-to-the-wonderful-RubyMonk-online-Ruby-tutorial


As for now you might take a look into Ruby Koans:
>rubykoans.com/

Just download it and start "path_to_enlightment.rb".
The cool thing about ruby koans is that it naturally teaches you test-driven devellopment without making you notice it. A RubyDev should know his TDD like the back of his hand.

If you prefer Python - there is nothing wrong with that. Python and Ruby have influenced each other anyway..


But Ruby gives you a lot of funny things you don't have in Python, i.e. the functional features are way more powerfull than in Python.

Also Ruby feels more natrural for me, for example in python you somtimes do "function_abc('string')" and sometimes "'string.function_abc'" and I always forget which one to use. In Ruby it's always the latter, because you always call the object which seems more logical to me.

Also Python is real wierd when it comes to strings, Ruby has way better tools for string and list manipulation.

Also Ruby has blocks (basically overpowered lambda-functions), once you understood them, you'll love them.

Also braces or do-end instead of whitespace indention. (Personally I have no problem with whitespace indention, but I like to know where I function ends)

That's kinda useless for parallelism right?

Because you don't know Perl

Good anwer.


Again, it really depends on your problem.

The kind of threading Ruby (or Python) use is to use tiny "time slices" and give it to differnt processes. Which is perfectly fine for most things.

Now let's assume you need a lot more cpu power and want "real" paralellism - that's a completely differnt beast.

What is relevant for your programm? Good latency? Good throughput? Is a Mutex suuited for your application? A lot of questions arise here.

Java has better threading, but even in Java you can't decide how many "native" threads it uses.

Go is better for parallelism than Ruby, but since Go is so "low-level" (syntax-wise), you have to code a lot of shit by hand. In other words: Sopgisticated parallelism in Go is anything but easy. But it all depends on your problem, for some things Go is veyr good to use.


Personally I think the best langauge concerning Paralellism is Elixir. It was created by a former Rails develloper, so it's syntax is very Ruby-like but it uses Erlang underneath.

You will need more time to understand Elixir than i.e. Go, since it's a completely functional language - a differnt paradigm, i.e. immutable values. But IMHO that's exactly it's strength, beacuse if you don't have immutable values but communicate about state a lot, you're in for a lot of problems..

(On a sidenode, that's the reason why a Go application either is "defensive" when it comes to errors or shuts down completely, while an Elixir programm can kill/restart processes as it like, you can hotswap code.. no problem because it's stateless)..


Huh, a wall of text, sorry.

So for a real example: a script to scrape content from thousands of URLs.

If I use 4 threads, will it be any faster with Ruby or the threads will just wait for each other and have the same performance?

I never scraped "thousands of URLs" at the same time (why would someone do this?). But I have seen webcrawlers in Ruby, and you already have a lot of tools for that stuff (Nokogiri is great!).


But honestly, for your example the bottleneck is not the "computing power", but rather WebRelated stuff like traffic, bandwith..

Here's how to write a crawler in Ruby, if this helps?

>ruby.bastardsbook.com/chapters/web-crawling/

It's just an example, it can be used for image galleries (maybe thousands is a bit of a stretch).
What I mean is, instead of going through each URL one by one, I would go through four (or more) at a time, let's pretend they all finish at the same time.

Would Ruby threads help that or it would have the same performance? That's what I'm wondering.

Lisp shits on both python and ruby

Is it bad if I like Scheme and Ruby?

>randomhacks.net/2005/12/03/why-ruby-is-an-acceptable-lisp/


Oh well...

I'd rather see paralellism and Web as two differnt things. They are related in some ways, but it's not that simple. You don't just use 1000 threads and load content 1000x faster..


First you need to understnd the differnce between parallelism and concurrency.

Maybe read this:
>cs.princeton.edu/~dpw/courses/cos326-12/lec/15-parallel-intro.pdf

Oh wait, here are two short papers about that topic:

>ideals.illinois.edu/bitstream/handle/2142/72643/technical-report.pdf?sequence=2

>people.eecs.berkeley.edu/~krste/papers/parallelbrowser-hotpar2009.pdf

Well, too bad there isn't even an implementation + ecosystem that is

- not severly outdated
- feature complete
- according to the standard
- not on JVM
- not a meme mostly
- not run by idiots
- not a sandbox for CS lessons
- aimed at multi developer application programming

Why would you use either?

Because it has a cool looking logo and you probably have an affinity for anything Japanese.