PDA

View Full Version : Pretty Syntax!


indecisive
October 9th, 2008, 03:49 PM
What language has the prettiest syntax?

To avoid dispute, after all suggestions for languages with pretty syntax have been posted, a poll will be implemented.

nvteighen
October 9th, 2008, 04:00 PM
No doubt: Lisp (in all its modern dialects)


(procedure args ...)


There you have. That's all you need and there is a whole universe inside of it, as you can nest S-expressions however you like in order to get it reduced to what you need.

The most beatiful for simplicity and power.

LaRoza
October 9th, 2008, 04:01 PM
It depends on what is being used to judge.

Lisp is the simplist and most elegant.

Python is very readable.

C syntax is in many popular languages, therefore, it is very familiar to many people.

nvteighen
October 9th, 2008, 04:10 PM
C syntax is in many popular languages, therefore, it is very familiar to many people.

Well, C syntax has a plus. It's pretty regular and everything has a reason to be there... yeah, even the annoying semicolon, which is kept for historical reasons. It's also very intuitive, IMO, if you know what you are doing: curly-braces to "embrace" some region of code and therefore have a block, parentheses enumerate what determines the function call, etc. Even the = vs. == distinction is coherent with the fundamental C principle of "one piece, one task".

arloth
October 9th, 2008, 04:14 PM
Code is far easier to write than it is to read. Different people often come up with very different solutions to coding issues that aren't always apparent to the person reading them.

I'm rather partial to C myself, but then I'm usually staring at it all day long anyways.

tcl/tk isn't bad either. It's variable and command substitution make things fairly easy to read. Then again, a very biased opinion here as well. ;)

rogier.de.groot
October 9th, 2008, 04:25 PM
Kind of depend on what kind of problem domain you're working with, I guess. Like C# 3.0 syntax myself, and Java too, but especially with Java the things they added to the language later seem weird sometimes.

Reiger
October 9th, 2008, 04:33 PM
I like the Lisp & Haskell syntaxes: elegant, simple, and easy to work with. Lisp has it's one-size fits all, which is nice but I think I do prefer the slightly more rich syntax of Haskell with it's pattern matching, litterate/non-litterate styles (not that I currently ever used the litterate style), less-cumbersome lambda (I simply don't like to see lambda written out in full) ... Though one should note that Haskell books may have the (bad/good?) habit of subsituting some well known symbols with their equivalents from Math.

Apart from that I find the Java one to work nicely as well. Python seems promising too.

@nvteigen: I found you a language apart from Lisp where code<==>data: XML.

pmasiar
October 9th, 2008, 04:33 PM
I have 2 candidates: HQ9+ and Forth -- languages with no syntax at all:

HQ9+: http://www.cliff.biffle.org/esoterica/hq9plus.html

Forth: http://en.wikipedia.org/wiki/Forth_(programming_language)

I'll let someone else to suggest Python 8-)

Get more languages at http://99-bottles-of-beer.net/

pmasiar
October 9th, 2008, 04:38 PM
Code is far easier to write than it is to read.

Yes, but it is irrelevant: code is read more often than written, and reading code of others is way to communicate about programs. So Language optimized for readability (like Python) IMHO wins when compared with language optimized to be "easy to write", like Perl (often considered a "write-only" language, because is hard to read even your own old code, and reading code of others is almost impossible ;-) )

jimi_hendrix
October 9th, 2008, 05:15 PM
Kind of depend on what kind of problem domain you're working with, I guess. Like C# 3.0 syntax myself, and Java too, but especially with Java the things they added to the language later seem weird sometimes.

i find java and C# code very easy to read and analyze

Code is far easier to write than it is to read. Different people often come up with very different solutions to coding issues that aren't always apparent to the person reading them.


i hate trying to read others code if its not commented extreamly well

I have 2 candidates: HQ9+ and Forth -- languages with no syntax at all:


HQ9+ is a great language for doing what its designed for...

another language with a beatiful syntax is Ook...

pp.
October 9th, 2008, 05:29 PM
Pretty syntax is so 20th century.

The large volume of discussion about whether whitespace is better to indicate depth of nesting than visible delimiters, and if so what kind of whitespace, and if not whether only one kind of visible delimiter, or variable delimiters depending on the verb contained within the nested structure, and whether positional parameters were preferable over named ones and whatever ...

Shoot the round enders. Only pointed end good.

Really, we should have attained a level of technology where it ought to be possible to separate the visible attributes of a serialised stream of nested entities from its content and structure.

