Tag Info

Hot answers tagged

23

Because in order to free memory as soon as the reference counter hits zero, you have to keep a reference counter. And that doesn't come for free. Typically, it limits your throughput. There are generally two major strategies for implementing garbage collectors: tracing collectors and reference counting collectors. (There are others, but those are the ones ...


15

I wouldn't call it a programming language. It is a framework. I have heard similar things about building on Zend (PHP) or building on Rails (Ruby). It seems pretty common these days to mention the framework instead of the specific language.


14

Because it would be too expensive to do it continuously. "Mark and sweep" garbage collectors periodically sweep the memory space for objects that have been dereferenced. Generational garbage collectors sweep those objects first that are most likely to have been disposed of recently (which turns out statistically to be the objects most recently created). ...


11

You keep on changing your function. But keep picking ones that will run forever without conversion.. Recursion gets complicated, fast. The first step to analyzing a proposed doubly recursive function is to try to trace it through on some sample values, to see what it does. If your calculation gets into an infinite loop, the function is not well defined. ...


10

Check out GNU MP. It has a C++ class based interface if the C one is too scary. As far as the speed comparison goes, I would seriously take into account programmer speed here. If it's going to take an extra month to do it "the fast way" for a one-shot program because of unfamiliarity with the language, I wouldn't bother.


7

It's actually not dissimilar to how people see JQuery - it's a framework, but due to the syntax and the actual 'way' you program things, it looks like it's a language on its own, or a DSL if you're inclined to think of it in that way. Similarly, you could look at Node like that. Its language is Javascript, but it effectively has its own standard library, ...


6

Benchmarking is a difficult science. It seems that your computer is conspiring against you: Your CPU keeps often-requested data in caches. As accessing memory in a cache is faster than using other memory, this can warp benchmarks. Your OS may cache files in memory rather than loading them from disk. Obviously this hasn't happened the first time you run a ...


6

There were a lot of tongue in cheek statistics in black and white. It's also possible that the statistic is just some semi-random number based on some function that is not actually linked to any real code execution statistic.


6

I would recommend creating your DSL on top of an existing language (internal DSL). I've done this a few times with Python, creating systems where the consumer of the DSL writes a python file that is used as a configuration file for the system. The configuration file uses constructs (classes, functions) that I have defined. These constructs form the DSL. ...


5

The runtime of that particular pair of functions is infinite because neither returns without calling the other. The return value of a is always dependent on the return value of a call to b which always calls a... and that's what's known as infinite recursion.


5

Most of these terms have become very ambiguous. "Library" is the simplest. It's just some utility code that resides on your computer, designed to be used by applications or other libraries. It could be a standard library that came with the compiler/interpreter, or it could be a third-party library. Some "pure" libraries are written only in the user's ...


5

What you described is achievable via Aspect-Oriented Programming (AOP). It won't be as straightforward as in your example, but you can get the requested behaviour. AOP has implementations in different languages; AspectJ being one of the most mature one. I will give you an example using AspectJ even though I don't want to go to in too much detail. To ...


4

I think the main reason is that BlueJ runs your code in a VM with a debugger attached. BlueJ actually has two VMs running: the main one, and the one with your code inside (the user VM, aka the debug VM). The main VM has a debugger attached to the user VM, which allows it to do things like pause user code, inspect the state of objects and all sorts. I ...


4

The line can be very fuzzy, but the distinction lies in their intended purpose rather than their implementation. Language VMs typically operate at a higher level of abstraction. They may execute bytecode or execute the AST directly. JIT compilation may occur in either case, but I don't know of any processors that implement GC (except possibly lisp ...


4

By many different methods, not easily reduced to just a few paras. Here are some, in roughly ascending order of abstraction. The OS implements one or more privileged instructions (trap, syscall, etc). The compiler emits code to translate certain language constructs into those instructions. [ASM] The OS provides an API in a form compatible with the external ...


3

