Tag Info

Hot answers tagged

6

Because Java has a pretty good trade-off between productivity and performance; it is somewhere between PHP/Python which are very productive and C/C++ which are very performant. Gmail is a large site which has lots of clients; here problems of scalability occur and Java is a more scalable language than PHP or Python. Also Java has some very good frameworks ...


5

Is it possible to create a programming language or write object-oriented code without static/class methods/variables? Absolutely. Case study: the Javascript programming language. The key insight is that, if you squint a bit and hold your head at an awkward language, classes start looking like objects. Special objects that do funny things when you poke ...


4

The usual argument for avoiding instanceof is "Instead of checking the type of a thing to decide on an action, you should make that action a method of that thing, and use inheritance to ensure that every thing automatically does the right thing." In other words, use the method look-up mechanism built into the language rather than program your own. However, ...


4

There's no such thing a simultaneous order. Your server is going to have to process one of the basket add actions first. At the point that happens the product should be locked, and any subsequent basket add actions should return an out-of-stock message. If the customer doesn't checkout within a fixed time (often one hour) it's normal to remove the lock on ...


3

Why wouldn't you? You can use any object as a Hash key in Ruby. (Well, any object that responds to hash and eql?, but since there are definitions of those in Object, that's pretty much all objects.) It would be strange and inconsistent if you would arbitrarily exclude two classes from that.


2

Supply and demand. Manipulating Excel spreadsheets is a task which is extremely useful to many people, hence there is considerable demand for code that does this, hence that code exists. Manipulating ODS spreadsheets is useful only to a very tiny niche, hence there is minimal demand for code that does this, hence nobody has bothered to expend much effort ...


2

Are you looking for something like Python Server Pages? <html> <% import time %> Hello world, the time is: <%=time.strftime("%Y-%m-%d, %H:%M:%S")%> </html>


1

Why limit the keys by a limited set of types? As long as it is an Object, you can use it as a key. Even a Proc or lambda can be used. my_proc = Proc.new { "Hello World #{Time.now}!"} my_hash = { my_proc => 'a proc', my_proc.call => "a proc that was called at #{Time.now}" , [3, 2, 1] => 'My 3, 2, 1 array'} my_hash.default = "There is no key with ...


1

Well, you probably know this much already; but for starters, I'd say that's probably very bad practice. Still, it's an interesting functionality question, so I'll give it a shot... From what I understand, Ruby maintains its empty arrays and hashes all as one singleton object, just as Nil is a single object in the entire program. If you declare 5 arrays with ...



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