

I told my 2nd year CS students to create a programming language [RESULTS] - dovyski
http://www.dovyski.com/2012/05/i-told-my-2nd-year-cs-students-to-create-a-programming-language-results/

======
Udo
This is a very cool experiment, this should be standard practice in teaching
CS. I'm a little surprised at the limitations of their interpreters, given the
fact that they are 2nd year already - but then again, they were given the task
do develop a language for a very specific test case.

The absence of support for nested loop/if constructs probably means they
didn't write parsers that generate trees, but rather chose to execute scripts
line-by-line, right?

I'd like to ask you fellow hackers: if you created a toy programming language
today, what features would it have?

~~~
dovyski
Thanks! I was a little surprised too, but I think they focused too much on the
test case, not the language itself.

About your (first) question, yes, they all execute scripts line-by-line.

------
laserDinosaur
Ok, I'll be the slow witted one in the room - When creating your own language,
what did you write it in? If you're using Java or C, are you still using it's
compiler but coming up with your own syntax? I'm a little confused how it
worked.

~~~
dazzawazza
Good question. You can write a language in any other language. Say you create
a language called LASERD and chose to write it in C:

You write a program in C that is able to transform LASERD source files in to a
form that it can interpret and then execute.

One way to do this is to create a simple virtual machine as part of your C
program that is sort of like a virtual CPU (with registers, pretend memory and
simple opcodes like ADD, SUBtract, MOVe etc.

The C program takes the LASERD source file interprets the syntax and generates
code that can 'run' on the virtual CPU.

This is basically how Lua, Python, Ruby, Java etc work.

Does that make sense?

~~~
dovyski
It makes sense to me. Even though this is the "right" way of creating an
"interpreted" language, the assignment I asked my students was way more
simple: they had to interpret the source code and react to it immediately.
There was no intermediate instructions (such as Java byte-code).

------
jhrobert
There exists tons of "toy" language implementation available online. I wonder
why no students came up with a forth or lisp like solution that would have
been able to handle nested loops, ifs, etc...

When I was in my 2nd year as a CS student, one of the assignment was to
reimplement the Unix's M4 preprocessor (a superset of C's preprocessor), based
on its manual... It includes an expression evaluator, we were told that tools
like lex and yacc would help...

Well... that was 25 years ago.

~~~
dovyski
I guess I forgot to mention, but one pair of students came up with a Forth
like solution. Their interpreter was even able to parse the source code
backwards.

------
kodablah
"I think it happened because they wrote just C code until now (they will meet
PHP next semester)."

This surprises me. Of the higher-level languages you (or your school) could
choose, why PHP? I understand for beginners, but why for students coming from
a C background?

~~~
dovyski
When I arrived, PHP was already chosen. I think PHP was chosen because it is
very similar to C and it lowers the learning curve for the students.

I know PHP sucks sometimes, but it's still a cool language to play with.

~~~
Udo
PHP hate is often a knee-jerk reaction here on HN. It's a language that has
both some very cool features and some legacy baggage it carries around - and
it's absolutely possible to use it for good (and to use it well). I think
PHP's image problem comes from the perception that there is some very low-
quality code out there, but it's definitely mainly an in-group coolness issue.

It's one of those things that (negatively) surprised me about Hacker News,
actually. People go around and unproductively bash each other's programming
languages when they could use their energy to elaborate on the stuff they
actually like. The group consensus seems to be that Lisp is the best thing a
language can hope to be; and since very few people actually develop in Lisp-
likes, they fall over each other to claim the next-best place in the All-Time
Universal Programming Language Hierarchy(tm).

I believe the origin of this behavior might be a somewhat mistaken PG essay[1]
implying that all non-Lisp languages are "Blub", which is a synonym for
"sucky, powerless, inferior language".

[1] <http://www.paulgraham.com/avg.html>

~~~
dovyski
I totally agree with you! I think every language has its own
benefits/problems, the programmer is the one that makes the difference.

I'm sure I can find crappy Ruby/Lisp/whatever code and excellent PHP code out
there. If you are a bad programmer, you write bad code. Of couse there are
languages that try to prevent that forcing you to follow certain patterns, but
it will not stop bad programmers.

