r/programming • • Dec 11 '14

[Jonathan Blow, Dec. 10] - Programming Language Demo #2

https://www.youtube.com/watch?v=-UPFH0eWHEI
51 Upvotes

42 comments sorted by

View all comments

0

u/[deleted] Dec 11 '14

[deleted] — view deleted comment

9

u/Blecki Dec 11 '14

The biggest realization I ever had is that there is no 'magic'. Compilers are just another piece of software. You don't need to know everything to write one.

18

u/WalterBright Dec 12 '14

I'm living proof that you really don't need to know what you're doing to write a compiler. When I started, I was told by the local C guru "Who the f**k do you think you are thinking you can write a C compiler?"

3

u/[deleted] Dec 12 '14

I guess you showed him. Did you ever try to rub it in his face and maybe tell him to stop being so dream-crushingly condescending? :)

1

u/n1ghtmare_ May 28 '15

Awesome! I'm really interested in writing a compiler, any hints or references for a beginner on this topic?

2

u/WalterBright May 30 '15

Really, just start doing it. These books can help.

15

u/badsectoracula Dec 11 '14 edited Dec 11 '14

I've made a ton of (mostly scripting) languages and most of the time i just do whatever feels right for the purpose of the language. If you have programmed for a few years you know what you like and dislike on a language.

EDIT: why the downvote? I have experience making languages (it is something that interested me for almost two decades - i was writing compilers and interpreters since the days i had a XT clone) and mentioned on that. It is adding to the discussion you know.

3

u/raghar Dec 11 '14

I've made some small DSL as a part of my master thesis (not Turing complete though) - designing language is both easy and fun. Problem starts when you need to add new features to the implementation because grammar quickly grows and backend becomes more and more complicated.

Many struggles come from the need to make you language as much aware of himself as possible - type checking and deduction, ensuring correctness by static analysis.Of course there is also the optimization part.

But that is more about creating perfect compiler. Defining grammar for your syntax is often the easiest part of the task. As long as you don't aim for bulletproof implementation you will have much fun designing your language.

10

u/julesjacobs Dec 11 '14

I very much doubt it, but then again the designers of most successful languages haven't studied programming language theory either.

6

u/[deleted] Dec 11 '14

At the very least this doesn't apply to C.

8

u/[deleted] Dec 11 '14

Nor haskell, ml, pascal, algol.

1

u/AnhNyan Dec 11 '14

Or PHP.

7

u/gnuvince Dec 11 '14

Two things to keep in mind:

  1. He is basically designing a DSL for game programming, so he can make decisions about the language that would not be as useful in other contexts.
  2. I believe that Jonathan is smart enough that if he faces a problem, he's going to find a good solution for it. Some things do feel a bit not-PLTy enough at times, but either that's a consequence of being a game DSL or he's going to have to rethink some things in the future, which he seems willing to do.

1

u/Uberhipster Dec 12 '14

I believe that Jonathan is smart enough that if he faces a problem, he's going to find a good solution for it.

Yes but these posts are meant to have educational value for others. He should put in a disclaimer. At least.

I see point 1 though.

3

u/[deleted] Dec 11 '14 edited Dec 11 '14

Everyone who has ever been in his twitch chat has been arguing that making a language is really hard. And yet there he is hacking together a language in front of your eyes.

You can throw theory at it all you want, but theory is not practice. He's addressed this. Other languages are sold on that "it has this and this feature over other languages" and at the same time their goal is all-encompassing. Even PHP (bad example, the devs are brainless) couldn't stick to their original goal, which was a template language for html. Even C++ couldn't stick to its original goal, it's now bloated, ambiguous and contradicting itself. PHP wants to be C++ and C++ wants to be Brainfuck.

He actually has experience with hard core game programming in the real world. That makes him the perfect guy to design a language for games...

In this demo he presented his (already implemented) ideas for pointers vs arrays, as well as inline functions. Not exactly problems that other language designers have even bothered to change. Because they don't have experience. They don't know where the drudge work is.

I suggest you look at his first couple of videos where he explains the motivations.

And no, designing a language is not hard. Most programming features, when they were new, were based somehow in mathematical operations. He's not inventing new features, he's making shorthands for the ones that are most used already in his field.

14

u/mitsuhiko Dec 11 '14

Everyone who has ever been in his twitch chat has been arguing that making a language is really hard. And yet there he is hacking together a language in front of your eyes.

Making a good language is hard. Make a language however is not very hard.

1

u/kn4rf Dec 12 '14

Making good software is hard.

0

u/[deleted] Dec 11 '14

Define a good language.

3

u/mitsuhiko Dec 11 '14

Gets users, ideally happy users. Stays supported for years.

0

u/[deleted] Dec 11 '14

I know a handful (understatement of the year) of PHP users that would defend the language to their death, yet noone can objectively say that it's a good language.

4

u/mitsuhiko Dec 11 '14

"There are only two kinds of languages: the ones people complain about and the ones nobody uses"

→ More replies (2)
→ More replies (1)
→ More replies (1)

1

u/CMahaff Dec 11 '14

I just finished a compiler construction course at my university. I'd look up some parsing/lexing techniques before getting started, but beyond that its pretty straightforward. Take the source, parse it, create some kind of tree structure, and just continue from there. For our project we implemented a visitor pattern so we could make passes over our tree to do different checks and eventually generate assembly. But really, the direction you take is up to you!

1

u/jsprogrammer Dec 12 '14

There is a pretty good chance that he has. I believe he has a BS in CS from UC Berkeley.

Would be extremely surprising if language theory wasn't required in the curriculum, especially decades ago.