4 ms·
That example is complicated because it interfaces with C++ and defines a macro. Most Nim code looks nothing like that. > I don't think Nim and many other ML-in
by lobster_johnson 10y ago
That example is complicated because it interfaces with C++ and defines a macro. Most Nim code looks nothing like that.
> I don't think Nim and many other ML-inspired languages
I don't think Nim is particularly ML-inspired. Nim's main point of influence is Turbo Pascal/Delphi and their deratives, which used to be obvious from all the "T" prefixes (TObject and so on, now largely or entirely gone from the language). Nim has things like ranges and enums, both of which come directly from Pascal.
- amyjess 10y agoThere's also a lot of Modula-3 in Nim, too. Which makes sense: Modula-3 is also a Pascal derivative, and there's a lot of Modula-3 in Python, which Nim borrows syntax from, too.
- lobster_johnson 10y agoThere's so much overlap between the Wirth languages that I am not surprised about that. What specifically comes from Modula-3, though? I didn't know that Python was influenced by Modula. Any examples? Keyword arguments is the only that comes up on Google.
- amyjess 10y ago> What specifically comes from Modula-3, though? Off the top of my head, the equivalency of "foo.bar(baz)" and "bar(foo, baz)" was inspired by Modula-3's object model, though Nim extends it to everything and not just classes. Also, Wikipedia tells me the pointer system comes from Modula-3. Nim's official FAQ also lists Modula-3 as the single biggest influence; I have a feeling that a lot of the Wirth-isms in Nim were borrowed from Modula-3 rather than from Pascal, even if they appeared in both languages. > I didn't know that Python was influenced by Modula. Any examples? Keyword arguments is the only that comes up on Google. Off the top of my head: - The module system. The syntax of "import foo" and "from foo import bar" were borrowed from Modula-3 verbatim, and Guido got the idea to give Python a module system in the first place because Modula-3 convinced him modules were the future. - The exception system. A lot of people don't notice the exception system because pretty much every language in the '90s also borrowed that from Modula-3 (the try-catch paradigm was invented by Modula-3), but Python hews even closer to the Modula-3 model by using the word "except" instead of "catch" and allowing for multiple except blocks attached to a single try block. - The object system is a hybrid of Modula-3 and C++; the whole idea of passing "self" as the first parameter to a method instead of having an implicit "this" was a Modula-3 thing. The official Python documentation still references it: https://docs.python.org/3/tutorial/classes.html https://docs.python.org/3/tutorial/classes.html Guido also talks about the Modula-3 influence in a few places: https://docs.python.org/3/faq/general.html#why-was-python-created-in-the-first-place https://docs.python.org/3/faq/general.html#why-was-python-cr... http://www.artima.com/intv/pythonP.html http://www.artima.com/intv/pythonP.html
- lobster_johnson 10y agoHm, is this official, or are you deducing this from similarities? I wish Andreas Rumpf were here to comment and hopefully correct me, but I believe he was formerly an ObjectPascal/Delphi programmer. The first version of the Nim compiler was written in Borland's ObjectPascal dialect (see http://nim-lang.org/docs/intern.html http://nim-lang.org/docs/intern.html), which has some of the same features as Modula, but with a slightly more circuituous lineage, since it was originally based on Apple's Object Pascal, a dialect which Wirth was tangentially involved in designing. (Object Pascal predates Modula-3, too.) In that sense, some of the similarities are probably accidental or caused by cross-pollination (for example, Borland probably took the exception handling syntax from Modula). That's the problem of trying to infer lineage by looking at similarities alone. The unified call syntax sounds like it might be lifted directly from Modula, though. Thanks for the Python trivia, I didn't know that.