4 ms·
I saw that part of the video too, and although Larry looked like he was having a fun moment, I think he was also quite insightful. IDEs help people write progr
by etse 8y ago
I saw that part of the video too, and although Larry looked like he was having a fun moment, I think he was also quite insightful.
IDEs help people write programs, but to language developers, an IDE might be the easy and less elegant way out of a problem in the design of the language.
- DonHopkins 8y agoAnders Hejlsberg also made the point that types are documentation. Programming language design is user interface design because programmers are programming language users. "East Coast" MacLisp tended to solve problems at a linguistic level that you could hack with text editors like Emacs, while "West Cost" Interlisp-D tended to solve the same problems with tooling like WYSIWYG DWIM IDEs. But if you start with a well designed linguistically sound language (Perl, PHP and C++ need not apply), then your IDE doesn't need to waste so much of its energy and complexity and coherence on papering over problems and making up for the deficiencies of the programming language design. (Like debugging mish-mashes of C++ templates and macros in header files!)
- daotoad 8y agoTypes as documentation is one of the things I like best about Perl6 types. Perl6 has the concept of a `subset` of a type. Let's say I want to write a function that takes a name which must be only one line of text, and a positive integer as arguments. In Perl6 I can document those requirements in the subroutine signature: sub foo( Str $name where *.lines == 1, Int $count where * > 0 ) { say "Name is $name with count $count"; } Or if I want to name the concepts and reuse them, I can say: subset LegalName of Str where *.lines == 1; subset PositiveInteger of Int where * > 0; sub bar( LegalName $name, PositiveInteger $count ) { foo( $name, $count) } You can use these subsets for multiple dispatch as well: # Print a single line argument. multi sub print-it( Str:D $it where *.lines == 1 ) { say $it; } # Print a multiline string as a single line multi sub print-it( Str:D $it ) { say $it.lines.join(''); } # Handle anything that we didn't expect multi sub print-it( Any $it ) { Failure.new( "it was unprintable", $it.gist ); } IME, this makes it easy to write self documenting code.
- DonHopkins 8y agoThen you'd probably love ADA! Does Perl 6 have postconditions, too? https://www.adacore.com/gems/gem-31 https://www.adacore.com/gems/gem-31 Gem #31: Preconditions/postconditions >The notion of preconditions and postconditions is an old one. A precondition is a condition that must be true before a section of code is executed, and a postcondition is a condition that must be true after the section of code is executed. http://www.ada-auth.org/standards/12rat/html/Rat12-2-3.html http://www.ada-auth.org/standards/12rat/html/Rat12-2-3.html >We will look first at the simple case when inheritance is not involved and then look at more general cases. Specific preconditions and postconditions are applied using the aspects Pre and Post respectively whereas class wide conditions are applied using the aspects Pre'Class and Post'Class. >To apply a specific precondition Before and/or a specific postcondition After to a procedure P we write procedure P(P1: in T1; P2: in out T2; P3: out T3) with Pre => Before, Post => After; >where Before and After are expressions of a Boolean type (that is of type Boolean or a type derived from it). If your language supports preconditions, postconditions and invariants, then you can pursue the "Design by Contract" approach to programming, coined by Bertrand Meyer for Eiffel. That's when you guarantee that if all the preconditions are met before calling a function, then all the postconditions will be met after it returns (but the object may go through intermediate states where the postconditions aren't met before it returns, like while inserting an item into a doubly linked list). Unfortunately that idea breaks down when you have multiple threads that might enter a function at the same time, so you have to use object level locks, which have their own problems. https://en.wikipedia.org/wiki/Design_by_contract https://en.wikipedia.org/wiki/Design_by_contract https://en.wikipedia.org/wiki/Eiffel_(programming_language) https://en.wikipedia.org/wiki/Eiffel_(programming_language) >The design of the language is closely connected with the Eiffel programming method. Both are based on a set of principles, including design by contract, command–query separation, the uniform-access principle, the single-choice principle, the open–closed principle, and option–operand separation. >Many concepts initially introduced by Eiffel later found their way into Java, C#, and other languages. New language design ideas, particularly through the Ecma/ISO standardization process, continue to be incorporated into the Eiffel language.
- lizmat 8y ago
- jules 8y agoThe prototypical example being getter and setter methods, which Java IDEs generate.
- gumby 8y agoOr you could just let the language do it, as do Commonlisp and C++.