Tumgik
Photo
Tumblr media
The realities of science. [Via drewtoothpaste]
544 notes · View notes
Text
Book Review: The Rust Programming Language
I haven’t been posting as often as I should, but I was trying to find a good topic to write about this time, since I’ve covered pretty much all I can for some introductory content. Today I’m going to review the Rustlang Docs, otherwise known as “the Book”.
To start off with, I’m going to state my opinion that it isn’t a very good book for those who have no understanding of Rust. It covers very simple syntax such as variable assignment, if statements, for statements, and even match statements. But after that, it decides to delve down a path far more confusing than it should.
Now, I myself love a good explanation of pointers and references. However, Rust is a very quirky language, and so pointers and references act very differently in it (or rather, how you have to deal with them) as opposed to languages like C and C++. For instance, dynamic memory in C and C++ with malloc() or new. Those concepts don’t exist in Rust, same with the famous delete() function. Instead, Rust will automatically create memory for the Object on the Heap, and when you pass it to functions it’ll behave similar to a reference (more on that in a bit).
So your question then should become: “How do I handle memory management in Rust?”. Simply put, everything gets deleted as it comes out of scope. So if I write code, for instance, like this:
fn object_copier(&Object obj) -> &Object {
    Object obj2;
    // Some code here that copies the values of obj to obj2
   // in Rust the final return statement is just the name of the variable you wish      // to return
    obj2
}
Object obj = Object::new();
obj = object_copier(&obj);
I get an error because the memory of obj2 is deleted as soon as it is destroyed from scope. Now Rust has something called “Traits” which aid in trying to do copies like the one I attempted to do above. However, you can see how certain aspects of Rust are pretty complicated for people who are trying to jump from languages like C and C++ over to Rust.
Now this is the point where the Book and I part ways. The Book tries to explain the concept of Pointers, References, and the Ownership concept (this involves memory, where you can’t have more than one mutable (changeable) reference to a pointer) before it goes into things like Structs, Annotations, Enums, or Generic Types. While this is moreso a matter of preference to me, it seems that they placed a rather complex and difficult subject before some of the more interesting parts of the language. It almost makes you want to quit on the language because, well, it’s just frustrating to try and understand a part of the language only to find out you will likely not need it for a large part of your start in Rust, and that the book will come back to those concepts when trying to explain things such as Enums and Structs.
I instead recommend two other books to read whilst trying to get a good grasp of Rust: Rust By Example, and Rust Essentials. I’ll drop links to the Book, Rust By Example, and Rust Essentials below. Thanks for reading.
The Book: https://doc.rust-lang.org/book/
Rust By Example: https://rustbyexample.com/cast.html
Rust Essentials: http://marge.zackburns.com/zackburns.com/files/public/Books/PacktPublishing/ToKeepOrNotToKeep/Rust%20Essentials.pdf
2 notes · View notes
Text
Why more women aren’t programmers, and why we need them.
According to the most recent Stack Overflow survey, about 92% of programmers are men, while a meager 5.8% were women. This post is going to explain the disparity involved, stereotypes, sexism in the industry, and why more women are needed as programmers.
So the first and most obvious part is sexism in the workforce. In a strictly male dominated field, there are going to be certain things that are believed or certain stereotypes regarding members of the opposite gender that permeate. But the bigger question here is why such stereotypes exist. Now many people will just state “bigotry” and how “bad men are” and all that noise, but that’s the easy, and unfortunately not so true answer. I will be the first to admit that men can be total and complete douchebags, but at the same time it is very hard for men to adapt in a predominately male field. As such, there are certain tolerances that women will have to make in that field. For instance, we have to stop looking at it as a “Male Engineer” or a “Female Engineer”. That will only cause a schism between the two genders in the workforce. Women should not be demanded to be treated differently based off of their gender. For instance, I recently read a post here on Tumblr regarding the term “Man Hours” to describe overtime in a large scale. This is a perfect example of certain things women will have to tolerate. You can think of it as you are the newcomer in a long existed field. It is unreasonable to expect certain people to behave a different way just because you are of a certain gender. If you do your job and you do it well, your gender shouldn’t ever matter.
Now with that out of the way, the second part is why many women aren’t exposed to backgrounds such as engineering, computer science, and math. The simple answer is societal norms that have been longstanding since the 50′s and need to change. With the advent of the Baby Boomers, many adult women are going to have been raised in an environment where gender roles were an established, proper part of the hierarchy of society. We as the millennials have to break that mold, and the sad fact remains that many people who believe in rigid gender roles may be someone’s boss, parent, or coworker. We as a generation have to overcome such hurdles in order for progress. And this, too, means that parents need to expose their children to things as much as possible. I feel that peer pressure due to upbringing have a much larger impact on people’s interest than potential institutionalized sexism. If we can first overcome that issue, you’ll see sexism in the industry slowly go away. There’s no immediate solution to this problem, and I believe it will take a lot of change within ourselves as humans before we can have a near equal field.
But more importantly is why we NEED female programmers. The obvious answer is that it brings in a more diverse field. We all know that diversifying a programming team can bring huge strides to the technology field (think Open Source). And I think it is a bit sad that in developing countries (such as India), women are more likely to be programmers (Asian countries like South Korea are also included, even though it’s not a Second World Country). 
Women are important to the world (they make up about 49% of the population after all). 
2 notes · View notes
Text
If you’re learning Java as a first programming language, try learning another programming language with it
TLDR; Try your hardest to learn another language alongside Java via the internet like Python or basic C syntax, just so that way you don’t get discouraged by the initial complexity of Java or the initial learning curve associated with OOP.
Alright so as the title of the post suggests, if you’re a new CS student at whatever University or College you’re attending you’ll probably learn Java as a first language. Java’s a great language for stack developers or people that have to actively work with SQL or anything related to servers. But it’s a really piss-poor language to learn with, and here’s why.
1) It forces Object Orientation:
I myself recall my first ever CS class: AP Computer Science. I was in the class with a lot of people much smarter than me when it came to Math and Science, and who were just generally more clever than I. However, our first language was unfortunately Java. The poor kids were forced day one into trying to understand a rather complex topic of Computer Science. A few dropped out and their dreams of becoming programmers halted; all because they weren’t properly exposed to the rest of the programming industry.
2) Java is very verbose and just confuses the shit out of people:
Now this topic is a bit funny because I really like Rust and C++ as programming languages and they’re similar in this regard. But the matter still stands. A lot of people are going to find that trying to follow Java code is somewhat difficult, which is due mostly to Object Orientation. For instance, every function has to be declared within a class: if you want to group a certain type of functions together in a package, they have to be in a class file and made static. Coming from languages like Rust, C++, and Python, this is a really stupid way to behave.  
3) Java code can be pretty hard to read:
I touched on this with reason 2, but there are other reasons as well as to why. There’s an opinion among certain developers that Object Orientation is very forgiving when it comes to coding style. I happen to agree with this opinion, and I will be using it for this post. Object Orientation itself isn’t a problem if you have a well trained, motivated individual who tries to focus good programming style. Unfortunately, everyone has bad programming style at times, and you can see it in large programs or open source software. Java, which was (and still is for the most part) taught as a primary starting language for students, forces Object Orientation on students. So, many people will want to try writing programs that test their skill and ability, mixing in their terrible coding styles (after all, we all need to learn by doing, right?). This leaves a huge codebase for people to learn Java from, but at the same time most of it is illegible and just plain terrible. No language is free from the curse of spaghetti code, and it seems that many up and coming Java developers find it very, very easy to write spaghetti code
4) Java is not general purpose:
I understand full and well that Java has a lot of built in functions that allow for general purpose programming (built in JFrames, etc etc) and has all the fun bloat associated with those features. However, it isn’t a proper indicator of what the industry uses as general purpose. Something like Python is used far more for “General Purpose” programming needs. 
In summary, Java holds a close place next to my heart, as well as the hearts of many developers. However, from a pure “Just getting started” mindset, go learn another language on the side. It doesn’t do you any justice if a complex subject of programming discourages you to the point of not wanting to program anymore.
1 note · View note
Text
Why C++ made me a shittier Java programmer
Before I get into the meat of why I’m so bad at what I do, I’d first like to list this disclaimer: I’m NOT saying C++ makes everyone shitty Java programmer, but if you learned Java as a first language I feel bad for you.
Okay so my first programming language ever was Java and hoo boy let me tell you: it had all these nice bells and whistles; no pointers or references, and did automatic garbage collection. That shit was the bomb. But eventually I realized that I’d need to step off from my sheltered box and expand the programming world. I experimented with Python and JavaScript, and did some okay work with web programming. But then my interest turned to systems. Which means we’ve got either two options: the big C or C++. Frightened like a child about to be scolded for breaking the dishes instead of cleaning them, I stumbled along with whatever web-based learning I could find. Scouring the internet for days at a time, I finally got comfortable enough in C++ to get the way the language is supposed to operate.
Now this is where the shit got tricky for me. Once I understood and valued the need for explicit pointers and references, I switched back to Java because I decided to go back to being a child and work on doing some programming for a Minecraft server. Much to my dismay, as soon as I hit objects and passing variables to functions that required me to either A) change the value of an object passed to the function or B) make a reference to or copy an object, I came to a loss. 
Now naturally after about a week I got a hold of my Java roots again, but I think it’s important enough to make a blog post about the struggle: I will never go back to Java again (except for SQL work or some bullshit netcode, but even then I have C#). I was reading a book by Bryan Lunduke titled “Why Linux is Badass” and he equates Macbook users (sorry 97% of this site) to that wealthy kid that had everything done for him. Of course he comes to the conclusion that such a child is boring and, to be honest, I quite agree.
There is nothing more boring than not using g++ (or clang) at a compiler and not flipping your shit when you made an error 300 lines ago that you can’t fix. Sure it takes a long time (like a LONG time) to write the same value of code in C++ than Java, but that’s half the fun. I’m not going to sit down and lecture you on the difference in runtime speed, or the Write Once, Run Anywhere concept because that, too, is boring (plus I’ve used up a lot of your time with this shitty post). So case in point: for me, C++ not only made me a shittier Java programmer, but it also made me fucking open my eyes to the world around me and realize that, no, Java is not the end all, be all language and; as a general programming language, Java can be kind of shitty for all the wrong reasons.
1 note · View note