News for hackers. Stuff that matters.
Re:C++ at Google: Here Be Dragons by michaelcampbell on Monday May 23, 2011 @07:18PM (#2577987)
I hear you, but I think the rest of the world is actually polarizing to some degree. Perhaps I'm just fickle or a language whore, but I love both the dynamism and freedom of Ruby (et. al.) and the "protect me from doing stupid $#@!" of Scala (et. al.) Although honestly, I don't know that I'd want a language that supported both, if even such a thing were possible.

I do see a lot of people getting all hung up on one side or the other though; and it could be that the rest of the world you are seeing is just that group "over there".

Perhaps predictably, as I get older (in my 40's now), I am leaning more towards the strong type system languages, but I do enjoy my dalliances with a dynamic language, at least for small things.

Re:C++ at Google: Here Be Dragons by nradov on Monday May 23, 2011 @07:38PM (#2578039)
Why can't we have a language that supports both? I would love to have a language with a scalable type system where I could hack out a quick small prototype with dynamic typing first, and then perhaps layer on static types later where necessary to improve reliability and performance as the program evolves. For example, I would like to be able to declare a variable in all of the following different ways.

a value

a number

a rational number

a rational number between [0.0 - 1.0)

a rational number between [0.0 - 1.0), and I don't need any more than 30 bits of precision

a rational number between [0.0 - 1.0), and I don't need any more than 30 bits of precision, and please try to optimize for minimum memory usage instead of performance

Re:C++ at Google: Here Be Dragons by swannodette on Monday May 23, 2011 @07:46PM (#2578065)
You can support both. You should take look at Typed Racket, Racket w/ Contracts, Erlang Dialyzer, and Qi/Shen. Frankly the Lisp contingent is way ahead on this kind of thinking (would of course love to hear about others).

I'm interested in developing such systems for Clojure and have actively researching something considerably more powerful than Chambers/Chen predicate dispatch.

Re:C++ at Google: Here Be Dragons by Confusion on Tuesday May 24, 2011 @03:43AM (#2579031)
Qi/Shen is a fusion of Haskell and Lisp, heavily inspired by Haskell. The Lisp contingent is not 'way ahead': they are simply assimilating useful bits of their strongly typed functional cousin languages.
Re:C++ at Google: Here Be Dragons by anamax on Monday May 23, 2011 @11:46PM (#2578574)
> a rational number

> a rational number between [0.0 - 1.0)

Those are representation errors.

The hard problems that I run into rarely have much to do with representation. The hard problems are knowing when it's okay to add apples and oranges and when it isn't.

Re:C++ at Google: Here Be Dragons by michaelcampbell on Monday May 23, 2011 @09:17PM (#2578275)
I'm not experienced enough to say that you absolutely can, or cannot. I only have some experience to guide me, and I haven't seen it done yet.

That said..., I have an uneasy feeling that trying to do it would end up with a PL/1 type of situation where, depending on your background, you write it with whatever baggage you bring with you, and the language would get large to the point of different types of programmers writing in their own familiar subset of the language.

Or, I'm completely wrong. =)

Re:C++ at Google: Here Be Dragons by zoul on Tuesday May 24, 2011 @06:34AM (#2579339)
You might be interested in the type system of Perl 6:

    subset Filename of Str where { $_ ~~ :f };
Here you define the Filename type as a string that represents an existing path. This particular example is a horrendous hack of course, but the tool looks very interesting. Not sure if this can be used for performance tuning in existing P6 implementations.
Re:C++ at Google: Here Be Dragons by rjh29 on Tuesday May 24, 2011 @07:01AM (#2579389)
That's a horrible hack indeed :)

Perl 6 does have 'gradual typing' though. You can define a variant:

  my $foo;
or a typed variable:

  my Int $foo;
or a subtype with arbitrary restrictions

  subset OneToTen of Int where { 1 <= $^n <= 10 };
  my OneToTen $foo;
Or... (http://rosettacode.org/wiki/Define_a_primitive_data_type#Per...)

  subset Prime of Int where { $^n > 1 and $^n %% none 2 .. sqrt $^n };
Perl 6 scares me.
Re:C++ at Google: Here Be Dragons by edabobojr on Tuesday May 24, 2011 @11:25AM (#2580175)
It's been a long time, but I believe Ada provides the ability for the first 4 and I would bet you could define the last two in it.