I do not see any merit in preparing a complex program using a program which scarcely exceeds the power of a text editor, if it does at all.

Or has anyone seen a serialised stream describing a plane as screw-SheetMetal-washer-nut- and so on for several GB, with the expectation that engineers work on that serialised stream?

rogier.de.groot
October 9th, 2008, 06:03 PM
i find java and C# code very easy to read and analyze

i hate trying to read others code if its not commented extreamly well


Like Dijkstra said, you can write fortran in any language...
Personally I hate commenting my code, I don't like reading comments much either.
Good variable/method naming and breaking things down into small, focused chunks works better for me.

jimi_hendrix
October 9th, 2008, 06:05 PM
Like Dijkstra said, you can write fortran in any language...
Personally I hate commenting my code, I don't like reading comments much either.
Good variable/method naming and breaking things down into small, focused chunks works better for me.

i like one comment for the purpose of a function or a class and good variable names

i will comment more only if im using a language that not many know well and its is in the programming challenges thread

SeanHodges
October 9th, 2008, 06:23 PM
Well all the sensible ones have been taken up, but to be honest the first one that I thought of was F**kF**k (variant of Brainf**k):

http://web.archive.org/web/20050318095341/http://www.chilliwilli.co.uk/ff/

I don't think I'll type an example up here, but those with a sense of humour can click here :)

http://web.archive.org/web/20050311055651/www.chilliwilli.co.uk/ff/hello.ff

I've yet to find a purpose for it in a commercial project...

drubin
October 9th, 2008, 06:47 PM
Java has the most standardized set of code I have ever looked at. All the standard libs/methods are set out in a very very logical manner and grouped together.

Not saying java is the best lang but by bar the most structured lang I have workd

Fixman
October 9th, 2008, 06:50 PM
Haskell for the win.

LaRoza
October 9th, 2008, 06:51 PM
Java has the most standardized set of code I have ever looked at. All the standard libs/methods are set out in a very very logical manner and grouped together.

Not saying java is the best lang but by bar the most structured lang I have workd

Well, I think Python does it better.

Java's "organisation" requires an IDE to use.

