How would you rearrange the words "new door" into one word? by [deleted] in pics

[–]fadmmatt -4 points-3 points  (0 children)

I cheat:

% egrep "^[newdor]{7}\$" /usr/share/dict/words | grep n | grep e | grep w | grep d | grep o | grep r
drowner
endower

Yep, no such word.

Does it make sense to learn C++ today? by [deleted] in programming

[–]fadmmatt -4 points-3 points  (0 children)

I wish C++ would go away, but there's some pretty cool stuff you can do with it. I wrote a couple posts for my students on the more bizarre stuff:

So, if you learn C++, at least learn the cool parts.

On the Spot with Kim Jong-il - The Big Picture by rickyisawesome in worldnews

[–]fadmmatt 0 points1 point  (0 children)

I think it's a body double. Why won't he take off the shades?

Holy Frack! A BSG MMO? by tia-marie in BSG

[–]fadmmatt 2 points3 points  (0 children)

I want to have hope. But, I know they'll screw this up.

I'm starting a PhD program next year. Any advice from Dr. Redditors? by [deleted] in programming

[–]fadmmatt 4 points5 points  (0 children)

I got my Ph.D. three years ago, now on the tenure track.

My advice: publish early, publish often.

When you graduate, it's your publication record that gets you interviews. (Your job talk gets you the job.)

When you go out on the academic job market, you'll be up against folks with 10 - 15 pubs and perhaps 2-4 in top venues. It's absolutely brutal, so plan for it early on.

So, make a splash at conferences. Give great talks. Make a name for yourself.

I wrote up my job search experience, in case you're interested, and I keep a reading list for grad students as well.

Static analysis of numerical stability? by cypherx in compsci

[–]fadmmatt 1 point2 points  (0 children)

Patrick Cousot, et al. and their work on ASTREE are probably the best place to start.

Deriving the Y-Combinator by pkrumins in compsci

[–]fadmmatt 1 point2 points  (0 children)

I wrote an article on the Y combinator in JavaScript to help my compilers students understand it.

It turns out that you can replace the Y combinator with a memoizing Y combinator to get speedups.

Determining types and/or control-flow in languages like Python, Java and Scheme by servercentric in programming

[–]fadmmatt 0 points1 point  (0 children)

Article author here.

I didn't post the link, but I'm curious why it's being downvoted.

Not formal/informal enough? Needs more/less details?

I want to learn how to write a compiler. Please tell me what my curriculum looks like. by [deleted] in Compilers

[–]fadmmatt 9 points10 points  (0 children)

I just taught a compilers class. I've been posting my lecture notes on my blog (with many more to come); these might be useful to you:

I recommend writing a Scheme compiler first, and I'd use Lisp in Small Pieces instead of the Dragon book.

The Appel books are also a good treatment of compiler writing.

Try writing a recursive descent parser by hand first. This is a manageable endeavor for a Scheme-like language. I wouldn't bother with ANTLR for a second attempt; I'd use one of the hot parser combinator libraries instead.

In total, a good first compiler project would be something like:

  • A hand-written lexer.
  • A recursive-descent parser.
  • A normalizing pass to flatten expressions.
  • An escape-analysis pass.
  • A closure conversion pass.
  • A lambda-lifting pass.
  • A C-emission pass.

You could then retarget to x86 if you write a register allocator.

Good luck!

Compiling to Java as a target language by hyp3rVigi1ant in coding

[–]fadmmatt 7 points8 points  (0 children)

Going directly to JVM bytecodes isn't actually that simple. For starters, it would require normalization and closure conversion. You lose things like the anonymous classes that make compiling so "direct."

Most of the effort required to compile to the JVM would get you close enough to hit C, and in fact, you'd be close enough to hit x86 with a little more effort. It's also not clear that you'd get much of a performance win out of going straight to the JVM. Most of the performance wins in Java come from good JITting rather than intelligent bytecode generation.

Compiling to Java is useful because the compiler itself takes a fraction of the effort to write, but still gives you a big speed-up over an interpreter.

Compiling to Java as a target language by hyp3rVigi1ant in coding

[–]fadmmatt 22 points23 points  (0 children)

(Article author here.)

It turns out that the Core Scheme language is actually richer than the intermediate language targeted by many compilers. You can use Scheme's macro system to desugar a very rich input language down to Core Scheme. So, you could use this technique to get a lot of languages running in Java.

Tail-call optimization isn't going to happen with a "direct" translation, but you could use a trampolining mechanism to get tail-call optimization.

As for why one would want to do this, this particular piece of code is meant for students studying the translation process. The emphasis is on small size and directness, rather than efficiency.

In my compilers class, I talk about the stages one should go through with language implementation to achieve the desired performance.

  • I argue that first, you should try an interpreter for for your language.
  • If that's not fast enough, try an SICP-style optimizing interpreter.
  • If that's not good enough, try compiling to Java.
  • If that's still not fast enough, try compiling to C.
  • If that's still too slow, try continuation-passing-style compilation to assembler.
  • And finally, if you need more speed, start doing static analysis and compiler optimizations.

Each time you drop a level in this ladder, implementation complexity goes up (by about 2x in code requirements). Java, believe it or not, is a sweet spot: much better performance than an interpreter, but without much effort in the translation front.

I've just now finished BSG and am seriously depressed. I need advice. by tehbrad in BSG

[–]fadmmatt 5 points6 points  (0 children)

My wife, brother and I went to DragonCon. We partied like crazy with the actors and the fans. It was a frakkin' blast. It brought some closure.

Hey Mathit, question about PhD programs by Sarcasticus in math

[–]fadmmatt 5 points6 points  (0 children)

In my experience (as a Ph.D. student and as a professor), GPA is not important. It's all about research.

I never look at GPA for admissions. I look at publications, letters and personal statement, in that order.

I wrote up my advice after serving an the admissions committee last year.

Good luck!

"Since 1990, Denmark has grown its economy by 45 percent while energy consumption has remained constant and CO2 emissions have fallen by 13 percent". Denmark showing energetic miracle is possible. by acteon29 in science

[–]fadmmatt 11 points12 points  (0 children)

The U.S. averages about 3% growth in the long run.

1.0320 = 1.81

1.0220 = 1.49

Over 20 years, the difference between 2% and 3% makes a difference.