Hot answers tagged

24

"Besides the fact that a higher level language is easier to code in and therefore less error prone" I really think this is a good enough reason all by itself. If you have no compelling reason to work in a low level of abstraction (such as performance, knowledge in the team, etc), then there is no reason to do it. If all you want is a coffee, then you want ...


6

The authoritative reason is because PEP-8 says so: Comparisons to singletons like None should always be done with is or is not, never the equality operators. Thus, if you ever find yourself in dire need of comparing exactly to True or False, you should also use is. Remember: in cases like these, 'truthiness' is generally preferred over comparison to ...


5

Generally when someone refers to a programming language as scientific it is either because there are useful libraries for use in that field or the syntax of the language makes it easy to write the required algorithms. However, just because one field considers a particular language as a scientific does not mean that a different field considers it the same. ...


4

It mostly depends on how deep are your changes. Wrappers can bring additional behavior, but can rarely change the existing one. For instance, if a target library writes some data to a file and you want, instead, to send this data to a database, unless the library was designed to allow that, you won't be able to change the behavior just with a wrapper. If ...


4

Jeff Bezanson's PhD thesis on Julia, "Abstraction in Technical Computing" discusses this question at length, reaching only partial answers. Here are key quotes. We propose that technical users crave the flexibility to pick notation for their problems, and language design — the highest level of abstraction — is where you go when you need this level of ...


3

I think a very maintainable way would be to define functions that take a tweet and return a boolean like this: def has_terms(*terms): return lambda tweet: any(term in tweet['text'] for term in terms) def complex_rule(tweet): return 'boo' in tweet['text'] and not any(y in tweet['text'] for y in no_words) Then you can set up your list of rules ...


2

Money. Cheaper developers, faster development speeds, and less bugs equal more money. Portability. Many high level languages allow you to target different platforms out of the box. Low level languages like C require significant efforts run on multiple platforms. Training. You can train a developer in Python in a day, while something like C++ takes ...


2

Standard input and standard output seems to be the simple overlooked answer (or maybe I'm not understanding the problem). For anyone reading this now, stdin and stdout is the simplest way for two applications to communicate. The main application can spawn a different process and send messages through stdin and stdout. It's simple, direct, and fast. However, ...


2

I don't know whether TypeScript enforces type constraints at compile or run time. But Python does support type hints. Python 3.0 introduced function annotations as defined in PEP 3107. They work like this: def log_in(login: 'Login', password: 'Password') -> 'Return value': # ... log_in.func_annotation['login'] # => 'Login' log_in.func_annotation[...


1

I'm sure the type specifications could be used to greatly speed up the runtime […] No, they can't. The definition of an optional type system is that it does not impact the runtime behavior in any way. That's what makes it "optional" in the first place. If adding or removing types made the program change its behavior, the types wouldn't be optional. Note ...


1

Don't think too much about Pip. If your Setuptools configuration works correctly, it's easy enough to upload all and only those files you actually want to PyPI (at which point end users will be able to install it with Pip; developers will be cloning your git repository since they need history for things like git bisect to work, and Pip does not provide git ...


1

Higher lever languages are by definition easier to learn, they take away a lot of the complexities of lower level programming such as memory management. Besides that since the explosion of hardware power it is much cheaper to get a faster processor or more RAM into a machine that paying the developer hours that'd come with a more complex programming language....


1

As a general, largely language agnostic approach, any time you're concerned that the behavior of a third party library might change, the providing of that behavior (be it your own code in the future, or another third party library) might change, or you simply want to decouple the third party library, it's perfectly reasonable to build a more abstracted ...


1

The problem you currently face with a simple HTTP post simply cannot be solved in that protocol. HTTP works asynchronously in strict client/server so there is no server-side notification and no native cancel. Also, you will face the problem of answers lost because of internet network timeouts. I will suggest a different and modern approach. Disclaimer : a ...


1

I think you missed probably the more important part of the book's corrected example. The more fundamental change to the code is from the method operating on all values in a list to operating on one element. There already exist functions like iter (in this case named pipeline_foreach) which perform a given operation on all elements in a list. There was no ...



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