1

What are the features of $ALIEN_LANGUAGE?

 3 years ago
source link: https://lobste.rs/s/u2wxlq/what_are_features_alien_language
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
What are the features of $ALIEN_LANGUAGE?

I want to learn an “alien” language to expose myself to unfamiliar programming styles (I mostly work with Python on data science stuff). While I don’t have a rigorous definition for “alien” languages, they typically refer to stuff like Nim, Julia, Rust, Go, Zig, Elixir, Erlang, OCaml, Common Lisp, etc, which has gained quite some momentum but is yet to become a Big Language like C++, JavaScript, and Python. Note that I’m learning the alien language just for a fun adventure, and am not expecting the skill to find me a better-paid job.

What are the features of the alien language of your favorite, and what kind of fun will I have by learning it? I surely can go to the language’s homepage and read the “Features” section, but that would be inevitably biased. Additionally, I would appreciate comparisons between different languages to understand their focus better.

  1. From the “non-marketing” features of Erlang/Elixir/BEAM as a whole (so excluding processes, OTP, supervision trees, etc. that you can read in almost any article about it) - binary pattern matching is awesome, and is a thing that made me love binary data formats. It is so simple to work with, that it is IMHO the most irritating thing when I need to work with binaries in any other platform.

    For example to encode integer in BARE you need to do (rough example):

    decode_int(<<1:1, N:7, Rest/binary>>) -> N + (decode_int(Rest) bsl 7);
    decode_int(<<0:1, N:7>>) -> N.
    

    And all bit twiddling magic is handled for you. It was pretty obvious decision to include such construction in Erlang, but it is a shame that not many languages provide something similar to this.

  2. quad

    16 hours ago

    | link

    The Elements of Programming Style:

    The book contains 33 different styles for writing the term frequency task. The styles are grouped into nine categories: historical, basic, function composition, objects and object interactions, reflection and metaprogramming, adversity, data-centric, concurrency, and interactivity.

    Seven Languages in Seven Weeks:

    In this book you’ll get a hands-on tour of Clojure, Haskell, Io, Prolog, Scala, Erlang, and Ruby.

  3. Prolog and forth will both feel unfamiliar. Rust will feel very different. Julia will give you the experience of numerical programming in something different.

    1. nalzok

      16 hours ago

      | link

      Prolog and forth will both feel unfamiliar.

      Thanks for mentioning them! I should note that I’m just looking for a different programming experience, and the language doesn’t have to be new.

  4. J really bent my head. The approach is so different it feels like learning to program again. Each line is it’s own fun little puzzle. There aren’t many “concepts” to wrestle with like in languages with unique type systems or logic languages. You just get a few different starting tools that are quick to grok, but then have to figure out how to actually use them to do anything real.

    As a data science person, you probably have some exposure to array programming ideas through stuff like numpy. But J and other APLs go 100% in that direction, and the world looks really different through that prism.

    I never really write serious J. But the REPL is my go-to calculator and I have a personal library of work and life related functions that I add to as needed. It’s crazy how good it is as a scratchpad, and how much the language conforms to how you think about a domain. Forth has a similar property to a greater degree, but feels like it gets “unruly” in a way that J doesn’t.

    Familiarity with Array Programming has also helped me come up with cleaner designs in other languages. It’s also due for a renaissance imo, as GPUs and SIMD become more relied upon and as the data people realize how wasteful we’ve been with our machines.

    1. SteadBytes

      edited 4 hours ago

      | link

      a personal library of work and life related functions

      Would you mind sharing some examples? Not asking for source code, just curious as to the sort of tasks you use this for :)

  5. Languages that blew my mind where: Lisp, Prolog, APL, FP, Forth, Strand, Verilog, in roughly that order. Note that it is not sufficient to just dabble with a language to get the real “feel” for its peculiarities. Ideally, one should try to implement a language to truly attempt to understand it.

  6. opFez

    11 hours ago

    | link

    After writing in C for the past year, I find Scheme to be a breath of fresh air. It has got all the advantages of being a Lisp (powerful macros, basically no syntax) but is also simpler in regards to Common Lisp. I think that is why I prefer it. Instead of having a tool for every problem, you have a couple tools you use to create your own solutions. Additionally, implementations like Chicken Scheme allows compilation to a binary, which is quite handy and something Common Lisp sorely lacks (no, I do not count sb-ext:save-lisp-and-die).

  7. yaymukund

    edited 9 hours ago

    | link

    I recommend this 3-part course on programming languages. It uses SML. It’s a fine language but I see that as the ‘price of entry’ to learn from Dan Grossman who is a fantastic teacher. It will give you the tools to make sense of all the languages you mention. If I recall correctly, in an early lecture Dan calls this course his ‘magnum opus’ and it shows.

  8. Haskell is interesting because it is one of the few examples of a pure function language. All data is represented by immutable values; all functions are pure (no side effects); all variables are immutable (no assignment statement). Coming from a background of object-oriented programming, it wasn’t obvious to me that you could do general purpose programming without mutable objects or mutable state, and once I clued in, it really changed the way I think about programming. Plus, Haskell has a very powerful type system. Learning the idioms of type-directed programming also changes the way you think about programming.

    Somebody suggested J, but I will suggest the K programming language instead. K is much simpler. The entire language cheat sheet fits on one page. K is rigorously simple, comprised of a small number of orthogonal types and operators that are highly composable. Most languages are an agglomeration of features, which are DSLs for different domains of programming. Like, there is a module feature, which has hierarchical module names, an ‘import’ statement which is its own mini-language, etc. In an OOP language there is a class feature, and a fairly complex DSL for defining classes, inheritance, etc. K doesn’t have features, it has idioms. You do everything by composing this small set of orthogonal operators. The operators are for the most part single ASCII characters. Each ASCII punctuation character has its own special meaning. K is extremely terse. Once you learn the idioms, K programs can be 100x shorter than programs in conventional languages. K programmers rely a lot less on libraries than in Python. The K idiom for some simple Python library function (which could be a composition of 3-5 K operators) is often fewer characters than the name of the Python library function, so why use a library if it’s more typing than using the idiom.

  9. If you’ve never written a Lisp before, I can recommend Janet as a nice introduction to that world.

    1. nalzok

      16 hours ago

      | link

      May I ask why do you like it, and how it compares to more traditional choices like Scheme and Common Lisp?

      1. I have a few reasons that I like it.

        I tried it on a whim for Advent of Code 2020, and ended up liking the PEGs quite a lot.

        Then, as I’ve used it more and more, I’ve grown to like it for it’s macros, and for the rather practical sensibilities it has around it’s data structures. It is still very young in an ecosystem sense, so it’s a great chance to learn how to build things for a small ecosystem, and/or to practice hacking on C extensions, or writing things in Zig (there are some people working with zig with it).

        I don’t have deep experience with Scheme and Common Lisp.

      2. jakob

        edited 4 hours ago

        | link

        Regarding the second point, they’re similar. The syntax is the same, and you have “similar enough” primitives for working with sequences. There are a few “big” differences, like most sequential data structures not being linked lists, but it still feels lisp-y to me.

        Racket is another beginner-friendly Lisp if you’re looking for something resembling Scheme. It has a nicely-written guide. The Janet documentation might be a bit confusing if you don’t have prior experience with lisp.

  10. nextos

    edited 3 hours ago

    | link

    • Erlang: Message-passing everywhere, thanks to the actor model. Feels like creating new biological systems, not just programming. In a good way.

    • Prolog: Encode rules. Encode a metainterpreter to redefine search. Suddenly, you have a very flexible system. Not just the cliche about Prolog. The first Erlang implementations were built this way.

    • Haskell: Laziness and point free style enable extreme composition, and facilitate calculating programs. Read about Squiggol to understand the deep implications this may have. The Joy language is also worth mentioning here.

    • Idris: Dependent types let you encode rich constraints that can be enforced at compile time. Liquid Haskell uses refinement types, which are a less expressive but more tractable alternative. And you still have the whole Haskell ecosystem at your disposal.

    • Mozart/Oz: Many paradigms in the same language. Look up CTM, a great sequel to SICP.

    • Julia: AOT compilation of specialized functions can lead to wicked speedups. Multiple dispatch plus a clever dynamic type system may be all you need for number crunching.

    • Rust: Nice type systems are also good for non-GC languages, and can enforce very practical guarantees (memory safety) for systems programming.

  11. Personally I got the most out of Erlang (in terms of mind expansion a la Sapir-Whorf and also in terms of usefulness as a tool for building systems), and I learned about it via the Seven Languages in Seven Weeks book mentioned by another commenter. There’s a sequel to that one out by now I believe.

  12. andyc

    edited 15 hours ago

    | link

    What I think are the most unique aspects of some languages you listed:

    • Julia: the way it’s dynamically typed but also uses types to generate fast code. This is totally unique to Julia as far as I can tell.
    • Rust: borrow checker, lack of mutable aliasing, fearless concurrency, etc. Also appears to be unique.
    • Go: the style of concurrent/parallel programming using goroutines and channels, although I will note it’s logically “threads and channels”. (Also I’ve heard that there are lots of big Go programs that don’t use channels at all, which might surprise the designers of Go.)
    • Zig: compile time metaprogramming and how it subsumes other language features.
    • OCaml: like Standard ML, I would say it’s worth it just to program with algebraic data types. You can sort of fake this in TypeScript and other languages but it’s worthwhile to use the “original”.

    I also recommend learning shell :-) It will expand your thinking:

    https://www.oilshell.org/blog/tags.html?tag=shell-the-good-parts#shell-the-good-parts

    Particularly around polyglot programming, i.e. factoring systems into processes written in different languages. And maintaining/operating/administering those systems, not just writing them.

    You get a different view on software once you have to admin your own code :) The operator’s view is inherently dynamic, not static.


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK