[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y ] [Search | Free Show | Home]

Why did you /g/uys choose Python over Ruby? Did you not know

This is a blue board which means that it's for everybody (Safe For Work content only). If you see any adult content, please report it.

Thread replies: 190
Thread images: 9

File: Ruby.png (167KB, 512x512px) Image search: [Google]
Ruby.png
167KB, 512x512px
Why did you /g/uys choose Python over Ruby?
Did you not know how inferior python is..
>>
>>61434581
I didn't.
>ruby for comfy scripting
>scheme for comfy programming
>c for stuff that needs to go fast
>>
>>61434623
>c for stuff that needs to go fast
Assembly or GTFO
>>
>>61434623
Python has all that too
>>
>>61434681
Ruby is faster than python and uses less system recourses to do so.
>>
>>61434717
Yeah but ruby is still shit and hard to deploy or work with.
Gems
Rvm
Etc.
If I want to make the crud app for babies with Sinatra and active record then great but for everything else pfft..
>>
>>61434581

I prefer programming in Ruby because it has less pitfalls then Python and I like the Syntax more.

But Python is also fun.

It depends more or less on the Tasks and existing Libraries. There are some fields where Python has more or better Libraries. Also if it's legacy code, you can't always choose.
>>
>61434581 (OP)
ITT: niggers who will argue about two equally shitty and dead languages
>>
>>61434581
Isn't Ruby a go-to language for hipsters, queers and such? I wouldn't want to be among all of those "pieces of human race" who don't really care about programming.
>>
File: serveimage.png (19KB, 180x165px) Image search: [Google]
serveimage.png
19KB, 180x165px
>he yet did not discovered superior products of 30 years of engineering
good luck using poorly reinvented wheel
>>
>>61434717
>Ruby is faster than python for a curated selection of tasks
fify
>>
>>61434717
>Ruby is faster than python

In the real world nobody uses Ruby for anything outside of Rails and that's slow as shit.
>>
>>61434581
Why did you /g/uys choose Ruby over Elixir?
Did you not know how inferior ruby is..
>>
>>61434581
All of m-muh machine learning examples are in Pyshit though.
>>
>>61434730
>Gems
>Rvm
They aren't great, but they are heaven compared to eggs, virtualenv, etc.
>>
>>61434818
>Isn't Ruby a go-to language for hipsters, queers and such?
Ruby used to be, but now it's JavaScript. The Silicon Valley culture around Ruby is still terrible, though. Makes you wish you knew Japanese to hang out with all the cool, non-leftist Rubyists.
>>
File: Bcle3RNIcAAro4T.jpg (30KB, 599x337px) Image search: [Google]
Bcle3RNIcAAro4T.jpg
30KB, 599x337px
node is faster than ruby and python. only problem is being constrained to a single thread, but there are workarounds if you know C++.
also, JS in general is much easier on the eye as a C/C++ developer than ruby.
>>
>>61435310
*now it's JavaScript and Rust
>>
>>61435005
I use elixir/phoenix and fuck it it's nif and port all the time.
>>
>>61435314
>is much easier on the eye
Are you Egyptian?
>>
>>61435314
js is for sperg kids who just found out about the web browser. You're shit at programming, how about you leave the real programming to us (C c++ java perl) Fagboy
>>
>>61435005
Elixir is a fad and will be forgotten about by next year.
>>
>>61434581
I heard ruby was for sjws so I didn't learn it
>>
>>61435325
>all the time.
When do you use NIFs? I see ports, but that's no different than shelling out from a $lang script.
>>
>>61435285
scripting? command line? prototyping?

