How far is a language tied to its syntax?

Started by
18 comments, last by ApochPiQ 16 years, 8 months ago
For me VB is very hard to read.

C++ is just like any other language it just takes time.

theTroll
Advertisement
Quote:Original post by apatriarca
@ Ravuya:
But in Haskell you can write the same program in a simpler way:
addProgressively :: Int -> Int
addProgressively j = j + sum [0..9]
In this way you can also understand better what the function is doing.
And I have written this function in a very short time.
Ah, yes, I keep forgetting about ranges! Mea culpa.

I wrote mine pretty quickly, too, which goes to show the conciseness of the syntax makes the code faster to write. It's no more incomprehensible than C++, either.

Like Apoch says, this is the perfect example. You write fewer lines of code in Haskell, but the consequence is that each line of code in Haskell matters more (signal:noise). In HyperTalk, there's at least 10-15 tokens there I could get rid of that don't significantly contribute to readability (and in the case of the range, actually hinder it).
Thanks for the replies.

I was using that critism of C++ just as an introduction to the topic. I have programmed in both C-style and BASIC-style languages, and it just got me wondering why we always assosiate a particular style of syntax to a language, when in fact they can do the same thing.

For the record, step in BASIC languages is the amount the variable increases. So for int a = 0 to b step 5 would be equivilant to for (int a = 0; a <=b ; a += 5)

I guess it is a matter of preference. Not to be antagonistic, but it seems most people on this forum program in C-style languages and so would be used to the syntax and find the BASIC syntax unhelpful. If a BASIC-style langauge was developed as powerful as C++, perhaps the consensus would be reversed? Maybe the language you first program in, or program the most in, sways you to which style you like the most?

But those are good points that programming shouldn't be too dependant upon human language and it allows beverity. But at the same time, departing too far from human language leads to obsfucation.

Being as I program in both BASIC-style and C-style languages today, it was just something I was thinking about. Thanks for your ideas!
I didn't know you could add multiple intializers / operations in a for loop thanks victor :-)
Quote:
for (a = 0, b = 10; a <= b; a++, b--)

Also you could you do multiple checks in the condition? IE a<= b, B==C? or would it be a <= b || b==C ? Or is it not supported... (talking in terms of c++)
-durfy
As far as I know, you can put <= b || b==C or any expression you want into the check.
Quote:Original post by Ravuya
For the sake of argument, let's take a look at Haskell and HyperTalk, two extremes on the 'natural language' scale. We're going to write three functions, one in C++, one in Haskell, and one in HyperTalk.
...

Human language is imprecise and flawed and should not be used as a basis for mathematical or logical expression.


Two things. I would not go so far as flawed, ambiguous, imprecise or incomplete yeah. But it does its job as well as may be expected for something from humans.

Also the Haskell code can be made a bit more concise and clearer I feel:
addProgressively j = foldr (+) j [0..9] 
Quote:Original post by Durfy
Also you could you do multiple checks in the condition? IE a<= b, B==C? or would it be a <= b || b==C ?


Yes, you can have a <= b, b == c. However, no one would ever have that, unless of course there is a very clever <= operator with side effects called for a <= b part. Otherwise, the result of this check is simply discarded, so why do you check in the first place?
Oh yeah, Czar Kirk you might want to check out Visual Basic .NET. It more or less fills your criteria.
Quote:Original post by Daerax
Oh yeah, Czar Kirk you might want to check out Visual Basic .NET. It more or less fills your criteria.


Thanks for the suggestion, but I wasn't looking for a new language (I've used VB before anyway), I was just thinking about the general idea of the two styles, and why one is more popular than the other ;)
C-style syntax is popular because C (and its bastard offspring C++) are both popular. It's purely a numbers game. Even the somewhat-objective argument that C is more concise than BASIC is easily countered by Python, which is "more" concise in the sense that there are no block-delimiter tokens at all.

C++ is popular because it inherited the market popularity of C. C was popular because it was portable, back in the days when every single model of computer in the world had a totally different architecture. Java wanted to appeal to the C/C++ crowd and lure away some of the market share, and thus adopted that style, perpetuating the aesthetic to a massive new market of unskilled college kids and business developers. The .Net platform is kind of Microsoft's way of flipping the middle finger to Java, and C# is square in the middle of that whole political quagmire.


So, hopefully that answers your question as to why one style is more popular [smile]

Wielder of the Sacred Wands
[Work - ArenaNet] [Epoch Language] [Scribblings]

This topic is closed to new replies.

Advertisement