Tag Info

Hot answers tagged

76

I'll expand on my comment. I think there are a few factors that influenced the use of Python in scientific computing, though I don't think there are any definitive historical points where you could say, "Yes, that is the reason why Python is used over Ruby/anything else" Early History Python and Ruby are of roughly the same age - according to Wikipedia, ...


61

Ask the maintainers. Coding style is a quite subjective discussion, and rules like maximum line length of 80 characters are fairly subjective - while general agreement should be that shorter lines are better to read, 80 might be too restrictive for some with today's screen sizes and IDE's. Other rules can be ignored on purpose, too. For instance, a ...


44

You seem to be motivated largely by respect for the authority of the rubocop tool and the Ruby Style Guide, which the maintainers may not share. They already have their own style, and are used to it, so any change would affect everyone working on the project, and that's a lot of work, especially if the project is large. Consider the motivations of the ...


41

Compared to languages like Perl, Python has a limited number of control constructs: only if and no unless, only for that iterates over sequences and no foreach or C-style for, only while that checks a condition every loop and no do-while, only if-elif and no switch, there's only one comment construct, the #, and for every line you can tell if it is ...


36

Asking the object about its state, and then calling methods on that object based on decisions made outside of the object, means that the object is now a leaky abstraction; some of its behavior is located outside of the object, and internal state is exposed (perhaps unnecessarily) to the outside world. You should endeavor to tell objects what you want ...


30

Don't let the fact the Ruby rose into the common parlance largely because of Rails (the web application framework) fool you. It is a general-purpose programming language, and you can use it for anything that you can use any other language for. Play around with Ruby and see if you fall in love with it. You either will or you won't. It's kind of like the ...


28

I did Python back in 2003-5, when I was a Plone/Zope consultant. Then in 2006 I started picking up Ruby. I've never looked back. I think different people feel more comfortable with different programming languages and cultures, but for me, Ruby feels a lot better than Python. I personally think that compared to Ruby, Python is the reliable workhorse that ...


28

Blind copying of C, just like ratchet freak said in his comment The vast majority of "language designers" these days have never seen anything but C and its copies (C++, Java, Javascript, PHP, and probably a few dozen others I never heard of). They have never touched FORTRAN, COBOL, LISP, PASCAL, Oberon, FORTH, APL, BLISS, SNOBOL, to name a few. Once upon ...


27

This is from experience learning, continuing to learn, and writing a relatively simple application in Rails. 1) Learning Curve Rails is deceptively simple. The tutorials, videos, and books all demonstrate how quick you can get a working (if ugly) application, but these really just scratch the surface. They tend to heavily rely on code generation and ...


26

The simplest solution would be to create a list where each element occurs as many times as its weight, so fruits = [apple, apple, apple, apple, orange, orange, lemon] Then use whatever functions you have at your disposal to pick a random element from that list (e.g. generate a random index within the proper range). This is of course not very memory ...


25

You could tell them you're very good with Ruby (assuming you ARE good with Ruby) and that you'd be willing to learn Rails as a part of a new job (assuming you ARE willing and interested to learn the Rails framework). On-the-job training is not that uncommon. I had to pick up JavaEE, Spring, Hibernate on the job. I had Java and web apps (not in Java) so they ...


23

Pragmatism over Dogma, always. Coding style guides are an especially insidious form of evil that draw attention away from architectural concerns towards frivolous nonsense like single/double quoting. Ask yourself: Does it really make a difference? They can be good up to a point, but the second you treat them with an almost religious fervor, you've gone too ...


21

Dilbert's principle in action. No, ruby isn't a PHP generator. It is a language that has nothing to do with PHP except some usages.


20

Variables and symbols are different things. A variable points to different kinds of data. In Ruby, a symbol is more like a string than a variable. In Ruby, a string is mutable, whereas a symbol is immutable. That means that only one copy of a symbol needs to be created. Thus, if you have x = :my_str y = :my_str :my_str will only be created once, and x ...


20

Looking at most (if not all) dynamic languages [i.e Python, PHP, Perl and Ruby], they are all interpreted. Not true. You can compile Python source. That's one existential proof. There are interpreters for statically-typed languages, and compilers for dynamically-typed languages. The two concepts are orthogonal. Side note: In general, a language is ...


