5 ms·
Ruby or Python? Well, it depends...
- ctide 15y agoI thought it was a pretty good article until I got to: "Since they are often used for the creation of webapps one should consider the deployment issue. Most web hosting companies provide cheap Python hosting, but very few companies provide Ruby hosting." Which pretty much killed it. Doesn't Heroku alone pretty much blow this statement away?
- iamscanner 15y ago> Doesn't Heroku alone pretty much blow this statement away? Not really - he said "very few", not "there aren't any". You can find mod_python all over the place - where are your shared ruby hosting options?
- ctide 15y agoI just mean that it implies that finding cheap hosting for a ruby webapp is problematic. If the purpose of that statement is to say that more places will support Python than Ruby, then it should probably be worded differently.
- tesseract 15y agoHeroku may be a good value for what it is, but it's vastly more expensive than a lot of entry-level shared hosting services - you know, the kind of place that starts at $5 or $10 per month and runs cPanel or an equivalent. Lots of those support Python these days; Ruby support still seems to be much rarer.
- cubicle67 15y agoHeroku hosting starts at $0. I've got about a dozen apps running on Heroku, most of which I pay nothing for
- danenania 15y agoHeroku's free hosting is leaps and bounds beyond what a typical $5-$10 shared host offers, and there's an easy upgrade path. Sure, you can come up with specific usage levels where a shared host is cheaper on a bit-to-dollar basis, but you're still not accounting for Heroku's main selling point: convenience and saving developer time. This plus the fact that the vast majority of sites on $5-$10 shared hosting would fit easily on Heroku's free plan means that value-wise, Heroku faces much stiffer competition from Linode than any shared provider. I like and am comfortable with both Python and Ruby, and one of the biggest reasons I choose Rails for projects nowadays is Heroku, and I'm not alone. Given this, I really don't see how you could claim Python has any edge when it comes to hosting. If you're concerned about what tons of shared hosting providers have installed, why not just use php?
- stoic 15y agoWe support Rails at HostGator.com, either using cPanel-managed Mongrel or through a FCGI dispatcher (I personally assist with multiple set-ups daily). Perhaps not as ideal for a 100% Rails shop as Heroku, but the option is definitely there.
- latch 15y agoPython and Lua were the first languages I used that had tuples as a native/core/whatever type. Absolutely love them. Changes how you program sorta thing. Mind blown that every language doesn't have them. Despite this, I can't get into Python (having tried 3 or 4 times the last couple years). The Ruby ecosystem is simply more polished...gem, rvm, capistrano, rails, sinatra bundler, .... I really tried to fall in love with Python/Django, and it just isn't as good as Rails by a wide margin. When languages are as close as Ruby and Python (or C# and Java), frameworks/ecosystem/community matters a ton more.
- RK 15y agoWhen languages are as close as Ruby and Python (or C# and Java), frameworks/ecosystem/community matters a ton more. This is exactly why I use Python over Ruby: scipy, numpy, matplotlib, etc. The right language + ecosystem will obviously be very domain dependent.
- PandaMilk 15y agoYou might think it's more polished because you know the ecosystem better but pip does the same thing as gem & bundler, virtualenv the same as rvm and fabric the same as capistrano. I have the same problem you have, I can't for the life of me see the point of learning Ruby and because of that I never give it a fair chance.
- latch 15y agoI totally think you can be right about my perspective. I can tell you my last expedition in Python land was bad. I ran into two problems: upgrading the version of Python that came on my Air and installing MongoEngine. For MongoEngine I used the instructions on their website "easy_install -U mongoengine". And after a bit of googling (I say a bit because a lot of people were having the same problem I was) I ended up installing PIP (via easy_install no less!) and then got into pathing problems. Having to use one package manager to install a better package manager isn't polish. Again, I can agree that this might all just be familiarity and comfort (or lack of in this case). I'm not so open to Django vs Rails though. I don't need to do a lot of struts to see how horrible it is (compared to anything). I don't need to do a lot of Django to see that it's behind Rails as a productive web frameworks. I'm not completely closed to the possibility that i'm just an idiot, but at this point it would likely take working with a guru for a couple weeks to change my mind.
- edanm 15y ago"If you’re looking for a flame post - this is not one of them. I love both languages and I’ll simply compare some of their features and possible uses." This was an interesting post, and I'm sure the op didn't mean any of it as a "flame". Problem is, on a lot of the comparisons, the op just said "I won't get into this, but I prefer Python" (or Ruby, depending on the feature). Those kinds of statements don't really advance anyone's knowledge, but are sure to get some people annoyed. As someone who uses Python but hasn't learned Ruby, this article got me to the same conclusion I alway get - while Ruby has a few very interesting differences and clever tricks I'd love to learn, it's so similar to Python that I'm better off learning a completely different language. One thing I think is tiny, but incredibly helpful in Ruby, and I don't understand why more languages don't have it - the ability to add "?" and "!" to operators. That's an actually useful convention.
- tesseract 15y ago> One thing I think is tiny, but incredibly helpful in Ruby, and I don't understand why more languages don't have it - the ability to add "?" and "!" to operators. That's an actually useful convention. My primary languages are Ruby and C. After working in Ruby for a while and then switching back to C I often find myself naming predicates with a trailing _q. I don't have an equivalent for !, though.
- edanm 15y agoIn C/C++, I was usually in the habit of adding "Is" in front of predicates. "something.IsDone()", "something.IsOver()", etc.
- wybo 15y agoWhile the '!' addition to methods is an useful convention, having both collect, and collect! methods, and for example only a delete method for arrays (which does change the array it is called on), and similar inconsistencies in libraries, can occasionally lead to unnecessary API-lookups/bugs. (I have been using Ruby (in a FOSS/academic setting) for a couple of years now (and I know Python too, though still prefer Ruby over it))
- jessedhillon 15y ago> Ruby’s REPL(irb) seems to me more advanced since it allows you to do TAB smart completion(amongst other things). You can easily have tab completion and a bunch of other good stuff (like preserving history across sessions) with the Python REPL. You have to use the PYTHONSTARTUP environment variable to indicate a script that is run when the Python shell begins, and that script has to use adjust some rlcompleter and readline setttings. It's all right here: http://docs.python.org/library/rlcompleter.html http://docs.python.org/library/rlcompleter.html Incidentally, this is the first result on Google for "python tab completion"
- lloeki 15y ago"but python + any python IDE < Java + IntelliJ IDEA(Eclipse/NetBeans)" (and I suppose s/python/ruby/g and s/Java/C#/g too) I don't quite agree with this statement as I find python and ruby development easy, perfectly usable and well performing in a generic code editor (vim, emacs, textmate) whereas doing Java or C# almost mandates a full-blown heavyweight IDE with smart code completion like IntelliSense to get anywhere near the same efficiency. I've tried a few IDEs for python and ruby, and they seemed almost more of a hindrance than a help, and definitely not a significant improvement.
- StavrosK 15y agoThis has been my experience as well. IntelliSense, import resolution, auto refactoring etc are all good, but I always find myself going back to vim because I've finished editing by the time eclipse starts up...
- lloeki 15y agoPython's REPL has autocompletion. It is just not enabled by default as it lives in its own module and python prefers to start in an absolutely clean state. >>> import readline >>> import rlcompleter >>> readline.parse_and_bind('tab: complete') See this article for the details (and more, like history persistence and REPL startup file): http://valueerror.wordpress.com/2009/11/03/python-shell-history-autocompletion-and-rc-file/ http://valueerror.wordpress.com/2009/11/03/python-shell-hist...
- StavrosK 15y agoWho doesn't use ipython these days, though?
- j4mie 15y agoI use bpython: http://bpython-interpreter.org/ http://bpython-interpreter.org/
- StavrosK 15y agoAlso excellent.
- dagw 15y agoPeople who use DreamPie (http://dreampie.sourceforge.net http://dreampie.sourceforge.net)
- arctangent 15y agoI've read about it but never used it - I write all my code in TextMate, Notepad++ or Nano, depending on where I am and what I'm doing. Could you outline what you see are the main benefits of using an enhanced interactive interface to Python such as IPython?
- lloeki 15y agoIt actually makes python a full-blown shell (which python REPL is not): $ ipython Leopard libedit detected. Python 2.6.1 (r261:67515, Jun 24 2010, 21:47:49) Type "copyright", "credits" or "license" for more information. IPython 0.10.1 -- An enhanced Interactive Python. ? -> Introduction and overview of IPython's features. %quickref -> Quick reference. help -> Python's own help system. object? -> Details about 'object'. ?object also works, ?? prints more. In [1]: ls Applications/ Downloads/ Movies/ Public/ Workspace/ Desktop/ Dropbox/ Music/ Sandbox/ Documents/ Library/ Pictures/ Sites/ In [2]: ls | grep App Applications/ In [3]:
- bajsejohannes 15y ago> Ruby and Python do not have statements - only expressions. Unfortunately this is not true for python. The reason his print-example doesn't show the returned value is that there isn't one. In ruby, puts actually returns Nil, and we can assign it: >> x=puts(0) 0 => nil Whereas in Python, we get a syntax error >>> x=print(0) File "<stdin>", line 1 x=print(0) ^ SyntaxError: invalid syntax
- andrewcooke 15y agothat's fixed in python 3 [edit: sorry, yes, i agree the general problem remains.]
- bajsejohannes 15y agoFor the specific example of print, then yes. But in general it is not. Another example is if-statements in python: >>> x=if True: File "<stdin>", line 1 x=if True: ^ SyntaxError: invalid syntax whereas in Ruby: >> x=if true: ?> 5 >> end => 5 Other Python statements from the top of my head: for, while, def, import. My point is that there absolutely are statements that are not expressions in Python. (You can easily tell by trying to assign the return value: x=<statement>).
- kbd 15y agoHeck, assignment itself is a statement. That's why you can't say while x=y: ... (and you'll notice the REPL gives no return value for an assignment). This "Python has no statements" error was one of my biggest annoyances with this article, as Python has a very strong statement vs expression dichotomy.
- deleted 15y ago[deleted]
- lloeki 15y agoBarring the fact that print became a function in Python 3 (and in Python 2.6+ with `from __future__ import print_function`), Python functions actually `return None` when the end of scope is reached, and indeed Python REPL does not show `None` being returned. >>> def a(): ... pass ... >>> a() is None True >>> a() >>>