33 votes

What is your go-to project for learning a new language?

Ive been playing around with learning a lisp language for a while, and I recently decided to go for it and learn fennel (as I already am comfortable with lua) just to see if I like lisps as a class. Normally, I try to do the first 5-10 days of a previous advent of code to pick up a lang.

Setting up my advent of code environment got me wondering: what projects do other people use to learn new languages/tooling? Id love to hear how other people approach learning a new skill.

22 comments

  1. kari
    Link
    That's exactly what I was coming here to suggest :) @hpr's suggestion of writing something you actually want to use is the other big one. For me, writing a couple of projects I actually use every...

    Normally, I try to do the first 5-10 days of a previous advent of code to pick up a lang

    That's exactly what I was coming here to suggest :)

    @hpr's suggestion of writing something you actually want to use is the other big one. For me, writing a couple of projects I actually use every day is the main reason I was able to learn Zig.

    8 votes
  2. DeaconBlue
    Link
    https://codegolf.stackexchange.com/questions/33172/american-gothic-in-the-palette-of-mona-lisa-rearrange-the-pixels Take pixels from picture A and try to use them to create picture B. It deals...

    https://codegolf.stackexchange.com/questions/33172/american-gothic-in-the-palette-of-mona-lisa-rearrange-the-pixels

    Take pixels from picture A and try to use them to create picture B.

    It deals with file IO, arrays, heavy math comparisons, I have a local server set up to animate my output so it involves web calls, and I try new ways to solve the problem each time because there is no "correct" solution.

    5 votes
  3. hpr
    Link
    Hm, I haven't gotten around to properly doing this apart from my day job, but depending on language you could also throw in Project Euler for algorithmic stuff, something like ToDoMVC for...

    Hm, I haven't gotten around to properly doing this apart from my day job, but depending on language you could also throw in Project Euler for algorithmic stuff, something like ToDoMVC for frontend-focused languages or generally some kind of "code katas" used to be big too.

    All these toy things aside, I believe the actual best thing would be something you actually want to have or use, which would provide additional motivation as well as actual "requirements" or fun ideas to work on.

    Maybe a little game, as well.

    4 votes
  4. [6]
    archevel
    Link
    I tend to do something I am fairly familiar with domain wise. Learning F# a while back I did a parser for Swedish accounting data using parser combinations via fparsec. I hadn't done much with...

    I tend to do something I am fairly familiar with domain wise. Learning F# a while back I did a parser for Swedish accounting data using parser combinations via fparsec. I hadn't done much with parser combinations before, but I knew the file format fairly well. Other times I build a lisp :) getting a basic interpreter is fairly straightforward (the book SICP is a good reference manual for this).

    Contrary to other people's recommendation I would avoid building something I actually want to use. I want a certain level of mastery and understanding of the tool (language) before doing anything "serious" with it. YMMV.

    4 votes
    1. glesica
      Link Parent
      I'm the same. If I finish (for some definition of the word, hehe) the project, but decide I don't really care to use the language in the future, I'm stuck maintaining a thing I use in a language I...

      I want a certain level of mastery and understanding of the tool (language) before doing anything "serious" with it.

      I'm the same. If I finish (for some definition of the word, hehe) the project, but decide I don't really care to use the language in the future, I'm stuck maintaining a thing I use in a language I don't want to use.

      3 votes
    2. [4]
      kej
      Link Parent
      This phrasing makes it seem like Swedish accounting differs significantly from other accounting. Is that the case, or am I reading too much into your word choice?

      I did a parser for Swedish accounting data

      This phrasing makes it seem like Swedish accounting differs significantly from other accounting. Is that the case, or am I reading too much into your word choice?

      3 votes
      1. [2]
        Narry
        Link Parent
        Swedish accounting practices are far more Scandinavian than other accounting practices. Austere but beautiful. I’m kidding. I have no idea. Maybe double-entry accounting is a common Swedish practice?

        Swedish accounting practices are far more Scandinavian than other accounting practices. Austere but beautiful. I’m kidding. I have no idea. Maybe double-entry accounting is a common Swedish practice?

        3 votes
        1. balooga
          Link Parent
          I use a shiatsu accountant, personally.

          I use a shiatsu accountant, personally.

          2 votes
      2. archevel
        Link Parent
        Nah, the basic data is the same, but the file format is specific to Sweden (I believe). It's a standardized format for exchanging accounting data that has wide adoption from the system providers....

        Nah, the basic data is the same, but the file format is specific to Sweden (I believe). It's a standardized format for exchanging accounting data that has wide adoption from the system providers. Here is some info on it SIE file format. Main thing a lot of applications miss is that it uses cp437 as an encoding which is mostly compatible with ANSI, but reading a file as regular ansinor utf-8 can garble some text.

        2 votes
  5. kej
    Link
    There is a 1978 book called Etudes for Programmers (overview here, but you can find a full PDF pretty easily) that has a bunch of problems that most software developers think they can solve, but...

    There is a 1978 book called Etudes for Programmers (overview here, but you can find a full PDF pretty easily) that has a bunch of problems that most software developers think they can solve, but that most software developers have never actually sat down and solved. Things like simulating Conway's Game of Life, or a basic accounting system, or the AI for a simple board game.

    I've only done a few of them, but they feel more satisfying than some of the Advent of Code/Project Euler puzzles, although I enjoy those quite a bit as well.

    4 votes
  6. scarecrw
    Link
    Not sure how generalizable this is, but I started learning Rust by going through Ray Tracing in One Weekend and translating as I go. It looks like someone's published a version for Rust...

    Not sure how generalizable this is, but I started learning Rust by going through Ray Tracing in One Weekend and translating as I go. It looks like someone's published a version for Rust specifically, but I actually found a lot of value in having to translate myself.

    It's a good blend of not having to worry too much about the project/structure (as it's all planned out for you) but still forcing you to identify the goals and learn what language tools to apply.

    3 votes
  7. Eji1700
    Link
    Snake. It's a simple thing but it requires some level of output, and understanding what options a coding language has for user interface is something that I feel too many coders gloss over. "oh...

    Snake.

    It's a simple thing but it requires some level of output, and understanding what options a coding language has for user interface is something that I feel too many coders gloss over.

    "oh we'll just dump to the console" or "tie to your interface here" or whatever. Given how many ways there are to interact with the user these days and the initial "do you want what is essentially a web app" starting point, I NEED something that helps me test that so I can figure out what my real options are.

    Obviously most everything these days has some way of at least connecting to JS, but even that can vary wildly.

    3 votes
  8. Bwerf
    (edited )
    Link
    I usually write a cli file deduplication program, i.e. finding files on disk that has the same content but not necessarily the same name. It's a bit of different data structures, standard library...

    I usually write a cli file deduplication program, i.e. finding files on disk that has the same content but not necessarily the same name. It's a bit of different data structures, standard library usage, error handling, string formatting and printing. Sometimes there's some dependency management as well if the hashing implementations are not part of the the standard library as well. At it's easiest it's pretty simple, but you can of course make it as complicated as you want as with any program.

    2 votes
  9. shrike
    Link
    IRC Bot. It's surprising how many languages make it nearly impossible :) You need to have at the very least: A constant open TCP connection, modern servers require TLS/SSL too. A way to listen to...

    IRC Bot. It's surprising how many languages make it nearly impossible :)

    You need to have at the very least:

    • A constant open TCP connection, modern servers require TLS/SSL too.
    • A way to listen to PING messages from that connection and reply PONG or the server will kick you out for being idle (some kind of threading or event-based system)
    • Sane way to parse strings

    Then you can start adding stuff like logging (writing to files or sqlite), module support (calling plugins, hot-reloading them in some way), configuration (read config from a file or something else), support for multiple networks (need to have 2+ constant TCP connections and an ability tell which is which)...

    And from that you can either go more on the bot side or start turning it into a client. Or go fancy and make the same core work for Discord and Telegram.

    2 votes
  10. [4]
    Narry
    (edited )
    Link
    I pretty much exclusively want to make command line interface/text user interface apps, so my first thing to do to try to shake out any language is to attempt to find how it handles console-based...

    I pretty much exclusively want to make command line interface/text user interface apps, so my first thing to do to try to shake out any language is to attempt to find how it handles console-based input an output.

    So far other than a couple of libraries in python, I’ve been very disappointed by how little modern programming languages tend to support the CLI. Many of them do have some sort of very lightweight I/O, but if you’re looking for things like proper ANSI codes or anything like that, best to just stick with things like Python. Sad thing is, I really don’t care for Python. My preference tends to go towards functional languages like Haskell and LISP, and procedural languages like Odin, and Go.

    (I guess technically there are some good ones for JavaScript, but I hate node with a burning passion, I can’t figure out deno, and to be honest, I just don’t much care for either JavaScript or TypeScript.)

    (Edit to fix Io -> I/O, this comment.)

    1 vote
    1. [2]
      Comment deleted by author
      Link Parent
      1. Narry
        Link Parent
        I really should properly learn ncurses…

        I really should properly learn ncurses…

        1 vote
    2. [2]
      Toric
      Link Parent
      Rust has a really good CLI ecosystem, actually, though its standard library doesnt provide that much.

      Rust has a really good CLI ecosystem, actually, though its standard library doesnt provide that much.

      1 vote
      1. Narry
        Link Parent
        Every time I look at Rust code my brain goes “nope, that’s for professional programmers and you’re a hobbyist. Turn around and find something for guys like you.” (To be fair I have this exact same...

        Every time I look at Rust code my brain goes “nope, that’s for professional programmers and you’re a hobbyist. Turn around and find something for guys like you.”

        (To be fair I have this exact same reaction to C++ and Zig)

  11. WhyCause
    Link
    When I want to "test drive" a language to see if I want to go any further with it, I'll write a ROT13 program. It includes a lot of the things I need to do on a daily basis, including text...

    When I want to "test drive" a language to see if I want to go any further with it, I'll write a ROT13 program. It includes a lot of the things I need to do on a daily basis, including text handling, file I/O, string manipulation, command-line handling, and simple data structures.

    Usually, I'll start with a hard-coded string and expand from there, moving on to add handling text passed on the command line, a flag to open a file instead, and a flag to change the rotation number. Once I've done all that, if I'm not grinding my teeth, I'll start implementing something else and see how it goes.

    1 vote
  12. tanglisha
    Link
    A bit of a tangent, the biggest challenge I usually have with lisps is importing or programmatically referencing other files.

    A bit of a tangent, the biggest challenge I usually have with lisps is importing or programmatically referencing other files.

  13. macleod
    (edited )
    Link
    I don't enjoy anything that has to do with rendering, and prefer more utilitarian 'first' cases. So Conways Tree of Life and Snake are out. What I do really enjoy is writing a CLI parser with a...

    I don't enjoy anything that has to do with rendering, and prefer more utilitarian 'first' cases. So Conways Tree of Life and Snake are out.

    What I do really enjoy is writing a CLI parser with a defined setup (usually using an array of objects, or similar) of commands, parsing them, and giving results.

    Setting up a system to take --flags, long or -s (short), defining type information such as Path, String, Bool, etc. Setting required flags. But, in an easy defined way, not in a way that requires macros, or CLI parsing.

    That way when I start a project I can create something like this (natively in the language, not using this problematic psuedocode):

    [ 
        Command: {
            name: "run"
            short: "r"
            required: false
            desc: "runs something"
            handler: thingtoRun()
        },
        Command: {
            name: "echo"
            short: "e"
            required: true
            desc: "prints a statement to stdout"
            args: {
                Arg: {
                    name: "statement"
                    required: true
                    type: String
                    inherent: true
                } 
            }
            handler: echo_fn(args.Arg["statement"])
        }
    ]
    
    fn echo_fn(statement: String) {
        print(statement)
    }
    
    > program echo --statement "Hello World!"
    
    Hello World! 
    
    > program e "Hello World!"
    
    Hello World! 
    
    > program echo
    
    echo requires a 'statement'! 
    
    > program --help
    
    run :: runs something 
       no arguments needed 
    echo :: prints a statement to stdout 
       --statement: required
    
    

    This makes it easy to understand types of the language, set flags, set required flags, easy to debug/experiment in the future. It basically becomes the entire 'core' of any of my programs, even if the user never sees it, and it allows for an excellent way to get instant results and learn the language since you have to learn how to parse given data on the command line, and then have it execute other functions. It's fun!

    You're essentially needing to figure out a way to read arguments from the command line, and then write an entire generic parser, and then is infinitely changeable, reusable, and you can re-implement in every project going forward (bonus points if you can use direct documentation comments to be included in your help message!). You can then build additionally scaffolding so you can build subcommands, different types, different results, etc. It's a great starting point that usually gives instant response as you are building, something important when you are first starting out in a new language so you don't end up being discouraged.

    Edit: Fix my unuseable pseudocode to be more believable? understandable? correct?

  14. AaronNight
    Link
    My "Hello World" set of projects: Tic Tac Toe Battleship (sometimes with multiplayer if I expect to work with network later) Minesweeper Wordle All this projects works perfectly in terminal, so...

    My "Hello World" set of projects:

    • Tic Tac Toe
    • Battleship (sometimes with multiplayer if I expect to work with network later)
    • Minesweeper
    • Wordle

    All this projects works perfectly in terminal, so CLI-first is a huge benefit to test apps without the need of complex UI, even in REPL environments. Also, games are fun to make.