Language Syntax

Started by
50 comments, last by Zahlman 15 years, 6 months ago
Quote:Original post by SamLowry
in does not really have a meaning, it's just a syntactic part of the expression: let <id>=<expr> in <expr>, which introduces a local (readonly) variable. The indentation and newlines have no significance in O'Caml.


Meaning enough for me. Thanks

@xZekex: it would be kind of cool to have a statically typed language with Pythonish syntax. Come to think of it, I'm sure there is one. I don't like the indentation thing when I'm doing something at the interactive prompt. I don't like having to worry about formatting when I'm just hacking something out. Maybe Python is just the wrong language for that.
Advertisement
Even though I think C# is the greatest thing since sliced bread, I find Python's syntax to be refreshing and clear. It's almost like the quintessential programming language.

Also, for a little slice of awesome, take a look at this complete raytracer written not in C# 3.0, but LINQ query statements inside of C# 3.0. It reminds me of some of the more functional languages. Not a bracket in sight.
Mike Popoloski | Journal | SlimDX
Quote:Original post by xZekex
I find python the clean language. I wish other languages would take after it.

*** Source Snippet Removed ***

Though I I don't really like weak typed language like Python all the much. I prefer the C/C++ declaration of variables. Python makes it to where you have to indent. Which I love. No more sloppy indention by people because they are too lazy to indent their code.


Agreed. I <3 python. And the django framework.

I do have to correct one inaccuracy though: Python is a strongly typed, dynamic language. Variables are dynamically typed, not weakly typed. You don't have to declare a variable's type before the program is run, but once you assign a value to a variable, it can only be used to store that type of value. C++ is both strongly typed and statically typed. You must tell the compiler what type you intend to store in it.
Quote:Original post by smrI do have to correct one inaccuracy though: Python is a strongly typed, dynamic language. Variables are dynamically typed, not weakly typed. You don't have to declare a variable's type before the program is run, but once you assign a value to a variable, it can only be used to store that type of value. C++ is both strongly typed and statically typed. You must tell the compiler what type you intend to store in it.


Um, no actually.
>>> l = [12, 4, 3]>>> print l[12, 4, 3]>>> l = 'fooie'>>> 


Runs just fine. Or did you mean something else?
Python is strongly and dynamically typed. Strong typing does not prevent changing the type of a variable later. It does prevent changing the type of a value; i.e., there are no implicit conversions. Python values have types (and they are rigid); Python variables don't.
Quote:Original post by Zahlman
Python is strongly and dynamically typed. Strong typing does not prevent changing the type of a variable later. It does prevent changing the type of a value; i.e., there are no implicit conversions. Python values have types (and they are rigid); Python variables don't.


Yes... That's what I meant!
I figured it was just a misunderstanding. I hope we haven't totally side-tracked this thread. It was just starting to get interesting. I would like to see some samples of Telastyn's language.
Quote:Original post by Ryan_001
Quote:Original post by ToohrVyk. While statements are a reasonable legacy of the good old days, having everything be an expression is a huge boost in expressiveness. Even more so when you have access to anonymous lambdas.


Any particular examples you have in mind?
In Ruby, output every line in a file to screen:

File.readlines(filepath).each { |line| puts line }
I like the syntaxes of your typical functional language. So stuff like ML and Haskell. Different strokes. A matter of opinion and preferences. Which you can respect and also respectfully disagree.

Not to cause any trouble or anything but the best description of Python's type system is loose - dynamic works but hides the nature. There are types kinda there but not really/only loosely in the type theoretic sense (for example at first glance it appears to be simply typed but it clearly is not, having far more power than a language with only such. Types from type theory do not really map to its notions of 'types'). I mean the whole monkey patching duck typing farm animal thing it has going flies in the face of type theory.

Python is not strongly typed - if (c = 7) comes up as a syntax error not a type mismatch, you can add floats and ints without conversion, the following:
def myfun(x):    if (x == 7): print "NN"     else: x
runs. in a language with strong typing it would be invalid since the type of the first branch does not match the second, etc. And to be honest strong typing done properly is an annoyance. Python semantics are closer to an untyped language than a typed one. And that is its strength really, why it is able to leverage its metaprogramming like facilities.

C++ is definitely not strongly typed - no need to look further than the existence of raw pointers. In some languages you can have implicit typing and still be static, such as haskell. You dont tell the compiler any types it infers the most general one.

[Edited by - Daerax on October 9, 2008 10:05:03 PM]
Quote:Original post by theOcelot
I figured it was just a misunderstanding. I hope we haven't totally side-tracked this thread. It was just starting to get interesting. I would like to see some samples of Telastyn's language.


Check out his journal. He has been posting about it since forever and you can download an old version.

This topic is closed to new replies.

Advertisement