Warning: Undefined array key "hide_archive_titles" in /home1/smartva9/public_html/smartvania/wp-content/themes/baton/includes/theme-functions.php on line 254

Author: SmartVania

Mars program

Letters

Hello!
I saw your MIPS Tutorial 1 that is uploaded in YOUTUBE.
In that video, you introduce how to download Mars program.
I did your process but when I double click Mars4_5.jar file, it doesn’t work.
java JDK is already downloaded.
I don’t know why this file doesn’t work and what should I do.
Could you tell me the reason and how to execute that file?
Thanks!!

2015-10-15

Hi dear reader,

If you haven’t solved this issue by this time, kindly please contact us at contact@smartvania.com

Sincerely,
SmartVania

Appreciation

Letters

Great doing.keep going and all success.God bless you!

2015-08-16

Thank you so much for the encouragement :).

Sincerely,
Smartvania

MIPS

Hello will you continue to make more MIPS tutorials?

2015-01-14

Yes, we are, now we have an entire series of tutorials of MIPS with 30 videos on Youtube. Click on the Tutorials tab of the menu.

Sincerely,
SmartVania

Hello Yanilda :D from: Gopal

Hello Yanilda,

My name is Gopal, I’m a Mauritius-based Computer Science(Level 1) student at the University of Mauritius.

Umm..actually I’m currently doing a module: Computer Architecture in which we have assembly programming(MIPS)..and when I came by your website and saw all those great tutorials about MIPS..I was I like delighted.

Just wanted to say Thank you for those great tutorials.

2015-02-26

Hello dear Gopal,

I’m happy to see that the assembly tutorials were of your help. Since This website is under construction, we are still adding more content, please stay in tune and thank you for writing to us.

Sincerely,
Yanilda

Assembly help

Letters

Hi,

Love your videos/tutorials on Assembly they’ve helped me a lot over the past couple of days.
But, there’s still many things i quite don’t understand when it comes to assembly language.
I’m trying to compute a program that prints the number of times each element is repeated,
eg) if the user inputs: [1 5 7 5 2 5 3 4 1 9]
The program will print:
1:2
5:3
7:1
2:1
3:1
4:1
9:1

Any help would be appreciated! I am trying to understand Assembly as much as possible.

Greatly appreciated!

2015-03-26

Student

Letters

I’m a student of electrical computer engineering, and now in 5th semester. in this semester we are studying computer organization which has a small parts of MIPS… kindly help me in MIPS basics.
thank you

Hanif

2015-09-19

Dear Hanif,

Thank you for reaching out to us. Please watch the Entire series of the basics for MIPS on Youtube or click on Tutorials >> Assembly language.
Please keep tuned for more content.

Sincerely,
Yanilda

Thank you for your videos

I am teaching comp. organiz. course
i found helpful to understand mars and assembly in no time
merci and grazi and shukran

2015-10-12

You’re Welcome! 🙂 WE are always glad to help.
Sincerely,
SmartVania

Python VS Java from: Raed

Letters

Dear Yanilda,

Hello, I’m Raed and i like programming too, i have some question and i hope you to answer.

1st i like programming a lot, but i have no time to training, so can tell me what’s the best way to learn all thing in programming.

2nd please tell me what’s the best computer language to learn it.

2015-11-08

Dear Raed,

Thank you very much for reaching out to me. I’m glad to know that you love programming.
To become a good programmer, the first thing that you need is motivation, and strength of will. Spend at least 1 hour at day practicing a language. Choose at least one programming language to focus on. It’s always good to be familiar with at least 5 languages but at least there should be one of expertise. One core language and 2 scripting languages could work.
However before programming, or focusing on learning one language, is good to train your brain to think logically. A good program takes a good algorithm and a design after analyzing the situation; no matter what language you know or focus on, writing an algorithm in pseudo code is going to save you tons of brainstorming time, then the code is straight forward.

