Agreed on all points. I think some of the issues that you’re facing are things that would be resolved if Ocaml were more popular. But some others would be harder to fix without making breaking changes to the language as I mentioned earlier. If I had to put it as succinctly as possible, I’d say that the language just needs a lot more polish which would probably happen if it were more mainstream. But not all languages have to be mainstream, and maybe Ocaml’s purpose in the world is, as you put it, to inspire other languages. It is definitely extremely good at that!
No one has said Ocaml yet, so I will. It’s not a perfect language, but it has a lot of cool ideas and concepts. It’s a functional language, but allows you to write imperative code when you want to. Algebraic data types and type matching are built natively into the language and work very nicely. It’s type inference capabilities are very powerful (though that can backfire at times), and the |>
operator is really, really fun to use. It also has very powerful module/functor capabilities, though they go a bit over my head since I haven’t had a chance to play with them. Also, Opam is a very powerful package manager and it’s pretty easy to wrap/bind external libraries with it.
I’d love to see some improvements to the language - the syntax is a bit confusing and ugly at times (but this unfortunately can’t be fixed without breaking the language of course) - but overall I think I’d have a lot more fun programming in Ocaml than what I do in my day job.
My advice would be to learn C first (or at least develop a good understanding of it). It’s extremely important to understand how memory works in C so that you can understand pointers in C++; and also important to understand how functions work so you can understand classes and methods in C++. I would go through The C Programming Language. It’s fairly concise and while you don’t have to go through it cover to cover, you should at least understand the chapters on structs, pointers and functions (up to chapter 6, I believe).
(Note that the wikipedia link that I posted above has a link to the full text of the book in pdf format.)
The reason why I think it’s important to understand C is because when you learn C++, then you’ll understand how the language abstracts over a lot of the lower-level functionality in C. new
in C++ supplants malloc
in C for example, and your understanding of functions in C will map to more complicated concepts like constructors, destructors, copies, methods, and operators in C++. At this point, I would probably start learning how classes in C++ work. They’re basically structs with private member variables and methods defined in the scope of the class. learncpp.com, is the best reference that I’m aware of (it’s very thorough, which makes for a pretty slow read, but you’ll understand it very well). I would probably start with chapter 14 (introduction to classes), and then go back to the earlier chapters to fill in the gaps, but this is more dependent on how you think you learn best.
Be aware though, that if you don’t have existing experience with OO development, then C++ is (in my opinion) not a great language to start learning it, because a lot of it is hacked on top of C and implemented in arcane ways in order to maintain compatibility with C. The first language I learned was Java, and it was really helpful to have that as a background for when I learned C/C++. I’m only familiar with Javascript on a procedural programming level, so I’m not aware of its OO functionality or how well that will translate to C++, but hopefully it works out.
Good luck!
Just use the same creative^W standard accounting practices that all other companies use. Take Google for example… we all know that they don’t pay any taxes, because they don’t earn any positive revenue. Right?
So I’d like to use the same approach. I would not be the one making $1000. That would be my, um, cousin, who just happens to live in Bermuda. HE is the one making all that money, not me! So I don’t have to pay the $680, right?
(By the way, can I also stop paying taxes and be worth a trillion dollars now? No? Why not?!?!)
I’d really like to do some personal projects, both to learn new stuff and scratch my digital itches.
Likewise. There are so many things I’d love to do. Hell, I’d even love to just practice and improve at things that I do in my day job. My current job requires golang and while I’m competent, I’m nowhere near the level of comfort that I want to be. And that’s just the language, there are other libraries, technologies, etc. where I’d like to improve too.
But unfortunately, I have to pace myself. And that basically means I can never do anything computer-related in my spare time. A part of me hopes that some day, I can reduce my hours, or just find a very chill job that still pays decently so I can do more important things in my spare time. But for now, this is the choice that I’ve made.
Personally, I’m just sick and tired of modern UI design. Bring back density, put more information on the screen, eliminate the whitespace, use simple (and native!) widgets, get rid of those fucking sticky headers, and so on.
In addition to all the software freedom stuff, and so on. Also, I wish GPL were more popular too.
Thanks for sharing! How do you feel about the transition from individual contributor to manager? What made you switch? How do you deal with the new responsibilities? How do you deal with the fact that you have to rely on others to get the job done rather than doing it yourself?
Fantastic way to get around firewalls. One of my previous jobs firewalled every server which made developing our network services hell. But they installed an SSH server on pretty much every machine in on the LAN. We got really really good at learning how to set up local port tunnels (even multi-hop ones) to get our work done.
I think what tripped you up here is that you iterated over the wrong object. In your second solution:
for letter in chosen_word:
if guess == letter:
for i in range(len(chosen_word[letter])):
display.insert(i, guess)
while in the correct solution:
for position in range(word_length):
letter = chosen_word[position]
if letter == guess:
display[position] = letter
The most important difference here is that in your code block, you iterate over the letters, ie. 'a', 'a', 'r', ...
, while in the second you iterate over the numerical indices of the string, 0, 1, 2, ...
. In this specific use case, it’s much easier to use the numerical indices - because you can see how the second code block is using position
in two places - once to retrieve the letter from the solution, and then again to update the display when the if
condition matches.
Usually we prefer iteration using the method you used in your solution. But in this case, it’s easier to just iterate by index because you’re retrieving the element from one string, and updating the same position in the other string. You have no way of knowing what position to modify in display
unless you have the numerical position, so it’s much easier to iterate that way in this case.
This is quite cool. I always find it interesting to see how optimization algorithms play games and to see how their habits can change how we would approach the game.
I notice that the AI does some unnatural moves. Humans would usually try to find the safest area on the screen and leave generous amounts of space in their dodges, whereas the AI here seems happy to make minimal motions and cut dodges as closely as possible.
I also wonder if the AI has any concept of time or ability to predict the future. If not, I imagine it could get cornered easily if it dodges into an area where all of its escape routes are about to get closed off.