19

I have used Python extensively for engineering applications and Ruby for web applications. The problem I see with Ruby as a scientific language is that there are too many syntax options for a given operation. Python is designed with the following premise "There should be one-- and preferably only one --obvious way to do it". This makes it MUCH easier to ...


18

I went through the same deliberations and ended up installing Ubuntu through Wubi. It's a painless install and easily removable through "Add or Remove Programs" if you decide it's not for you. My choice was largely motivated by also wanting to gain more exposure bit more about the Linux side of things. Without that, I would have developed on Windows easily ...


17

This is a good question. I would leave your resume alone. It's good to filter out languages you are not comfortable working with, but do not filter out frameworks. You don't know what version of your resume will be sitting on someone's desk when they become interested in you. By the time they see it, you might be a well-versed Rails developer. With that, I ...


17

Sweet! I was about to suggest migrating this to Programmers, and here it is. Please, please, please learn some programming. Even if, at the very minimum, you only learn a little bit of the lingo and a few of the base concepts, the impact will be profound. This is because you'll be able to "talk the talk" when you do hire a programmer. I cannot fully ...


16

I've hardly used Ruby, admittedly, but here are my impressions of Python: when I write pseudocode to pencil out a function, I find that what I write practically is Python, and sometimes remarkably little rewriting is necessary to make it actual code. You might even skip the pseudocode all together and just express your thoughts directly in Python when I ...


16

Scaffolding serves a purpose - it's a rapid prototyping tool. Use it if that is what you are doing. Once you have your prototype, you can intelligently make the decision to modify what the scaffolding produced for you, or delete the scaffolding and build up the app exactly as you want it. If this is your first rails application, I strongly recommend ...


16

Read On Lisp and then decide for yourself. My summary is that Ruby is better at providing convenient syntax. But Lisp wins, hands down, at the ability to create new abstractions, and then to layer abstraction on abstraction. But you need to see Lisp in practice to understand that point. Hence the book recommend.


15

No. Google App Engine does provide a free/cheap infrastructure for hosting Python applications, but Ruby has virtually the same thing with Heroku (and Heroku has a lot less restrictions that GAE). Before using GAE, make sure to read very closely about the restrictions that Google puts on the platform, many of which can be significant barriers to the goal ...


15

O'Reilly's main line of books (the "Animal Books") are very technical and not (usually) well suited for beginners. Don't get me wrong; they are my absolute favorite (I've lost count of how many I have). If you are just beginning a programming language, I'd recommend the Head First series, which is ironically published by O'Reilly. They try to ease you into ...


15

No, but sometimes monkeypatch is a lesser evil (than having broken code :)). My general rules for monkeypatches in ruby are: have a really good reason for monkey-patch (temporary critical hotfix is a good reason. Nice formatting of to_s method is not, unless you're working on ActiveSupport) make them as transparent as possible: put them into specific place ...


15

Here's an algorithm (in C#) that can select random weighted element from any sequence, only iterating through it once: public static T Random<T>(this IEnumerable<T> enumerable, Func<T, int> weightFunc) { int totalWeight = 0; // this stores sum of weights of all elements before current T selected = default(T); // ...


14

Check Qt. it's arguably as rich as .NET, and the IDE (QtCreator) is simple yet pretty powerful. Of course, it's better used on the native C++, but the Python binding is kept complete and up to date. On top of it, it's really crossplatform, and that includes mobile platforms now too :-)


14

It looks like both the Git and Grit gems are now deprecated and should not be used in new projects. Work has already begun on a Git library written in C, and a ruby library which interfaces with it is also in the works. This new ruby interface to the git library is called Rugged. https://github.com/libgit2/rugged Once completed, this should be the Git gem ...


14

I have been doing this with python. I find that it is cumbersome to write in a hereditarily pure functional style in a language that wasn't designed for it. For example, contrast the two definitions of in_order: def in_order(xs): for i in range(1,len(xs)): if xs[i] > xs[i+1]: return False return True inOrder :: (Ord a) ...



Only top voted, non community-wiki answers of a minimum length are eligible