On the internet there is a lot of resource
My advice: While you are learning code, create a portfolio or a repository where you will upload all your projects that you create, because in that way they will easy to take a look at them when you forget something. Look at other people open source codes and examine them. Finally join Programming newsletters, and forums where you can ask questions.

In terms of which language to learn Python or Java:
It all depends on what is your goal.

Python is fast to program and fun, some people might say “Python is just a scripting language”, but you can actually implement multiple paradigms of programming ( including object-oriented, imperative and functional programming). Also super easy to programs robots with Python. NASA uses Python too. But python is not very secure because is a Dynamic type language, that means that the variables are bind at run time. It’s also a high level programming language. High level programming language are normally easy to learn because they are made common elements like in English.

Java is a high level programming language too! but it’s object oriented programming. Java is the most widely used computer programming; Object oriented programming is better than the old “structure programming” because it focuses on the data instead of focusing on commands. An object is anything that can have attributes(such as color, size, type,…) and classes are lists of actions to perform. Java is the preferred language for meeting many organization’s enterprise programming needs and it’s also the programming language of choice in software for devices that communicate through a network. Java is a General purpose programming language that allows the user to create all kinds of programs from databases to multimedia applications.

My recommendation: There are more job opportunities learning Java programming language, though Python and Java can work by the hand you asked me for one, I’d choose Java. Though python is my favorite language, Java is a statically type language which means variables will be bind at compiler time. Furthermore Java will compile faster.

Sincerely,
Yanilda

Java interview questions

The Toptal Engineering Blog has published a great post called
8 Essential Java Interview Questions” on there you can submit your Java interview questions, answers and hire freelancers,
and they were happy to share with us these questions. If you would like to like them on Facebook click on the link Toptal on Facebook
8 Essential Java Interview Questions
Click on the question to see the answer

The main distinction between fail-fast and fail-safe
iterators is whether or not the collection can be modified while it is being iterated.
Fail-safe iterators allow this; fail-fast iterators do not.


Of the three, LinkedList is generally going to give you the best performance. Here’s why:

ArrayList and
Vector each use an array to store the elements of the list.
As a result, when an element is inserted into (or removed from) the middle of the list, the elements that follow must all be shifted accordingly.
Vector is synchronized, so if a thread-safe implementation is
not needed, it is recommended to use ArrayList rather than Vector.


In Java, Strings are immutable
and are stored in the String pool. What this means is that, once a String is created, it stays in the pool in memory until being garbage collected.
Therefore, even after you’re done processing the string value (e.g., the password), it remains available in memory for an indeterminate period of time thereafter
(again, until being garbage collected) which you have no real control over. Therefore, anyone having access to a memory dump can potentially extract the sensitive data and exploit it.


A single ThreadLocal
instance can store different values for each thread independently. Each thread that accesses the get() or set() method of a
ThreadLocal instance is accessing its own, independently initialized copy of the variable. ThreadLocal i
nstances are typically private static fields in classes that wish to associate state with a thread (e.g., a user ID or transaction ID).
The example below, from the ThreadLocal Javadoc,
generates unique identifiers local to each thread. A thread’s id is assigned the first time it invokes ThreadId.get() and remains unchanged on subsequent calls.

public class ThreadId {
			// Next thread ID to be assigned
			private static final AtomicInteger nextId = new AtomicInteger(0);
				// Thread local variable containing each thread's ID
			private static final ThreadLocal<Integer> threadId =
				new ThreadLocal<Integer>() {
					@Override protected Integer initialValue() {
						return nextId.getAndIncrement();
				}
			};

			// Returns the current thread's unique ID, assigning it if necessary
			public static int get() {
				return threadId.get();
			}
		}
		


In Java, each thread has its own stack, including its own copy of variables it can access.
When the thread is created, it copies the value of all accessible variables into its own stack. The volatile
keyword basically says to the JVM “Warning, this variable may be modified in another Thread”.

