Tag Info

Hot answers tagged

12

Wouldn't it make more sense to spend the effort working in something that will give better results? Like what? The nice thing about compilers is that they don't have many dependencies. This makes them good candidates for a new language that likely doesn't have a very large or diverse standard library yet. Better yet, they require a variety of things, ...


11

The goal of having a compiler in the language that is being compiled is often part of the practice of "eating your own dog food." It demonstrates to the world that you consider the language, compiler, and ecosystem of supporting modules and tools to be "good enough for serious work" or "production ready." It also has the virtuous effect of forcing those ...


9

Methods in most (class-based) OOP languages are fixed by type. JavaScript is prototype-based, not class based and so you can override methods on a per-instances base because there is no hard distinction between "class" and object; in reality, a "class" in JavaScript is an object which is like a template for how the instances should work. Any language ...


8

People create new general purpose languages for one main reason: they hate at least one thing about every other language out there. This is why so many languages don't get off the ground. You have a great idea for a language that would improve your programming life, but you have to make the first implementation in a language that annoys you in at least ...


8

It usually means that any code marked as deprecated is considered old and out of date, or it may have potentially serious issues with performance/conformity to standards/platform-specific issues/security/compatibility/etc..., and that there is probably a better replacement. It is marked as deprecated to indicate that developers writing new code should avoid ...


8

Yes, pretty much everything in the Haskell/ML family does this. Here's a snippet of some relevant Haskell foo = 1 + bar bar = "Not a number :O" main = putStrLn foo No types need to be explicitly annotated, but the error is still caught at compile time. In general we always infer some types in every language. Nothing would require something like int ...


8

Many of the Gang of Four Design Patterns are really just workarounds in Object Oriented languages for mechanisms that are already available in Functional languages. Consequently, the best languages for design patterns (from a productivity standpoint) are the ones that don't require them. If you don't need the pattern, then you don't have to spend any time ...


8

Reference counting is basically never sufficient for managing memory due to cycles. If a language has mutation we can essentially create a structure like ------------------- | | | | Head | Tail | | | | ------------------- | | | | +-------+ | 1 <+ I put way too much effort into this ...


6

Language stability is not a technical decision. It is a contract between the language author and the users. The author advertise a given version as more or less stable. The less stable a language is, the more changes the author can make. Each user interested by the language can decide if he wants to invest time in it to learn new features or develop ...


6

You asked for any language that provide per-instance methods. There is already an answer for Javascript, so let's see how it is done in Common Lisp, where you can use EQL-specializers: ;; define a class (defclass some-class () ()) ;; declare a generic method (defgeneric some-method (x)) ;; specialize the method for SOME-CLASS (defmethod some-method ((x ...


6

Type inference does exactly this. You do not generally have to declare types, as they can be inferred from usage. However, more complex type systems will still occasionally require explicit type annotations. Your example can be written in Standard ML as fun some_func {bar} = print (Int.toString bar); val foo = {bar = 123}; some_func foo; This uses ...


5

Be aware that languages change throughout their life, regardless of how well it might be designed up front. Instead of trying to immediately ship the most awesome language on earth, first try to be useful and extensible. A mediocre langauge which I can actually use is worth more than any wonderful programming language that only exists in theory. Consider ...


4