Fixman
October 9th, 2008, 07:02 PM
Brainfuck (http://en.wikipedia.org/wiki/Brainfuck)

Or maybe LOLCODE (http://lolcode.com/).

LaRoza
October 9th, 2008, 07:06 PM
Brainfuck (http://en.wikipedia.org/wiki/Brainfuck)

Or maybe LOLCODE (http://lolcode.com/).

****-lisp (http://flukkost.nu/blog/2007/02/22/****-lisp/)

Emill
October 9th, 2008, 07:06 PM
I think Ruby has the prettiest syntax :)

jimi_hendrix
October 9th, 2008, 07:06 PM
I CAN HAS PRETTY SYNTAX PLS?
i think that language has potential :D it is definitly more detailed then most other joke languages

days_of_ruin
October 9th, 2008, 07:37 PM
If by pretty you mean readable then python wins IMO.
if by pretty you $mean @butt ugly then perl %wins.

Lux Perpetua
October 9th, 2008, 11:19 PM
Forth: http://en.wikipedia.org/wiki/Forth_(programming_language)
I love postfix syntax. Some of my best work is written in PostScript. However, stack-based languages easily lead to write-only code. In particular, this becomes a danger if you actually try to use the stack to keep track of things in the long term. The problem is obvious: you have to keep track of the stack in your head to make sense of your program, and the stack can store arbitrarily complicated data without the code needing to define it. Nevertheless, good postfix-style code can be really beautiful. Also, there are ways to avoid this pitfall, such as defining variables and not putting everything on the stack (which may relinquish some elegance) or just using good comments.

Lisp is a special case, since it literally has no syntax: the syntax you write in your editor isn't the lisp code itself, but only a particular representation of it. In theory, you could represent the same underlying objects in completely different ways. I actually don't find the parenthesis-based syntax to be all that pretty, although maybe the true underlying code is better. :-)

sidran
October 9th, 2008, 11:53 PM
I think C has a very pretty syntax. Better than C++, Java, and C#. Mainly because it's simple. Before it got bastardized with pseudo-object oriented hacks. Before templating. It's very straightforward, simplistic, and logical.

Though I don't know if this would apply as it's not a typical programming platform, but G2 is crazy. The syntax is basically spoken English. Most of it is very graphically driven, but you do have to type up source code when defining rules. For example: http://www.gensym.com/documents/g2%208.2%20datasheet.pdf
Check out page 2, and you'll see some source code in the picture on the top left of the page.

doas777
October 9th, 2008, 11:57 PM
whitespace (http://99-bottles-of-beer.net/language-whitespace-154.html)

doas777
October 10th, 2008, 12:00 AM
I think C has a very pretty syntax. Better than C++, Java, and C#. Mainly because it's simple. Before it got bastardized with pseudo-object oriented hacks. Before templating. It's very straightforward, simplistic, and logical.

Though I don't know if this would apply as it's not a typical programming platform, but G2 is crazy. The syntax is basically spoken English. Most of it is very graphically driven, but you do have to type up source code when defining rules. For example: http://www.gensym.com/documents/g2%208.2%20datasheet.pdf
Check out page 2, and you'll see some source code in the picture on the top left of the page.

C isn't bad. I do typically find C a little harder to read than others, but i think thats largely a PEBCAK issue. the original RKR text is also probably to blame. I don't particularly like the style they choose.

just my two bits.

sidran
October 10th, 2008, 12:34 AM
C isn't bad. I do typically find C a little harder to read than others, but i think thats largely a PEBCAK issue. the original RKR text is also probably to blame. I don't particularly like the style they choose.

just my two bits.

And you think reading whitespace source is any easier? :P

Lux Perpetua
October 10th, 2008, 02:26 AM
I think C syntax is all right if you avoid macros like the plague.

NovaAesa
October 10th, 2008, 03:43 AM
Lisp has really nice syntax. That would have to be the winner for me, but appart from that I really like the syntax of C/C++/Java (they are very similar syntax wise) even if it is complex. I guess it appeals to my logical side.

SupaSonic
October 10th, 2008, 08:18 AM
Java, especially with the introduction of wrapper classes and the enhanced for loop.

Canis familiaris
October 10th, 2008, 09:26 AM
The language you are most well versed with...

kavon89
October 10th, 2008, 10:03 AM
Lisp looks very interesting and "pretty", if you become familiar with it I would say, from what I've heard, that one would be the best & prettiest syntax wise.

But I'd say Python and Java are the most readable for a newcomer. Java is quite verbose, which is a pro and a con. It's methods can be pretty long and the code often reads like a complete sentence.

Java Ex:

if(item.isSelected()) {
//do somthing
}

nvteighen
October 10th, 2008, 01:25 PM
@nvteigen: I found you a language apart from Lisp where code<==>data: XML.

Nice find. Yeah, it's true, but as far as I know, XML hasn't taken full advantage of that yet (e.g. Lisp's macro system... which IMO resembles a lot to Chomskyan Transformational Grammar (http://en.wikipedia.org/wiki/Transformational_grammar)).

cmay
October 10th, 2008, 01:34 PM
http://en.wikipedia.org/wiki/Chef_programming_language
nice syntaxt. very readable.

estyles
October 10th, 2008, 02:21 PM
I can't believe no one has mentioned ASM. Assembly language is the prettiest because most of the lines are the same or similar length:

How can you say that the below (greatest common divisor function), isn't pretty?

gcd: mov ebx,eax
mov eax,edx
test ebx,ebx
jne L1
test edx,edx
jne L1
mov eax,1
ret
L1: test eax,eax
jne L2
mov eax,ebx
ret
L2: test ebx,ebx
je L5
L3; cmp ebx,eax
je L5
jae L4
sub eax,ebx
jmp L3
L4: sub ebx,eax
jmp L3
L5: ret

And I do believe the question was prettiest, not most readable. Although that definitely brings in consideration for C, considering some of the obfuscated C contest winners.

saulgoode
October 10th, 2008, 09:42 PM
ColorForth (http://www.colorforth.com/cf.html) is quite pretty.

RiceMonster
October 11th, 2008, 01:02 AM
I really like C syntax. It's just familiar to me and seems very logical.

i hate trying to read others code if its not commented extreamly well

Avoid my code then :p. I usually use comments as markers to make it easier to scroll through my own code or write stupid stuff like "Holy crap this is messy!" or "Do I really need this junk?". I only write that stuff when iI don't plan on anyone else reading it though. In the case that someone is, I'll do much better commenting.


This got me thinking though, the most annoying syntax I've seen is COBOL. Thank god it's not really used anymore because it's so out of date.
MULTIPLY VAR-X BY VAR-Y GIVING VAR-XY.

Eck! In an attempt to make it really easy back in the day, it's just really annoying and feels really backwards.