If your server app is open source, no... I.e. you give the code away freely If you don't want to give the code away, you need a license per developer working on the site.


3

In C# you just do: void InterfaceA.doWork() { } void InterfaceB.doWork() { } So there are no real shenanigans involved. The calling function needs to identify which doWork() is intended: Instance io = new InstanceSubclass(); ((InterfaceA)io).doStuff(); See this page for more details.


3

The obvious method is to run the function and measure how long it takes. This only tells you how long it takes on a particular input, though. And if you don't know beforehand that the function terminates, tough: there's no mechanical way to figure out whether the function terminates — that's the halting problem, and it's undecidable. Finding the run time of ...


3

Reasonably recent Intel and AMD processors (and most other high performance processors) include Performance Monitoring Counter (PMC) registers. You can monitor quite a variety of different things, but probably the most relevant to the question at hand would be number of instructions retired. Putting these to serious use can be a little tricky -- for ...


3

I suppose: (how-long-you-played-for) / (average-execution-time-for-80x86-instruction) would get you a ballpark figure. Actually, I just came across my old copy of Black & White at the back of a cupboard I was emptying - maybe I'll give it anther go, although I remember not thinking much of it at the time.


3

Some languages are pretty strongly static, and only allow the specification of the inheritance relationship between two classes at the time of definition of those classes. For C++, definition time is practically the same as compilation time. (It's slightly different in Java and C#, but not very much.) Other languages allow much more dynamic reconfiguration ...


2

Rather than recommending a particular approach, allow me to recommend Martin Fowler's Domain-Specific Languages as an excellent resource for making the decision. It has an extensive, thought-provoking examination of the relative merits of internal and external DSLs.


2

Look at Xtext (http://www.eclipse.org/Xtext/) and Xbase (http://blog.efftinge.de/2010/09/xbase-new-programming-language.html). If the users are non programmers I don't think you should base your DSL on an existing programming language. It will be too complicated for them. A "clean" DSL can be very efficient if made correctly.


2

Is c++ so much faster than java as to make it worth it to learn and find a way to handle large numbers? Is performance a critical concern? Do you need to perform computations with hard timing requirements? If so, then C or C++ would be the obvious choice. Otherwise, given your familiarity with Java, it might be a good idea to just use that. You might ...


2

At least your part about the programming language isn't very correct. While what you describe is one (of many) options, describing a web programming language as something "that mimics a traditional desktop application" is leaving out far too much (and the frontend part that makes the web page itself run is mostly done with JavaScript). Most programming ...


2

That depends on the nature of the security holes and that of your application. The most popular and major ones that have been fixed are related to applets. This is to say that there's some hole in the Java stack (JVM, native libraries, Java libraries, etc.) that allows an applet to access e.g. files on disk, to run a process, the kind of things that applets ...


2

Garbage collection based on reference counting is much slower than tracing garbage collectors (Boost shared_ptr vs other solutions, or you can find links to more scientific comparisons at the Boehm GC's website). In addition, reference counting alone is insatisfactory, because it cannot deal with reference cycles. C++ programmers tend to think about memory ...


1

Let's consider a strongly typed language like C#. Here you would define inheritance like this: class BaseClass { public string SomeMethod() { return "Hello"; } } class DerivedClass : BaseClass // Inherits BaseClass { public string AdditionalMethod() { return "World"; } } Usage: var d = new DerivedClass(); ...


1

A reference in a 64-bit JVM typically use 4-bytes of memory (using compressed oops) This means using a reference count will increase the size of memory per object, but also increase complexity of passing references around. Every time a thread anywhere has to obtain a reference to an object it need to increment and later decrement the counter, something a GC ...


1

If the "while it is running" is a requirement, you need to be looking at dynamic loading of class files. Application servers support this type of structure - after all, it is how you do a redeployment of an application without stopping and starting the server. You start getting things like How to dynamically reload classes when class files are changed in ...



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