New answers tagged

0

This is an old question, but in case you are still interested, you might look at Qore, which is an interpreted language with fundamental support for multithreading and also has a unique garbage collection approach (Prompt Collection) which allows for the language to support the RAII idiom (c++-like destructors for resource management and exception-safe ...


3

To make it simple: Static state is bad because it is effectively global state since everyone has access to it. Wrapping it in a singleton doesn't change anything. In general it is good to avoid global state which is hard to test. Static functions that are pure functions or that only mutate their arguments are perfectly fine. If they don't do any ...


6

The notion that static methods are impossible to unit test is a myth that has proven difficult to kill. What makes a method hard to test in isolation is stuff like hidden dependencies and accessing static state. There is no difference whatsoever between a static method and an instance method, except for the fact that invocations of instance methods get a ...


0

This is a Java-specific design. For example in D, sort is an instance method on arrays, not a static method as in Java. But in Java arrays are special. They are defined as objects, but they are not instances of classes. The only instance methods they have are the ones inherited directly from Object. There are no Array-specific instance methods since there ...


3

Is there some historical or practical reason why SQL (or more specifically T-SQL in my case) does not support the closure property in many areas where many other language families like C do? The historical reason is that Codd first defined the concept in 1970 and it wasn't turned into what we would now call SQL until 1974. Many of the things that would ...


4

1) Sql does support relational closure, which means you can use base tables, table literals, views, subqueries, CTE's, table variables and table-valued functions interchangeably in queries, and nest them arbitrarily. You can also use the resultset from a stored procedure in a query, as long as you execute the query and loads the result into a temp table ...


5

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


1

FFIs are based on C. They look like C. And therefore, FFI-based interfaces are limited to C. I'll use Lua as an example, since that's what I'm most familiar with. If you were using the Lua C API, you could expose a system to Lua that looks and behaves like Lua expects it to. It could expose objects that Lua code could store and call like other Lua stuff: ...


3

This sounds like the old CFront compiler - which compiled C++ into C: Cfront was the original compiler for C++ (then known as "C with Classes") from around 1983, which converted C++ to C; developed by Bjarne Stroustrup. The preprocessor did not understand all of the language and much of the code was written via translations. Cfront had a complete ...


0

I agree with Robert Harvey... this is not a bad approach. If you would like to see an example of "class" design in c that uses a different approach look at X11/xview/etc https://www.x.org/wiki/guide/ to see how structs are used like classes...


2

Some food for thought. Overloads are traditionally done at compile time. You're talking about doing runtime differentiation of overloads, or in other words, introducing a runtime dispatch to the selection of the overload. There are several things of interest. First, most languages with static type systems that do runtime dispatch (e.g. for virtual or ...


1

A very similar approach is common in object-oriented languages. There, it's called function overloading and it means that you have multiple distinct functions with the same name, but different signatures. These languages don't assign type to the group of functions with the same name, but I think one way to look at it is that it's a tuple (or, more formally, ...


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.


2

In my opinion, exceptions are an essential tool for detecting code errors at run time. Both in tests and in production. Make their messages verbose enough so in combination with a stack trace you can figure out what happened from a log. Exceptions are mostly a development tool and a way to get reasonable error reports from production in unexpected cases. ...



Top 50 recent answers are included