Over the past year I've been thinking about how to make my own language. It's a pretty big undertaking and I've been too busy with other projects to put any serious effort into it, so I just think about it when I go for a walk. Mostly I try to convince myself to not make a language but it sounds like a lot of fun. With the explosion of JavaScript, and so few people wanting to write JavaScript, it seems like other people think writing a language sounds like fun too. We have CoffeeScript, IcedCoffeeScript, Roy, JSX, Amber, Dart, and many others. And that's just a list of recent languages that compile to JavaScript. Many more languages have come out, relatively recently, such as Go, Fancy, Elixir and Loop. Most of these languages will be minor dents in the history of programming languages, but that is OK. Not everything has to be important to be worth doing. But they have gotten me thinking. Should I create a language? What would it have to offer? Is the effort worth it? Below are thoughts that have steered my decision process for when I get some time to start hacking on a language. The thoughts are targeted at me, someone who has little experience building a language, not a professional.
Showing posts with label programming. Show all posts
Showing posts with label programming. Show all posts
Wednesday, June 6, 2012
Saturday, October 29, 2011
What is Covariance and Contravariance Anyways?
If you have been following the talk around Google's latest language, Dart, then you might have heard things like "covariant arrays are widely regarded as a mistake" (src). But what is covariance? Why are covariant arrays considered a mistake? Who has covariant arrays? Why?
Labels:
c,
c++,
contravariance,
covariance,
dart,
java,
programming,
python,
type systems,
type theory
Sunday, July 31, 2011
C Gotcha Of The Day: Pointers aren't integers
The C standard is clear that pointers are not required to be convertible to or from an integer.
Friday, July 29, 2011
C Gotcha Of The Day: ptrdiff_t
Excerpt from C99 Draft (AFAIK this has not changed):
That means, while the type
The size of the result is implementation-defined, and its type (a signed integer type) isptrdiff_t
defined in the<stddef.h>
header. If the result is not representable in an object of that type, the behavior is undefined. In other words, if the expressionsP
andQ
point to, respectively, the i-th and j-th elements of an array object, the expression(P) - (Q)
has the value i−j provided the value fits in an object of typeptrdiff_t
.
That means, while the type
size_t
is capable of expressing the size of any object, you cannot guarantee that the subtraction of two pointers inside your object will result in defined behavior. That is because ptrdiff_t
is signed (so it can give you the direction of the difference) and size_t
is unsigned. You can use the macros PTRDIFF_MAX
and SIZE_MAX
to determine if your subtraction is safe though.
Subscribe to:
Posts (Atom)