In all versions of Java, the volatile keyword guarantees global ordering on reads and writes
to a variable. This implies that every thread accessing a volatile field will read the variable’s current value instead of (potentially) using a cached value.

In Java 5 or later, volatile reads and writes establish a happens-before
relationship, much like acquiring and releasing a mutex.

Using volatile may be faster than a lock, but
it will not work in some situations. The range of situations in which volatile is
effective was expanded in Java 5; in particular, double-checked locking now works correctly.

One common example for using volatile is for a flag to terminate a thread. If you’ve started a thread, and you want to be able to safely interrupt it from a different thread, you can have the thread periodically check a flag (i.e., to stop it, set the flag to true). By making the flag volatile, you can ensure that the thread that is checking its value will see that it has been set to true without even having to use a synchronized block. For example:

public class Foo extends Thread {
		private volatile boolean close = false;
		public void run() {
			while(!close) {
				// do work
			}
		}
		public void close() {
			close = true;
			// interrupt here if needed
		}
	}
	


sleep() is a blocking operation that keeps a hold on the monitor / lock of the shared object for the specified number of milliseconds.

wait(), on the other hand, simply pauses the thread until either (a) the specified number of milliseconds have elapsed or
(b) it receives a desired notification from another thread (whichever is first), without keeping a hold on the monitor/lock of the shared object.

sleep() is most commonly used for polling, or to check for certain results, at a regular interval. wait() is generally used in
multithreaded applications, in conjunction with notify() / notifyAll(), to achieve synchronization and avoid race conditions.


Here is an example of a typical recursive function, computing the arithmetic series 1, 2, 3…N. Notice how the addition is performed after
the function call. For each recursive step, we add another frame to the stack.

public int sumFromOneToN(int n) {
	  if (n < 1) {
		return n;
	  }

	  return n + sumFromOneToN(n - 1);
	}
	

Tail recursion occurs when the recursive call is in the tail position within its enclosing context –
after the function calls itself, it performs no additional work. That is, once the base case is complete,
the solution is apparent. For example:

public int sumFromOneToN(int n, int a) {
	  if (n < 1) {
		return a;
	  }

	  return sumFromOneToN(n - 1, a + n);
	}
	

Here you can see that a plays the role of the accumulator – instead of computing the sum on
the way down the stack, we compute it on the way up, effectively making the return trip unnecessary,
since it stores no additional state and performs no further computation. Once we hit the base case, the work is done – below is that same function, “unrolled”.

public int sumFromOneToN(int n) {
	  int a = 0;

	  while(n > 0) {
		a += n--;
	  }
	  
	  return a;
	}
	

Many functional languages natively support tail call optimization, however the JVM does not. In order
to implement recursive functions in Java, we need to be aware of this limitation to avoid
StackOverflowErrors. In Java, iteration is almost universally preferred to recursion.


This can be done using Thread.UncaughtExceptionHandler.

Here’s a simple example:

// create our uncaught exception handler
	Thread.UncaughtExceptionHandler handler = new Thread.UncaughtExceptionHandler() {
		public void uncaughtException(Thread th, Throwable ex) {
			System.out.println("Uncaught exception: " + ex);
		}
	};

	// create another thread
	Thread otherThread = new Thread() {
		public void run() {
			System.out.println("Sleeping ...");
			try {
				Thread.sleep(1000);
			} catch (InterruptedException e) {
				System.out.println("Interrupted.");
			}
			System.out.println("Throwing exception ...");
			throw new RuntimeException();
		}
	};

	// set our uncaught exception handler as the one to be used when the new thread
	// throws an uncaught exception
	otherThread.setUncaughtExceptionHandler(handler);

	// start the other thread - our uncaught exception handler will be invoked when
	// the other thread throws an uncaught exception
	otherThread.start();
	

The Wizard of Oz