If only crystal has windows support and the compilation time is improved (it's fucking suck compiling a single `hello world` line in 0.5s)
>>
>>61435342
It won't, but even if it were it wouldn't matter. What matters is the BEAM.
>>
>>61435332
>Java
Pajeet, please. Nobody wants to spend 3 years and use a development team of 200 streetshitters to do what could have been done in 3 months by a team of 4 westerners in Node.js.
>>
>>61435348
Elixir is pretty good for scripting, command line tools and prototyping anything that talks over sockets. If you have any specific problems with Elixir for scripting, describe them and I might help you.
>>
>>61435350
BEAM doesn't solve any problems that you actually have.
>>
>>61435372
Tell me what you think those are.
>>
>>61435329
the base looks like C, and ES6 together with promises make JS look much better than it used to be.
>>61435332
i already use C/C++
cba learning java
perl is ass and should die
>>
>>61435347
stuffs like markdown, html/css parsers that speed matters

port for syntax hightlight and shit
>>
>>61435355
You say that but node .js has proven itself to be the worst at scalability and expression. The language itself is a complete disaster with abstractions and callbacks are the worst way to accomplish things. Javascirpt not supposed to be used as fucking desktop compiler or interpreter. It's a web language
>>61435384
You are a disgrace to the C c++ community
>>
>>61435379
BEAM is a terrible choice unless you're developing a large distributed system with OTP. Even then there are superior options now (Akka) running on vastly superior platforms.

Like most of the Ruby bandwagon hoppers, you've never written a system that requires BEAM or one that even takes advantage of its only strong point.
>>
>>61435367
>good for scripting
no because:
+ BEAM is slow to start up
+ def/macro needs to be wrapped in modules
+ can't use libraries (such as option parser) without have to setup a whole project

>command line tools
Same as above.
Also I don't know about other tools, but phoenix cli is fucking shitty

>prototyping
now you are clearly joking
>>
>>61435347
>When do you use NIFs?

Basically for everything that isn't simple IO. Erlang is slow as shit.
>>
>>61435231
Just finished an internal web application for my company using plain ass Ruby for the backend. Works prety gud.
>>
>>61435465
Did you monkey patch tons of core classes? It's hardly Ruby if you don't create an unmaintainable mess.
>>
>>61435437
>BEAM is a terrible choice unless you're developing a large distributed system with OTP.
BEAM and the OTP are a great choice if you want to talk to unreliable clients and/or servers and handle failure gracefully. BEAM languages change the way you develop software for two reasons: they rely on complete data immutability and have supervisors in the standard library that any third-party library worth a damn uses. It doesn't matter if your system runs on one node or a hundred because you get the core benefits of reliability and transparent data transformations in either case. On the immutability front only Clojure compares (and, I guess, Haskell?). I like Clojure and I acknowledge that it has superior performance, but in most cases I'll choose the OTP over raw performance.
>Akka
You could have at least said Quasar.
>Ruby bandwagon hoppers
Assumptions.
>you've never written a system that requires BEAM
No system requires BEAM (as Ericsson themselves proved with their non-Erlang telecom products), but a lot of them would benefit from running on BEAM. It is a no-brainer to choose it instead of an equally slow interpreter like MRI or CPython.
>>
>>61435511
It was just a crud api built with grape and a handful of gems. I worked with a competent architect with years of Ruby exp, so we avoided making a mess (I was 100% new to Ruby)
>>
>>61435696
>It is a no-brainer to choose it instead of an equally slow interpreter like MRI or CPython.
Unless you need a specific Ruby or Python library.
>>
>>61435437
to be honest I only use phoenix because its live reload feature is topnotch, and css/js livereload is decent, too. I have no need for OTP at all.
>>
File: erlang-map-reduce.jpg (57KB, 640x321px) Image search: [Google]
erlang-map-reduce.jpg
57KB, 640x321px
>>61435437

I wouldn't call BEAM a "terrible choice", since it's pretty good for every day tasks. Phoenix is a solid framework. But I do agree that it's overengineering for most problems "john doe webdev" usually has..


>>61435456

That's not entirely wrong, but it's inaccurate.
You have to be carefull when you compare things like.. say Java, Erlang, Node and Ruby/Python.


What are you measuring? Latency or Throughput? Or you do need a lot of raw computing power?

Based on your problem you want to use differnt tools..

>https://medium.com/@franzejr/ruby-3-mri-and-gil-a302577c6634
>https://elixir-lang.org/blog/2013/05/02/elixir-on-xen/
>https://news.ycombinator.com/item?id=4716589


>>61435465

There are many tiny Ruby frameworks, for example check out Cuba.


>>61435511

> t. "I-can't-into-proper-abstraction" WebDev
>>
>>61435735
Nah bro. We write everything from scratch using the magical powers of BEAM. Elixir totally isn't another shitty dynamically typed fad.
>>
>>61435696

> muh immutable functional programming

Functional programming is a fucking joke without a good static type system to back it up. Dialyzer is shit too.
>>
>>61435793
The functional programming meme isn't because functional programming is so good. It's because object oriented programming so so bad.
>>
>>61435824
You know what else is bad? Dynamic typing.
>>
>>61435866
dynamic typing is good for hundred lines of scripts

too bad the alternative choices were crap so they were used to build larger things which is not what they were supposed to do in the first place
>>
>>61435793
>Dialyzer is shit too.
Dialyzer is okay. Not great, but useful. I would love to have a good type system, and https://github.com/alpaca-lang/alpaca gives me hope, but I consider total immutability more important than static typing. I am not about to switch to Scala or Haskell, and those are about all the real alternatives.
>>
>>61435793
>>61435824
>>61435866

Jeez, you can't look at one tiny part like "dynamic typing" or "type systems" and ignore the rest..

For example:
Erlang/Elixir is pretty based (*cough* muh 9 nines *cough*) without a huge ass type system. Why? Because usually typing is a lot about preventing mistakes in production code. But since Erlang/Elixir is effectively all about error handling and dealing with programm mistakes, it wouldn't make any sense to use a type system like Haskell..

Or the other way arround:
In Haskell you need types to verify your programm runs correctly. In Erlang you say "scre that shit, as long as I can restart my process just come at me with all your trash data.."

Both ways can be succefull.


As for dynamic typing:
Ruby's core strengths are all about being flexible and fluid. Ruby isn't really "dynamic typing" like i.e. JavaScript, but it's all about a lot of tiny implicit casts. For example the program automatically decides wether you would have a buffer overflow and chooses an adequate data type for number. The result is that you can't have buffer overflows anymore.


Now it's up to your goal:
If you want calculate a few numbers and don't really care about micro seconds, but you just don't want your programm to crash if someone types trash, that Ruby does all that tiresome work for you and grecefully does the best it can with what it gets from the user.
If you want to do micro optimization and can be sure that your data is always in the "integer" range, then Java or even C would be the better option.

Both behaviours can be useful.
>>
>>61435997

> decides wether you would have a buffer overflow and chooses an adequate data type for number

That's trivial to do and many languages with static type systems have variable width numbers. The reason a lot of languages don't do that is because it's absolutely horrible for performance.
>>
>>61435997
Dude, get a spellchecker. It detracts from your argument.
>>
>>61436045

That's exactly what I was talking about:
Abstraction always comes at a price. So you want the right abstraction.

If abstraction was a bad thing then we would all programm in Assembly. But that would take way too and also we would have more errors.

So it's not about having internet fights about """good""" and """bad""" languages, it's about understading the differnt trade-offs.

If you have a "just open that stupid site, grab the contents and put them into a file" sort of problem, you really don't want to know about the nuts and bolt, but you want a clever langauge that tries to avoid problems whenever possible. So you would use something like Ruby.

If you need 100% logical perfection and reasoning you would rather use Prolog or Haskell. If you want something that works, even if this is the worst day in your server's life and shit really hits the fan, Erlang is at your service.


All those "my langauge is better than yours" is so stupid..
>>
>>61436067

Sorry, ran out of time..
:P
>>
>>61436150
> clever langauge that tries to avoid problems whenever possible

Ruby doesn't do anything to "avoid problems." It just lets you ignore them until runtime when they blow up in your face.

> all languages have merit

This is basically your argument and it's incredibly dumb. Some languages are just poorly designed garbage (PHP, Ruby, Python, Go etc.).
>>
File: 1478431480367.jpg (40KB, 897x869px) Image search: [Google]
1478431480367.jpg
40KB, 897x869px
>>61435355
>nodejs
kek
>>
>>61436205

> It just lets you ignore them until runtime when they blow up in your face.

No, it's a real difference when you can completely avoid buffer overflows.

Or do things like this:

streams = [$stdin, $stdout, $stderr]
streams << streams

streams[-1][1].write "test"


In the second line we added the object to itself. But this doesn't result in an error and we can access the last element of "a" (which is "a") and then write to $stdout.

Now tell me this isn't clever?


>PHP, Ruby, Python, Go etc.

What a stupid comparison..
Those are very differnt langauges.
>>
>>61436205
>PHP, Ruby, Python, Go
Each widely-used language has merit, even if it is extrinsic to the language itself. For instance, okay PHP programmers are much cheaper than okay Ruby/Python/Java/C# programmers.
>>
>>61436150
Fuck off underage
>>
Ruby is straight trash and anyone who thinks it is a viable language for a career should go shoot themselves. That shit is moving out of the scene faster than you can take a shit.
>>
File: JRuby.png (54KB, 400x400px) Image search: [Google]
JRuby.png
54KB, 400x400px
>>61434581

Can annyone comment on JRuby and Rails?

I'd think the deployment/speed should be much better, are there any downsides?
>>
>>61437080
Its still ruby, throw it away.
>>
>>61437093

Yes, there's no difference between C and Java..

Idiot.
>>
>>61434675
NOT PORTABLE
>>
>>61437080
Faster, takes forever to start, will probably be replaced by TruffleRuby. Give TorqueBox a gander.
>>
>>61435348
>compilation time is improved
That won't happen, unless the devs decide to implement a non-LLVM backend.
LLVM is amazing, but totally unsuitable for JIT compilation.
>>
>>61437061
There will be plenty of shit rails app that will need maintenance in the future anon
>>
>>61436205
>python is badly designed

kys
>>
>>61438652
As far as languages go, python is boring and uninspiring
>>
>>61438677
>boring and uninspiring
You've never used Python then. The rabbit hole goes deep.
As for "badly designed", it had some issues that Python 3 fixed but the direction it's going in now is highly questionable.
>>
>>61434581
But I do, OP.
In particular, I love
[1, 2, 3].sample
.
>>
>>61438652
He's right though.

What's worse are its implementations.
>>
>>61438652
string format
>>
>>61434818
>>61435310
What's the python userbase like?
>>
>>61438803
Significantly less SJW than Ruby and Javascript. Still quite a few SJWs that use it for web development with Django and Flask.
>>
File: AntifaMolli.png (302KB, 2400x2400px) Image search: [Google]
AntifaMolli.png
302KB, 2400x2400px
The alt-right jap Ruby community is fucking fire desu
>>
>>61438747
>sample
As opposed to
choice([1, 2, 3])
which also accepts any kind of sequence, not just lists.
>>
>>61438907
>as opposed to choice
Which you need to import, that makes it garbage.
>which also accepts any kind of sequence
Which is a useless gimmick.
>>
>>61439016
>namespaces are bad
>reusability is bad
I hope you don't write code that anyone else has to read.
>>
def SieveOfEratosthenes(size):
array = [True] * size
for each in xrange(3,int(sqrt(size))+1,2):
if array[each]:
array[each*each::2*each]=[False]*((size-each*each-1)/(2*each)+1)
return [2] + [each for each in xrange(3,size,2) if array[each]]

def ModInverse(a, m):
# Returns the modular inverse of a % m
if gcd(a, m) != 1:
return
q1, q2, q3 = 1, 0, a
r1, r2, r3 = 0, 1, m
while r3 != 0:
q = q3 // r3 # // is the integer division operator
r1, r2, r3, q1, q2, q3 = (q1 - q * r1), (q2 - q * r2), (q3 - q * r3), r1, r2, r3
return q1 % m
def generateRSAKey(keySize):
print("generating two Mersenne primes...")
p1 = generateMersennePrime(keySize)
p2 = generateMersennePrime(keySize)
print("generating n=prime1*prime2")
n = p1 * p2
print("determining a number coprime to n..")
e = randrange(2 ** (keySize - 1), 2 ** (keySize))
while gcd(e, (p1 - 1) * (p2 - 1)) != 1:
e = randrange(2 ** (keySize - 1), 2 ** (keySize))
print("generating modular inverse of number coprime to n...")
d = ModInverse(e, (p1 - 1) * (p2 - 1))

publicKey = (n, e)
privateKey = (n, d)

print('Public key:', publicKey)
print('Private key:', privateKey)
return (publicKey, privateKey)


python, most definately
>>
>>61439052
>namespaces are bad
>reusability is bad
They aren't. It's just that Python fails to deliver a commonly used functionality by default whereas Ruby properly delivers it as part of array objects which is only useful in context of arrays.

So Python really fails at two things in this example:
- overengineering for stuff YAGN
- easy access to an often used feature that shouldn't require an import

It's just like you'd needed to import the list length function in lisp or something.
>>
>>61439052
Ruby's module system is objectively awful. A real Rubyist would just monkey patch the core Array class and subtly break everything when some other library does the same thing in a slightly incompatible way.
>>
>>61439135
> choosing a random element is only useful in the context of arrays

Rubyists are actually this retarded. OOP was a mistake.
>>
>>61439135
>commonly used functionality
I disagree. Random number generation is definitely not common enough to warrant having "rand" in your namespace all the time.
Most programs I've written do not require any randomization and some that do would also like to be able to pick a random character from a string.

I can't believe that out of all the horrible things in Python, having to import a module is the dealbreaker for you.
>>
>>61439293
>Random number generation is definitely not common
It depends what you do for a living. cryptofag and security fag here. I use randint and randrange quite often.

I do concede though that most generic/hobby programmers of the plebeian variety would have little use for randoms.

Likely game programmers use randoms quite extensively as well
>>
>>61439344
>cryptofag and security fag
>using the random module
Did you see the big red box on https://docs.python.org/3.6/library/random.html ?
>>
>>61439377
i just read from /dev/random when it matters.

in many cases the py random library works.

depends on what im doing
>>
Has literally no one in this thread done anything with Linux or security? Python is king with anything security related. Thanks to the massive user base with open source Linux the py library has massive security advantages over ruby.
>>
>>61439539
see:
>>61439070
>>
>>61438834
Is the stereotype true?
>ruby = webdevs
>perl = sysadmins and unix wizards
>python = scientists/researchers
>>
>>61440115
Ruby is basically only used for web development with Rails and is undoubtedly dying.

Perl and Python have pretty solid libraries in most areas but Python is much more popular. Either one of them is a good choice for system administrators and, unlike Ruby, neither of them will be going anywhere anytime soon. Python has a huge advantage in a lot of research domains because of libraries like numpy, pandas, scikit, matplotlib, pytorch, tensorflow etc.
>>
>>61440471
Ruby isn't dying.
It's going to be around for years to come
>>
>>61440643
>Ruby isn't dying.

It's basically dead.
>>
>>61440471
I've never actually used Ruby for web dev in my life.
>>
>>61440655
Do you recommend any other language I should learn besides from Python?
>>
>>61440665
> muh anecdotes

That's nice. That doesn't change the fact that 99.99% of professional software developers using Ruby are using it for Rails and nothing else.
>>
>>61440699
Depends on what you want to do. Javascript and Python are the only dynamically typed languages worth learning, and they're only worth learning because the former is necessary for web development and the latter has libraries/bindings for basically everything.

They'll be the last dynamically typed languages to ever become popular.
>>
>>61440773
I've always hated the stigma behind web dev , I'm more into languages like C# , C++ , Rust.
>>
I'm about to start a job in a company that uses Ruby. How fucked am I?
>>
>>61434581
>Did you not know how inferior python is..
Like? I tried ruby for one project and while it was a smooth ride, nothing standout.
>>
>>61440866
Opposite of fucked, Ruby is a great language.
>>
>>61440882
Depending on the project to be fair.
>>
>>61439234
If you actually implement actual data structures in a scripting language you should be neutered anyway.

>>61439293
>Most programs I've written do not require any randomization and some that do would also like to be able to pick a random character from a string.
That sound like wrong string handling, desu.
>>
>>61440471
>muh babby hand holding libraries
this is pretty much every Python 'programmer'

people who know what theyre doing use the better language, Ruby is a better general purpose language, you can meme all you want about 'only used for Rails' or whatever, Ruby and Julia completely shuts out Python in every way, Python is just a shitty language built on ugly hacks and cludges, you can do nothing but latch on to your babby libraries to defend Python because its got nothing else going for it
>>
>>61441338
Whatever you say faggot. Enjoy your dead languages where absolutely no one is working on interesting problems.
>>
>>61434675
Only if you can write better routines in assembly than the nowadays ultra-optimized C compilers can. Otherwise you're just wasting time.
>>
>>61434802
>dead
Python is rated nr4 as most popular language by Tiobe, only behind Java, C and C++.

>hurr durr tiobe is shit because personal experience and wishful thinking say otherwise
yeah, I get it, you live in your own reality bubble.

Ruby is actually going down hard though, but it's still miles above Rust, Haskell, Erlang, Scheme/Lisp and other meme languages.
>>
>>61442074
According to Tiobe VB.net is rising steadily and it surpassed JavaScript last year.
I am not saying that Python is or that Ruby is not dead but this doesn't seem right.
>>
Perl is better than both
>>
>>61441338

lolololol Ruby has so many more back doors and vulnerabilities. Hmm maybe try building a secure server with Ruby instead of python...
>>
>>61435293
Venv is a feature not a bug and wheel fixes the egg issue
>>
>>61442904
It doesn't, but whatever
>>
>>61442904
https://www.cvedetails.com/product/22568/Rubyonrails-Ruby-On-Rails.html?vendor_id=12043
https://www.cvedetails.com/product/18211/Djangoproject-Django.html?vendor_id=10199
>>
>>61440773
>They'll be the last dynamically typed languages to ever become popular.
you're pretty intent on forcing this meme
https://rbt.asia/g/thread/61302365/#61304741
>>
>>61442931
Compared to Clojure where you can just say
 :dependencies [[org.clojure/clojure "1.3.0"]

it's a bug.
>>
>>61443062
It's a pretty common opinion among fans of static typing.
>>
>>61443205
They're going to get blindsided by Elixir.
>>
>>61443270
I like Elixir, but it has no chance of being anything other than a small niche language.
>>
>>61443315
I'd say it should grow to about match Ruby.
>>
>>61440471
>>61440655

>Rails and is undoubtedly dying
>It's basically dead.

I just love how Pythonistas keep on repeating this meme. They want this so much to be true..

I just checked in my city:
64 Rails jobs, 10 Django jobs.

Keep on dreaming, hahaha..


>>61439216

>le monkey patch meme.. xD
Yeah, you looked at Rails in 2009, right?


>>61439234

>choosing a random element is only useful in the context of arrays

Are you somehow retarded?

p rand

a = {a: 1, b:2}
a.keys.sample

require 'securerandom'
p SecureRandom.hex
p SecureRandom.base64
p SecureRandom.random_bytes
>>
>>61442816

Ruby is basically Perl with a cleaner Syntax.
>>
>>61443372
Doubt it. The programming language field is much, much more competitive now than it was when Ruby gained popularity. I doubt any language without a huge company backing it will ever gain significant traction again. Languages nowadays require a ton of libraries and tooling support to have a hope of catching on. The VM and compiler implementations are also much more complicated and the giant companies are hiring all of the small number of programmers that are capable of writing these implementations.
>>
>>61443383
>you looked at Rails in 2009

Rails still monkey patches tons of core classes.
>>
>>61443383
>64 Rails jobs, 10 Django jobs

Same city:
64 Ruby jobs, 3048 Python jobs
>>
https://2017.keeprubyweird.com

This website says basically all you need to know about Ruby and its community.
>>
>>61443497
It is there is more competition today, but it's also true that a lot of it is growing a bit stale (Ruby itself could really use the renovations promised in Ruby 3, Node cannot into threads, Go has a gimped type system, Python's tooling is subpar and the 2/3 break hurt it, etc.). Despite having no major company behind it, Elixir has some brand power of its own and obvious marketing channels (famous RoR people and Ruby conferences respectively), both of which are being exploited. It wisely chose an existing VM that others work on, so VM maintenance is not a concern, and people praise it for its tooling (mix, hex, standard test framework). Libraries may, indeed, prove a problem. As may performance, unless that LLVM Erlang JIT project succeeds.

We'll see. It is obviously not a certainty, but I'd give it a 65% chance, i.e., more likely than not.

Of course, there are also statically typed wild cards that may challenge Elixir on two fronts: Crystal as a Ruby replacement and Pony on concurrency (the creator of the latter swears he isn't a ponyfag). Both are really fast but have their own flaws.
>>
>>61443736
>It is true there is
>>
Ruby is nasty
If I want aesthetics I'd opt for Lua
>>
File: 15003207760220.png (448KB, 846x900px) Image search: [Google]
15003207760220.png
448KB, 846x900px
>>61434581
>2017
>Ruby
step up, grandpa, nodejs is making its way today
>>
Why are there so many ruby-like languages but not the same for python? Where is my compiled python-like language?

Nim is nice but unstable, bad docs, and I disagree with the way procs are handled.
>>
>>61443605
TACOOOOS xD
>>
>>61443605
Looks all right and memorable. If I didn't know what West Coast Ruby people were like, I'd want to attend.
>>
>>61443517

>Rails still monkey patches tons of core classes.

But you don't just go and monkey patch what you want and break everything.

If you really want to use monkey patching, the best way is to just patch an instance:

str = "Some String"

str.singleton_class.class_eval do
def upcase
'monkey patch only for this instance. it is safer this way..'
end
end

puts "this works as expected".upcase
puts str.upcase



Or if you want to monkey patch a whole class, you can simply include it where you need it:

module MyProject
module SummableArray
def sum_of_squares
self.map{|i| i**2}.inject(:+)
end
end
end

# put this in a class where you need it

Array.include MyProject::SummableArray

puts [1, 2, 3, 4].sum_of_squares



>>61443533

>Same city:
>64 Ruby jobs, 3048 Python jobs

Not exactly..

Python: 272 Jobs
Ruby: 113 Jobs


Like I said, Ruby is not going anywhere..


>>61443605

This is the first valid Ruby criticism in this whole thread.

Someone give this man a cake.


>>61443736

I'd love to see Elixir take off. It's really great.

But it will never really replace Ruby, because Ruby's key is simplicity. Whenever I forget the name of methods or wonder how something could be done I just type the most likely word and 90% of the time it's correct.
>>
>>61443957
>reddit spacing
>>
>>61443849
There is no language that's specifically like Python because any random "big" object oriented language is already enough like Python. I've written tens of thousands of lines of Python, and the truth, as I see it, is that beyond the clean way it looks Python is just another dynamically typed Algol flavor.

What is special about Python: significant whitespace, OOP with multiple inheritance, deliberate avoidance of FP? Language designers don't want to alienate their potential audience with those (mis)features because they're controversial. List comprehensions? They are usually replaced with lazy streams and better lambdas. "One way to do it"? Too vague. "Batteries included"? It's pretty much the standard now, thanks to Python's influence. The scoping rules? Nobody wants them because they suck. That's it.
>>
>>61434581

I always ask myself the same when people use JavaScript instead of Python.

Nevertheless, there's aws lambda support, a lot of nice libraries, especially data science, there's cython, pypy and if I really want to go 100% nuts on OO, I can simply call a ruby program.
>>
>>61444086

Damn, that really hurt my feelings!
Don't be such a meanie, anon..


>>61444163


Not him, but:

>significant whitespace

First thing that comes to mind is the SLIM templating system (I use it in my current Rails project)..

>OOP with multiple inheritance

But anon, Mixins are built in in Ruby and Scala.
Even Java can use them when you include the proper libraries..


>deliberate avoidance of FP

That's true. Python is trying way to hard to not be like Ruby here. It would be much nicer if you could just use basics like Map/Reduce in Python. List comprehensions aren't that great for bigger and more complicated tasks..
>>
>>61444262

Oh and I forgot: Why didn't you use Haskell? There's no excuse...
>>
>>61444163
Metaclasses
Function decorators
Context managers

>deliberate avoidance of FP
The lambda syntax is awful but functional programming style is very easy to do in Python. Especially now when most things return generators instead of lists.

>>61444324
>It would be much nicer if you could just use basics like Map/Reduce in Python
map is literally in the default namespace, reduce is in functools along with many other useful high-order functions.
>>
>>61444331
Laziness. Every data structure comes in lazy and strict and more. The string types are bullshit. The compile times are insane.
>>
>>61444383
>The string types are bullshit
More or less bullshit than Erlang's?
>>
>>61444470
Yes. Erlang only has what in Haskell's terms are strict String and ByteString. You basically use the latter for everything, especially in Elixir.
>>
>>61444550
s/Yes/More/
>>
>>61444470
Pretty much the same. Elixir's String is fine though and Haskell is fine as long as you use Data.Text instead of the default string type. There's a ton of shitty libraries on Hackage though that still use the default string type.
>>
>>61444373
>Metaclasses
"Advanced" statically typed languages have higher-kinded types, which are similar. I am actually not sure why metaclasses aren't more common. Maybe they are considered unnecessary? I'll admit I've written very few metaclasses after learning Python.
>Function decorators
I think language designers tends to prefer macros.
>Context managers
Many recent languages implement "with" in some way or other.
>The lambda syntax is awful but functional programming style is very easy to do in Python. Especially now when most things return generators instead of lists.
I guess that's fair enough, though I'll note that if it wasn't for the lambda syntax I think many of the standard library APIs could have been made more elegant by having them take lambdas. That is what I meant.
>>
>>61444331

Ruby is the Haskell of the scripting langauges..

a = (1..10) . select {|i| i.even?} . map {|i| i*i}

for item in a
puts item.to_s +
case item
when 0..9 then " < 10"
when 10..99 then " < 100";
when /\w+/ then " is a String?!?"
else " is something different."
end
end
>>
>>61444935
Metaclasses aren't similar to higher kinded types at all and Python's decorators aren't comparable to macros. They're just syntactic sugar for higher order functions.
>>
>>61443517
>Rails still monkey patches tons of core classes.
you keep throwing around the term 'monkey patching' like its a bad thing, duck typing is Ruby's strength, its the kind of dynamic late binding that is influenced by Smalltalk. The people in this thread trying to critisize Ruby are probably Java/C#/C++ programmers who dont get dynamic langauges and can only compare them with features they expect in static languages. The whole point of scripting languages is to handle external data which you have no control of, which dont know the types or sizes of and can only handle dynamically
>>
>>61434623

R5RS or R7? What implementation?
>>
>>61435231
>Outside of Japan, nobody uses Ruby for anything outside of Rails and that's slow as shit.

Fixed.
>>
>>61445052
>waaah waaah waaah, Im going to cover my ears keep meming that Ruby is dead
every Python shill in this thread
>>
>>61434681
python is not fast
>>
>>61434581
I love ruby, it's so comfy.

Don't fall for the python meme
>>
>>61445023
Duck typing and monkey patching are two very different and unrelated things retard. Almost everyone agrees that monkey patching should be avoided. This is only even debated within the retarded Ruby community and Matz even added refinements to discourage you retards from doing it in a ridiculously unsafe manner.

Are you the same retard that was saying metaclasses are very similar to higher kinded types?
>>
>>61444984
>Metaclasses aren't similar to higher kinded types
Why aren't they similar?
>They're just syntactic sugar for higher order functions.
Yes, but think about how they are used. E.g., in Flask you use decorators to assign routes to functions. Web frameworks in languages with macros use macros to create a routing DSL. @memoize is normally implemented as decorator in Python but as a macro in Lisps, Elixir, etc. And so on. In practice macros replace the need for decorators.
>>
>>61445052

Metaploit?
Homebrew?
Chef?
Puppet?
Everyday scripting?


>>61445120

This is basically correct, but I want to add that all bigger frameworks use monkey patching.

It is so comfy to use things like:
10.days.from_now
5.months + 30.minutes
"man".pluralize


;)
>>
>>61445104
correct, it uses an interpreter
the more additional features you install with python, the more resources it will take as well

Python is good for simpler syntax in order to make stand alone scripts for various tasks: ie -> a simple web scrape, parsing .xmls, shape files for GIS, etc.
>>
>>61435324
>Rust and JS
no, do not put Rust and JS in the same sentence...
blasphemy
>>
>>61445354
Pretty much good for anything up to certain points. We use it for internal tooling and even the entire web application that manages our entire datacenter infrastructure.
>>
>>61445171
>>61444935
I should have written "kind" instead of "higher kinded type". My bad.
>>
>>61445430
whoa, no way, an entire datacenter?
well, to be frank I have not used python outside of simple web projects
>>
>>61434581
Python is fucking shit./

t. C# shitter
>>
>>61434581
numpy
scipy
matplotlib
sklearn
shapely
basemap/cartopy
h5py
pandas


I need these things or equivalents for my daily work. If a language doesn't offer these functionalities + interactive shell like IPython, it's useless to me.
>>
>>61445499
Yes. We use it to manage the infrastructure of our three datacenters. Basically the DCO techs rack and setup a server initially, it gets a very basic set of info (including a serial #), takes that basic info gets puppet catalog, then from there you can kick off a custom kickstart in the application and watch it burn-in, and get finalized via puppet with it and do whatever you want afterwards from there.

Then after that we have some tooling to get your iLO ssh access if you need to debug and more info from the web application portion on the CLI.
>>
>>61435314
>cancerscript
>>
>>61445822
>coffeescript
Drink up, anon.
>>
>>61445052
kek
You obviously don't know much about python
>>
>>61434717
Last time I looked at benchmarks that wasn't true at all. In fact, PHP 7 beat Python, Ruby and Perl in most cases. It upset me, since I'm the reason the company I work for is a Perl shop, but facts are facts

But that's all besides the point. Ruby is the slowest out of the three in almost any case, Rails or no Rails
>>
>>61447649
Quote the wrong guy?
>>
Personally ever since I was taught scripting languages years ago, I had been on python. So that is just what I use, because I am so use to it, but I am fully aware of all of the benefits of ruby over python.
>>
>>61448016
The only benefits are development speed and style. And the lack of a community split between versions 2 and 3 I guess
>>
>>61447700
Most of the people saying Ruby is faster than Python are just looking at the Debian Benchmarks Game where the Ruby programs are just using the FFI to call into C libraries. They don't realize that it's not proving that Ruby is fast, it's proving that Ruby and its FFI is slow as shit.
>>
>>61434581
I agree that Ruby is a better language than Python but it is too little innovation, too late.
Python beat Ruby to the market by 4 years.
Ruby mostly improves on Python by avoiding the obnoxious emphasis on white space and taking OOP to a more extreme position. It is slightly faster, but they are both dogshit in speed anyways so it doesn't matter.
Python got established earlier, and competes in a completely different market than Ruby.
Python with numpy, scipy, and pandas is in direct competition with R, Julia, MATLAB and FORTRAN. It is arguably better too (although FORTRAN is awesome). Sciruby is shit by comparison, whereas Python is arguably better than R and at the very least it will kill the cancer that is MATLAB.
The only saving grace for Ruby is webdev, which it has been supplanted because hipsters don't like it anymore. Even if Rails is better than Django, Python fundamentally offers way more than Ruby.
Don't get me wrong, I think Ruby is a very nice language, but again it had too little innovation too late.
>>
>>61435314
wah brah so mazing
let me just use your shitty fucking npm system and all that support and years of packages for and the biggest fucking library of code in the world

Oh, sorry. NPM doesnt quite do that.
>>
>>61448177
While those may be advantages over Python, its probably wrong to say it "improves" on Python. If anything, it "improves" on Perl, at the cost of performance
>>
>>61445354
>Python is good for simpler syntax in order to make stand alone scripts for various tasks: ie -> a simple web scrape, parsing .xmls, shape files for GIS, etc.

>python
>good for web scrape

you must be joking, right? Try to crawl websites of languages other than english!
>>
>>61448078
>where the Ruby programs are just using the FFI to call into C libraries.

>implying python doesn't.

Are you stupid?
>>
>>61448946
>he's using python 2
>he couldn't figure out how encoding works
>>
>>61448177

Of course Python has a bigger market penetration. But if you look at how much support it gets (many universities teaching python as first language) it's astonishing that Ruby is at least 1/3 as big as python..

Don't get me wrong, I kinda like Python. But Python's "print(a(b(c(d))))" syntax feels terribly outdated. As for whitespace indention, it was a nice gimmick but nobody wanted this for other languages because it's not a good idea for bigger functions. So in Python you are constantly forced to write small functions and break problems down in 100 small steps.

To me Ruby is just the next logical step in scripting languages. It gives you the advantages of Python (batteries included and a super short and concise syntax) as well as all the Perl Shenanigans (i.e. RegEx, spaceship operator and what not). It also has a lot of brilliant influences: Blocks are a great way to use lambda functions: they are dead simple and get out of your way. Also Ruby is arguable the best OOP language ever created. Long story short:
I'm a really critical person but it's so hard to think of ways to make Ruby better.

Only downsides are that you can't create binaries that run with the speed of C. But that's just the way it is, I don't think that you can have the incredible flexibility and simplicity of Ruby with the speed of C.


So Ruby is not the "be all, end all" language, but when it comes to duct taping and modeling small applications, it's great. I would always use Python or Perl in a project, if there were advantages (better APIs, team of Perl/Python developers), but if I can choose for myself, Ruby is the way to go.
>>
>>61451090
>But Python's "print(a(b(c(d))))" syntax feels terribly outdated
As opposed to what in Ruby?

>whitespace indention
>it's not a good idea for bigger functions
I am baffled every time I see that mentioned. Do you not indent your functions in languages that don't force proper indentation?

Personally I hate Ruby's syntax (except blocks) but most of my issues with Ruby actually come from the conventions.
Implicit is considered good. Parenthesis for function calls are optional and people abuse that to create "DSL"s that are essentially a fancy way to fuse code and configuration together.
Other times you end up with abominations like RSpec where people try to pretend that they can write tests in English.
Rails has this idea that convention is configuration and unless you know exactly how Rails works you'll end up with problems because some of the "convention configuration" clashes with what you're actually trying to do.

I'd rather have "explicit is better than implicit".
>>
>>61450419
yeah like you fucking know the different between
Shift JIS, Big5 or GB2312. Do not google!
>>
>>61434581
I don't plan on touching Python until I see what happens after 2.7 is finally routed.

I keep getting this weird feeling that someone's going to fork Python2 so no one has to change.
>>
>>61451392

>As opposed to what in Ruby?

I just think it's bad design to parse the things you want to mutate as arguments. Basically Python is all about side effects.

Not talking about stuff like ",".join() where you tell the delimiter (!!) to fulfill a concat operation on his arguments.. sorry, that just doesn't fly for me.

Ruby is just more logical. All things that an object can do are a property of it's class, so you always work with the result:

"a b c".split.join(";").length


It's just a no brainer: String -> Array -> String -> Number


>Do you not indent your functions in languages that don't force proper indentation?


Yes I do. I'm not saying it's impossible, but it's not convenient for bigger functions. When I insert something I always check twice if I have the correct whitespace indention.

The result is that in Python you have to break everything down into very small functions. A lot of language constructs work only for small scale, i.e. try to making a really big list comprehension doesn't work, you need to break it down into pieces.


>Personally I hate Ruby's syntax

Different strokes for different folks, I guess..

>abominations like RSpec

What's your problem with RSpec?
It's super readable and understandable..

RSpec.feature "Users can sign in" do
let!(:user) { FactoryGirl.create(:user)}

scenario "with valid credentials" do
visit "/"
click_link "Log in"

fill_in "Email", with: user.email
fill_in "Password", with: "password"
click_button "Log In"

expect(page).to have_content("Log in successful")
expect(page).to have_content("My profile (#{user.nickname})")
end
end



>Rails has this idea that convention is configuration

Nah, it's "convention over configuration".Of course you need to do config sometimes, but if you have sensible defaults you can reduce the configuration needed. Conventions make sense, i.e. if I see a table I already know the names of the Controller/View.
>>
>>61435367
>If you have any specific problems with Elixir for scripting, describe them and I might help you.

Is there a lightweight elixir library for a simple rest api? Phoenix is too complicated and heavy.
>>
>>61451795
>Python is all about side effects
split, join and length are all pure functions. You should check what side effect means.

I agree that the Ruby version is slightly easier to read but Python's way of joining lets you join any kind of iterable instead of just arrays.

>When I insert something I always check twice if I have the correct whitespace indention.
That should be correctly handled by your text editor.
Even if it isn't you should know where you expect the leftmost part of the pasted code to appear.

>The result is that in Python you have to break everything down into very small functions
That's a very good practice in general but whitespace indentation definitely doesn't force you to do it.

>making a really big list comprehension doesn't work
It does. You can chain and nest them and they do exactly what you'd expect them to.
It's even very readable if you indent them properly instead of writing them in a single line. There is no forced indentation inside brackets and parenthesis.
If you reach the point where it becomes unreadable then you're better off writing a function and using map() or something anyway.

>What's your problem with RSpec
The problem is that it's adding alternative spellings for things that already exist in the language. Even basic things like comparison operators.
You need to learn a "DSL" just to write tests instead of writing them in Ruby. You might say that it's easy to learn but I find the whole notion ridiculous.

>Rails
It's been a few years since I've touched it so I can't give you exact examples but I do know that it was doing way more than I wanted or expected.
After I certain point I spent more time undoing the things Rails implicitly gives you than I spent configuring it.
>>
>>61448177
>Ruby mostly improves on Python by avoiding the obnoxious emphasis on white space and taking OOP to a more extreme position.
These are the more superficial differences. The ones that matter to Rubyists have to do with how the standard classes of the language like collections are designed.
>>
>>61448197
Your post in incomprehensible. Rephrase.
>>
File: dealwithitneti.gif (2MB, 261x238px) Image search: [Google]
dealwithitneti.gif
2MB, 261x238px
META

PROGRAMMING

/thread
>>
>>61452190
Just use Plug directly. Thanks to pattern matching it's expressive enough.
>>
>>61452717
thanks, just what I needed
Thread posts: 190
Thread images: 9


[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y] [Search | Top | Home]

I'm aware that Imgur.com will stop allowing adult images since 15th of May. I'm taking actions to backup as much data as possible.
Read more on this topic here - https://archived.moe/talk/thread/1694/


If you need a post removed click on it's [Report] button and follow the instruction.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com.
If you like this website please support us by donating with Bitcoins at 16mKtbZiwW52BLkibtCr8jUg2KVUMTxVQ5
All trademarks and copyrights on this page are owned by their respective parties.
Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
This is a 4chan archive - all of the content originated from that site.
This means that RandomArchive shows their content, archived.
If you need information for a Poster - contact them.