5 ms·
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
by michaelcampbell 15y ago
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.
- nradov 15y agoWhy 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
- swannodette 15y agoYou 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.
- Confusion 15y agoQi/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.
- michaelcampbell 15y agoI'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. =)
- anamax 15y ago> 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.
- zoul 15y agoYou 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.
- rjh29 15y agoThat'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#Perl_6 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.
- edabobojr 15y agoIt'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.