I have seen this 1939 classic, The Wizard of Oz countless number of times growing up, and now here in my early stages of adulthood. Despite that fact, the magic the film has never lessens its hold on me. In fact each time I see it, it grows more magical as I appreciate the film even more and more. This is one of those few films that can successfully be handed down from generation to generation. People of all ages loved this magical film since its release in 1939, arguably one of the greatest years in movie history. This adventure story has themes that all children can relate to. Every child has a need for adventure and to discover the world beyond their homes and families. But the movie also shows the world is not always a happy world, as evil can persist beyond the comfort of your home. Other prevalent themes include helping others find a path, and helping others see who they truly are. The movie is good at making symbolisms. For example, Toto (Dorothy’s dog) is a symbol for comfort. As children tend to find comfort in pets. If you take the symbolism and the themes away, you are left with a simple adventure story full of heart, wisdom, and most importantly magic.

Before I discuss my opinion of the film even further, let’s talk about the basic plot of the film. Dorothy (Judy Garland) lives at a Kansas farm with her faithful dog companion Toto, and her Auntie Em (Clara Blandick) and Uncle Henry (Charley Grapewin). However, a tornado strikes the farm and somehow transports Dorothy and Toto to a far-away magical land of Oz. When she lands in Oz, she immediately meets the Munchkins: a group of small people, and Glinda, a good witch (Billie Burke). They claim that her landing accidentally killed the Wicked Witch of the East, which is caused for celebration. Now Dorothy wants to go home, but Glinda tells her about the Wicked Witch of the West (played beautifully by Margaret Hamilton). In order to go back to Kansas, Dorothy must travel on the Yellow Brick Road towards Emerald City, where the Wizard may be able to grant her wish. Along the way, she meets new pals such as the Scarecrow (Ray Bolger), The Cowardly Lion (Bert Lahr), and the Tin Man (Jack Haley), and enemies such as the forementioned Wicked Witch of the West.

I absolutely love the story and the themes, but I admire the technical side of the film. Keep in mind that this film is almost eighty years old, so it’s amazing how the visual effects hold up fairly well by today’s standards. The tornado looks very real, and one of the most memorable scene is inside the tornado as Dorothy is being whisked away to Oz. We see images pop outside her window, and it looks so realistic. I also loved the transition of color in the film. The film starts out black-and-white, but once we land in Oz, vibrant colors adorn everyone and everything, which I find to be a symbol for happiness because she’s away from home. I may have had more issues with the costume design. It is plainly obvious how fake the Cowardly Lion’s suit is, and how awkward the makeup is on the Tin Man. But this was back in 1939, long before the days of CGI.

This movie is also accompanied by wonderful music, bolstered by great songs including the Oscar-winning song, “Somewhere over the Rainbow.” It’s a song that routinely plays in my mind because it is such a great song. There are other recognizable songs such as “If I Had a Heart.”

Believe it or not, this film suffered through many production problems ranging from Margaret Hamilton being severely burned to Toto being out of commission for several weeks because he was stepped on. Also, Jack Haley wasn’t the first choice to play the Tin Man. He only got the role because the actor who originally had the part suffered severe allergies to the makeup. There were many more issues the film had while in production. So that attains to the talent of those who put together this film and kept the magic intact.

As for the acting, everyone does a fantastic job. The cast was relatively unknown at the time, with the exception for Judy Garland. She was already a bona fide star, but this film propelled her to superstardom. She does an amazing job in the iconic role as Dorothy. Another standout was Margaret Hamilton as the Wicked Witch of the West. It’s a known fact that many scenes with her in them were cut because here performance was felt to be too scary for kids. Despite all the cuts, her performance was magnificent and even today, her performance still creeps me out. But on the whole, everyone should be applauded because they did such a great job.

Overall, The Wizard of Oz is a timeless classic that will live on for ages and ages. It is not my favorite film of all time, but I am very appreciative of the film and how instrumental it is in cinema history. Bolstered by a wonderful story, great acting, memorable songs, and a colorful production design, this film is a great film from the early days of cinema. The themes are also timeless. But it also shows that while adventures are fun, “there’s no place like home.”

My Grade: A