Hot answers tagged

102

Nope. They're really handy for implementing Observers and making sure that classes are closed to modification. Let's say we have a method that registers new users. public void Register(user) { db.Save(user); } Then someone decides that an email should be sent. We could do this: public void Register(user) { db.Save(user); emailClient.Send(...


52

Nope. A classic example of events being used in non-GUI logic are database triggers. Triggers are code that gets executed when a given event happen (INSERT,DELETE, etc). Seems like an event to me. This is the Wikipedia definition of event: In computing, an event is an action or occurrence recognized by software that may be handled by the software. ...


43

There are lots of languages which already work this way, e.g. Haskell. In Haskell, every function takes exactly one argument and returns exactly one value. It is always possible to replace a function that takes n arguments with a function that takes n-1 arguments and returns a function that takes the ultimate argument. Applying this recursively, it is ...


39

Robert C. Martin in his book "Clean Code" recommends heavily the use of functions with 0, 1 or 2 parameters at maximum, so at least there is one experienced book author who thinks code becomes cleaner by using this style (however, he is surely not the ultimative authority here, and his opinions are debatable). Where Bob Martin is IMHO correct is that ...


28

Event-based programming is actually also used for highly performant server programming. At a typical server workload, much of the time processing a result actually comes from I/O. For example, pulling data off a (7200 RPM) hard disk drive can take up to 8.3 ms. For a modern GHz processor, that would equate to ~1 million clock cycles. If a CPU were ...


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 ...


9

Events are also heavily used in network programming (e.g. Nginx) to avoid expensive busy-wait loops and instead provide a clean interface to know exactly when a certain operation is available(I/O, urgent data etc). This is also a solution to the C10k problem. The basic idea is to provide the OS a set of sockets (i.e. network connections) to monitor for ...


7

I've been spending some time these last few weeks attempting to learn the J computer language. In J, pretty much everything is an operator, so you only get "monads" (functions that have only one argument) and "dyads" (functions with exactly two arguments). If you need to more arguments, you have to either provide them in an array, or provide them in "boxes"...


6

Steve Yegge wrote a great blog post that, somewhat indirectly, addresses this. Big point #1: compilers encompass pretty much every aspect of computer science. They're an upper-level course because you need to know all the other things you learn in the computer science curriculum just to get started. Data structures, searching and sorting, asymptotic ...


6

Are there any general-purpose programming languages with classes, objects, methods, interfaces, and so on, which disallow class-based inheritance? This reads very much like a description of VBA - Visual Basic for Applications, embedded in Microsoft Office and other VBA-enabled hosts (e.g. AutoCAD, Sage 300 ERP, etc.), or even VB6. The "A" of "Basic" stands ...


5

Embedded systems are almost always inherently event-driven, even if they are not programmed explicitly as such. These events come from things like hardware interrupts, button presses, period analog-to-digital readings, timer expirations, etc. Low-power embedded systems are even more likely to be event-driven; they spend most of their time sleeping (CPU ...


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

A language based around how it constrains the developer is dependent on the assumption that the language developer understands the needs of each programmer better than the programmer understands those needs themselves. There are cases where this is actually valid. For example, the constraints on multithreaded programming requiring synchronization using ...


4

Your question is too broad to be answered in a few paragraphs. And actually interpreters do not mean much: the BASIC interpreter of the ZX80 (in 1980) is really different from today's Guile, Lua, Ruby, or Python interpreters on most Linux systems. Knowing several programming languages, e.g. by reading Scott's Programming Language Pragmatics, is worthwhile. ...


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 ...


4

The Wake Programming language is designed to use dependency injection. Basically, it has the equivalent of a dependency injection framework baked into the language itself. Classes define the parameters they need and provide and the compiler hooks everything up.


3

Event Messages Gregor Hohpe. Event Driven Architectures Gregor Hohpe. SEDA architecture, Welsh, Culler, Brewer. how do you handle in normal backend programming when something happens do this other thing? Finite State Machine is one common approach Given(State.A) When(Event.B) Then(State.C) .and(Consequences.D)


2

I know more than 30 programming languages and yet I agree with your prof. It's better to invest your time in the algorithms and approaches than in the languages per se. If Azure seems shallow to you, invest in something else. Dynamic programming, databases, machine learning, high availability, etc etc. For resume it's more important to show that you're ...


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

An interpreter is feed a program represented as a data structure, then it steps through each of the tasks in the data structure and performs the tasks as it goes. The data structure can be a abstract syntax tree of the code you wish to interpret, or it can even be a byte-code if you wish. Interpreters may also hold on to a table (hash map) of variable names ...


1

In just about any programming language, you can pass some type of list, array, tuple, record, or object as the only argument. It's only purpose is to hold other items instead of passing them to a function individually. Some Java IDE's even have an "Extract Parameter Object" feature to do just that. Internally, Java implements variable numbers of arguments ...


1

You will need two things: Closure Composite data type I will add a mathematical example to explain the answer written by Jörg W Mittag. Consider the Gaussian function. A Gaussian function has two parameters for its shape, namely the mean (center position of the curve) and the variance (related to the pulse width of the curve). In addition to the two ...


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

Many years ago I read about this topic in a JavaScript book, I cannot remember which one it is. But I can still remember the discussion about whether JavaScript should be considered as an OOP language, the author's answer is yes, coz it meets the four criteria for a language to be object oriented: Encapsulation, which allows you to combine data and ...



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