News for hackers. Stuff that matters.
Re:Advanced programming languages (2009) by Bromskloss on Sunday June 19, 2016 @12:11PM (#11933426)
> It's untyped, which makes it ideal for web-based programming and rapid prototyping. Given its Lisp heritage, Scheme is a natural fit for artificial intelligence.

Why does being untyped and having a Lisp heritage make Scheme suitable for these three tasks?

Re:Advanced programming languages (2009) by phamilton on Sunday June 19, 2016 @12:27PM (#11933492)
Web based is because JSON is always easier with dynamic types.

Rapid prototyping is because it requires less explicit up front design due to dynamic types.

Artificial Intelligence is because metaprogramming is easier in homoiconic languages.

Re:Advanced programming languages (2009) by hesdeadjim on Sunday June 19, 2016 @01:13PM (#11933693)
I just don't buy the "dynamic types" lets you iterate faster argument. You are implicitly using types, and how often does that type change such that all the code you've written doesn't need to be updated anyways? And without the benefit of a compiler to tell you what you need to fix. A language like Go is fast to iterate, trivial to parse and serialize JSON, and simple enough that the tools let me make sweeping changes quite easily.

For a while now I have felt that the reason for the creation of languages like Python and Ruby is simply a response to the pain of one such as C++. Now that we have modern languages like Rust and Go, what is there to be gained from sacrificing a type system?

Re:Advanced programming languages (2009) by phamilton on Sunday June 19, 2016 @01:21PM (#11933726)
Iterate faster != Rapid prototyping.

The type system definitely helps with long term maintainability (and therefore fast iteration) but when your goal is to whip out a Proof of Concept for a greenfield project Ruby wins for me hands down. (Provided it isn't overly complex, defined as "can be completed in an hour or two").

Re:Advanced programming languages (2009) by peteretep on Sunday June 19, 2016 @02:28PM (#11933980)
Can you explain how types slow you down for whipping up a proof of concept?
Re:Advanced programming languages (2009) by phamilton on Sunday June 19, 2016 @02:36PM (#11934014)
Hitting an API endpoint, pulling data out of a database. Areas that already have an implicit schema require you to explicitly redefine that schema within your application.

I say this not just from personal preference, but I've proctored many timed coding challenges that were language agnostic. The challenge involved consuming data from a handful of API endpoints and compiling a response. Most statically typed solutions took twice the time of a dynamically typed one. We catered the time limit to the static case and it was a simple pass fail so no bonus points for doing it faster, but there was a strong advantage to the dynamic languages.

Note: This is very much alleviated with typed interchange formats like protobuf.

Re:Advanced programming languages (2009) by hesdeadjim on Sunday June 19, 2016 @02:47PM (#11934077)
That coding challenge sounds like a far cry from developing even a prototype application. What was the skill level of the people doing it? Had they had experience in both dynamic and static types languages? What were the languages, Java or something modern?

Edit: I don't mean this to be snarky, I just feel that it is not a very good experiment to draw conclusions from.

Re:Advanced programming languages (2009) by phamilton on Sunday June 19, 2016 @03:16PM (#11934244)
We prepped them ahead of time telling them that they would need to produce an HTTP API that accepted requests and returned a response compiled from multiple HTTP endpoints. It's basically an orchestration layer, and I've done similar things in production many times. ("If we exposed X to the clients, we could allow action Y. Would action Y contribute to our goal of Z?" Instead of building a highly performant correct solution, we would do an on the fly derivation of the data needed, launch it for 5% and see the experiment results.)

It was for all candidates, meant to test ability to understand a problem and prototype a solution quickly.

Edit: most candidates did Java/Scala/Python/Ruby.

Re:Advanced programming languages (2009) by caconym_ on Sunday June 19, 2016 @04:05PM (#11934444)
I think it's not so much a fundamental issue with "strongly typed" languages as it is the way "dynamic" languages are typically designed. For instance, Ruby doesn't care if you add an integral type to a floating point type; it'll give you something back. A strongly typed language will typically complain about this (the alternative is e.g. an onerously huge constellation of custom typeclasses/traits/whatever to support the full range of numeric intermingling), and Ruby could too, but its designers have made the decision that arithmetic operations should silently convert one argument to the type of the other, and return the answer as an instance of that type.

If I'm hacking together a quick and dirty prototype, I might not even care what type I get back from that operation as long as it's in the ballpark. Using Ruby means I just don't have to worry about it for longer than it takes me to type `a + b`. If I used Haskell, or Rust, or whatever, I have to be explicit. That's additional work, however minimal, and in my experience it really does add up.

Of course, if I'm writing code that's going to be in production, this sort of thing is highly irresponsible and using a strongly typed language will help me to avoid numerical errors that would not even be runtime errors in e.g. Ruby; they'd be silently swallowed instead. That's extremely valuable. And if development of my prototype is going to span multiple days or more, strong types and compile-time type checking are going to reduce my mental workload since I don't have to remember how everything fits together; it's explictly annotated throughout the code and checked every time I build.

Re:Advanced programming languages (2009) by edgyswingset on Sunday June 19, 2016 @01:08PM (#11933672)
> because JSON is always easier with dynamic types.

I think you mean JSON where the schema isn't defined. If you have full control over the JSON you're consuming, you control the schema. Typed languages aren't any worse than dynamic languages in this case.

> Rapid prototyping is because it requires less explicit up front design due to dynamic types.

Many types languages have a REPL environment specifically for this reason. In my experience, it's not any slower.

> Artificial Intelligence is because metaprogramming is easier in homoiconic languages.

I have no experience here, thus I will assume you are correct.

Re:Advanced programming languages (2009) by phamilton on Sunday June 19, 2016 @01:13PM (#11933692)
Complex, recursive JSON schemas are much more difficult even when the schema is known in most typed languages. Not impossible but I've definitely found myself changing my schema design because of friction in parsing JSON in Java.
Re:Advanced programming languages (2009) by mafribe on Sunday June 19, 2016 @02:52PM (#11934108)

   Artificial Intelligence is because 
   metaprogramming is easier in homoiconic 
   languages.
Homoiconicity is something you can add to any language, dynamically or statically typed, simple or complex, it doesn't matter. It used to be belived that only syntactically simple languages like Lisp are suitable for homoiconic extension, but this myth was destroyed by Walid Taha and his development of the MetaML family of languages.

For an overview of how to add homoiconicity to languages, see https://arxiv.org/abs/1602.06568

Re:Advanced programming languages (2009) by hetman on Sunday June 19, 2016 @03:05PM (#11934181)
While I'm sure it's an interesting exercise, using a language that already had this property without any additional effort, still seems like the best path for most people trying to produce practical results.
Re:Advanced programming languages (2009) by mafribe on Sunday June 19, 2016 @04:16PM (#11934480)
I'm not sure I can agree. Every language that is being heavily used eventually acquires meta-programming extensions of some sort of other.
Re:Advanced programming languages (2009) by bogomipz on Sunday June 19, 2016 @02:20PM (#11933954)
I'm really intrigued by your last point that "Artificial Intelligence is because metaprogramming is easier in homoiconic languages."

Can you elaborate on this? Why are or what about homoiconic lnagunages make them more suitable for metaprogramming and AI in general?

Thanks

Re:Advanced programming languages (2009) by phamilton on Sunday June 19, 2016 @02:42PM (#11934047)
Homoiconic languages are ones where the program itself is a valid data type. Lisps (like scheme) are great for this because your program is just a list. You can insert and remove code using the same tools you would for manipulating a list generally. It makes metaprogramming much simpler.

The relation to AI is an assumption that AI and metaprogramming are connected. This is probably debatable, but it makes sense to me (and others) that AI development would benefit from being able to easily generate code and modify itself, much like you or I would learn a new skill.

Re:Advanced programming languages (2009) by bhntr3 on Sunday June 19, 2016 @02:47PM (#11934072)
I don't think this is actually true for most of what people do with AI right now. Machine learning these days is something where you want strong, native machine level support for numeric programming on matrices. Possibly with GPU support. So a lisp based language wouldn't really help you much in the current environment.

If what you want is a system that rewrites itself, then you definitely want homoiconicity. It also helps if everything is one big expression.

Let's say you want to write an evolutionary algorithm that rearranges fragments of its code and runs it. More successful functions make it to the new generation. You want LISP for that.

Realistically, you could probably do this on any abstract syntax tree. But the problem is that unless your language is homoiconic, what you get back might not actually be valid in your language. So, homoiconicity gives you bidirectional support for rearranging the AST and still getting something you can read.

It's also just a lot easier to write something that looks at the code and does computation on it when that code is also data.

But, like I said, I'm not sure many people are actually doing this these days. It was popular back in the day. It's not clear that it's the right way to do things.

Re:Advanced programming languages (2009) by teamhappy on Sunday June 19, 2016 @04:25PM (#11934510)
> [...] you want strong, native machine level support for numeric programming on matrices. Possibly with GPU support.

Scheme is a popular extension language. You could use it the same way Torch uses Lua.

Re:Advanced programming languages (2009) by bogomipz on Monday June 20, 2016 @01:02AM (#11936141)
Thanks, sure, this makes sense given the origins of LISP. Cheers.
Re:Advanced programming languages (2009) by douche on Monday June 20, 2016 @07:41AM (#11937358)
Why is JSON easier with dynamic types? In my experience, there's always a schema of some kind.
Re:Advanced programming languages (2009) by jlg23 on Sunday June 19, 2016 @12:55PM (#11933606)
Your first two points are also met by optionally typed languages.
Re:Advanced programming languages (2009) by phamilton on Sunday June 19, 2016 @01:06PM (#11933662)
I'd argue that optionally typed languages are dynamically typed. Typescript at runtime is dynamically typed, same with Erlang. Perhaps not always true, but usually the type system provides static analysis which is help but not sufficient to provide guarantees.
Re:Advanced programming languages (2009) by MaulingMonkey on Sunday June 19, 2016 @02:49PM (#11934096)
Dynamic typing and static typing can coexist in the same language. C# is generally statically typed, but the more recent versions support the dynamic keyword - at which point you're statically typing things to be dynamically typed. Typescript of course goes the other way - adding static typing features to otherwise dynamically typed Javascript.

...the first thing I do when encountering JSON in TypeScript these days is to add type definitions to describe the schema. If I have a hard time describing the schema to TypeScript, I'm going to have an even worse time trying to keep it straight myself.

Re:Advanced programming languages (2009) by shrugger on Sunday June 19, 2016 @01:04PM (#11933654)
Oh yeah, because those are a dime a dozen and available almost everywhere! /s
Re:Advanced programming languages (2009) by teamhappy on Sunday June 19, 2016 @12:28PM (#11933496)
> web-based programming and rapid prototyping

Any dynamically-typed scripting language is good for that sort of thing. Scheme in particular is very productive because of its meta-programming capabilities and REPL-based development.

> artificial intelligence

"Scheme was created during the 1970s at the MIT AI Lab [...]"

https://en.wikipedia.org/wiki/Scheme_(programming_language)

Re:Advanced programming languages (2009) by _ph_ on Sunday June 19, 2016 @12:20PM (#11933463)
And of course, it is not "untyped". It is dynamically typed.
Re:Advanced programming languages (2009) by rayiner on Sunday June 19, 2016 @12:50PM (#11933581)
PL theorists generally talk about whether or not syntactic terms (as opposed to runtime values) have types. Scheme is untyped by that definition.
Re:Advanced programming languages (2009) by klibertp on Sunday June 19, 2016 @12:58PM (#11933622)
PL theorists - from what I saw, not being one - prefer the term "unityped". It's not true that there are no (static!) types - there is a single, unnamed type which contains all possible values.
Re:Advanced programming languages (2009) by kazinator on Sunday June 19, 2016 @02:04PM (#11933878)
PL theorists who know what they are talking about know that this is false, because the actual diverse types of those values can be reasoned about at compile time. Such a "unityped" program is made up of syntax. We can reason about an expression more deeply than just "it returns a value" and we can do so statically. For instance in Lisp we know more about an expression like (cons 1 2) than that it returns a value. We know statically that it returns a cons. From that we can infer that (+ (cons 1 2) 3) is not well-typed.

Type isn't just an implementation system; it's how we can reason about the program, as a mathematical object. The reasoning which informs us that (+ (cons 1 2) 3) is not well-formed without evaluating it, has to do with type.

How we implement values (using a generic "cell" that is type-tagged) is just a convenience. We can get things working without being concerned for up-front type checking. It also represents the philosophy that type is innate to objects (not just a syntactic property of programs).

A piece of compiled code can have a type passed into it which didn't exist when that code was compiled, and sensible things can happen anyway.

Re:Advanced programming languages (2009) by tel on Sunday June 19, 2016 @02:48PM (#11934078)
It's not false, it's just unspecified. If you hand me scheme I can provide it a unitype system without conflict. If you hand me Haskell I cannot because the language has explicitly said that uncheckable statements are invalid.

You can of course go further with your static analysis—a language may support many type systems in principle regardless of what the compiler accepts.

Re:Advanced programming languages (2009) by szemet on Sunday June 19, 2016 @02:28PM (#11933975)
It depends on the context. I guess rayiner has referred to "untyped lambda calculus".

Thats not a bad name as it is self consistent - there are no type expressions in that language. If you say that it is actally "unityped" it is (just) your (semantical) categorization looking at it from a higher level perspective.

Of course on the other side whole numbers were just "number"-s, before fractionals came, so in the end it may be ok to introduce higher level perspective in naming just to diferrentiate better. :)

Re:Advanced programming languages (2009) by kazinator on Sunday June 19, 2016 @01:57PM (#11933849)
PL theorists don't get own the definition of what "type" means.

Type pervades computing.

A directory is a different type from a file or character device. A JPEG is a different file type from a PNG. You have MIME types in your e-mail. An ICMP packet is a different type from a TCP datagram.

Machine language instruction sets have types: pointers, signed and unsigned words of various sizes, floating-point values.

"Type" is a very broadly encompassing word. What all notions of type have in common is that it refers to some representation by whose rules some digital bits are interpreted to have a meaning (in some context which somehow establishes which rules apply).

Re:Advanced programming languages (2009) by rayiner on Sunday June 19, 2016 @02:26PM (#11933969)
> PL theorists don't get own the definition of what "type" means.

Every field has its terms of art. "Type" is a term of art in PL theory; PL theorists are entitled to define it how they want. Of course you can use the word however you want, but you can't complain if that non-standard usage results in miscommunication with others.

Besides that, it's very useful to able to talk about the "types" of syntactic terms as distinct from the "types" of runtime values. You can easily reason about syntactic types. You can, for example, use syntactic types to resolve syntax ambiguities (as in C++) or prove program properties. Runtime "types" are much less useful to PL theorists because it's hard to reason about them.

Re:Advanced programming languages (2009) by noblethrasher on Sunday June 19, 2016 @02:38PM (#11934024)
A PL theorist would note that most of the time when people talk about ‘types’, that they really mean ‘classes’, and that all of those things your mentioned would be considered to be the latter. Types are rather the elements of your program that correspond directly to logical propositions (which your program proves to be true).
Re:Advanced programming languages (2009) by kazinator on Sunday June 19, 2016 @10:15PM (#11935721)
In software engineering, programs are usually not constructed to prove anything; this claim is just the consequence of an equivalence between logic and static typing (Curry-Howard). Programming languages do not make very good logic systems in spite of the isomorphism. They are not designed to be expressive that way. The logic system exhibited by the type system is geared toward proving trivialities about the program: mainly that its run-time translation won't misuse data. Plus it supports certain devices like polymporphism and pattern matching and whatnot.

Now instead of writing a useful program, we can exploit the type system for doing logic in a separate domain, detached from the program. The proof occurs as a byproduct when we compile the program.

Somehow we encode, for instance, the "all men are mortal; Socrates is a man; therefore Socrates is mortal" argument into types and write the corresponding code. Then when the code compiles, it verifies: yes, the argument is valid. At that point, we throw the program away. What (if anything) that program does is irrelevant; its types have proven the modus ponens as it passed through the compiler, thus quod erat demonstrandum.

That is supposedly what type is all about in a very narrow, myopic branch of computer science.

Re:Advanced programming languages (2009) by xyzzy4 on Sunday June 19, 2016 @12:35PM (#11933526)
Since Strong A.I hasn't been invented yet, I don't think anyone knows which language is best for A.I. Maybe it'll just be something boring like Java.
Re:Advanced programming languages (2009) by dxhdr on Sunday June 19, 2016 @01:11PM (#11933686)
Agreed, that was the only sentence in the article that gave me pause -- a language having been used extensively for (failed!) attempts at A.I. does not make it a great A.I. language. Maybe we'd have general purpose A.I. by now if we didn't waste a decade with LISPs; the secret has been there in assembler all along!