The term "open source programming language" doesn't make much sense. The specification of a language can be released under an open source license (for example, the specification of Go uses CC-BY), but many languages listed on that Wikipedia article that are widely used in open source projects don't use an open source license for their specification (e.g. ...


4

It's hard to guess the motivation for your question, and so some possible answers might or might not address your real interest. Even in some non-prototype languages it is possible to approximate this effect. In Java, for example, an anonymous inner class is pretty close to what you're describing - you can create and instantiate a subclass of the original, ...


4

You can think of per-instance methods as allowing you to assemble your own class at runtime. This can eliminate a lot of glue code, that code which has no other purpose than to put two classes together to talk to each other. Mixins are a somewhat more structured solution to the same sorts of problems. You're suffering a little from the blub paradox, ...


4

You can also do this in Ruby using singleton objects: class A def do_something puts "Hello!" end end obj = A.new obj.do_something def obj.do_something puts "Hello world!" end obj.do_something Produces: Hello! Hello world! As for uses, this is actually how Ruby does class and module methods. For example: def SomeClass def self.hello ...


4

.NET already does this; it's called Linq. Linq is basically SQL for object collections. In C#, it looks like this: var q = customers. where(c => c.City == "Montreal"). select(c => c.CompanyName); and in Smalltalk, it looks like this: q := customers where: [ :c | c city = 'Montreal' ] select: [ :c | c companyName ]. or this: ...


3

Well, take on an application that requires two or three hundred UI forms and you might decide that hand-coding them all is a nightmare and wish for a graphical UI designer. Like everything in this game it's a case of the right tools for the right job.


2

The number of patterns used in a code is not a quality metric, often quite to the contrary. Patterns are used to describe best practices to solve common problems, they are a means to reach a goal, not a goal in itself. So what you are asking is which language has most of the common problems to be solved by design patterns. Pick the language best suited to ...


2

You can write an interpreter in a compiled language that executes a self-modifying, domain-specific language whose instructions are held in a mutable data structure of some sort. So yes, it's possible. If your question is "can I do it with the original target language using the original compiler," that, too, is possible, if you write a program that writes ...


2

If you want to have a compiler for language X be self-hosting, your first have to implement it in some other language, say Y, such that it takes input for language X and spits out assembly code, or some intermediate code, or even object code for the machine the compiler is running on. You want to choose language Y to be as similar to language X as possible, ...


1

Who says that? ...anyway, it's just an opinion. Some might agree, some may not, there is no right or wrong here. Some languages have compilers written in itself, others don't. Whatever. Nevertheless, I think it's a nice exercice/proof-of-concept if a language is able to "self-compile" ...it's just ...nice ...and it prooves the language is suited to do some ...


1

The answers so far have mentioned extreme functional languages. If you're looking for something a bit closer to the mainstream, have a look at Boo. Its syntax is heavily inspired by Python, but it's statically typed. Type declarations are required for defining class members, but for variables, method arguments and return types everything can be optionally ...


1

Yes, but… It has been long known that machine code for Von Neumann architecture machines is too "brittle" to reasonably mimic some life-based dataprocessing. As a simple example, if you alter a single bit in a machine instruction, you won't necessarily get something useful, you may very well crash the processor or program. Contrariwise, biological systems ...


1

In the old days, languages (often forms of Assembly) used to be designed with instructions specifically set aside for self-mutating code. This means you could easily tell the program to change itself while it's running, which was used for performance improvements. The key word here is "easily", because although this went out of style decades ago, as a ...


1

Rather than trying to modify the firmware of devices, and alternative is to harness what is already in place. As you say, a small single-board computer is a good solution. Try a Google search on Arduino. These boards are cheap, and are designed to control lots of IO lines. Programming in C or C++ is the norm and you are working with bare metal - there is no ...


1

This is a quick article about the relationship between APIs and hardware. Generally, if you are accessing hardware directly, you would generally use a C or C++ driver. You might raise the question: how do all the other languages access the hardware? They utilize the C or C++ compiled driver. EDIT: One of the commenters provided a list of high-level ...


1

I think a pretty important step is to promote a package manager whicih can also manage the version of the language itself. For instance, I use SBT for Scala or Leiningen for Clojure. Both of them let me declare which version of the language I want to use, per project. So it is quite easy to start green projects in the latest version of the language, while ...


1

Naive reference counting cannot deal with cyclic data structures, since parts of the data structure will cause other parts to have a reference count higher than zero. On the trivial end, Lisp (in general and Common Lisp in particular) allows you to create read-time cyclic "lists": #1#=(red green blue . #1#) is a never-ending list. They're even useful, in ...


1

Other answers have shown how this is a common feature of dynamic object-oriented languages, and how it can be emulated trivially in a static language that has first-class function objects (e.g. delegates in c#, objects that override operator () in c++). In static languages that lack such a function it is harder, but can still be achieved by using a ...



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