Boolean b = null;
if(b) System.out.println(“I am using a sane language”);
result in a NullPointerException? Either it’s a fucking boolean or it isn’t. If it is, make null falsey. If it isn’t, don’t compile the goddamn code. I keep trying to use Boolean in classes when I need a distinction between null and false, then rediscovering why it’s a bad idea. Why would I ever use Boolean anywhere if this is how it works? Because I really enjoy maximising the opportunities for runtime errors in my code?
But falsey would be nice to have you say? Strongly typed languages can be frustrating, and still lead to runtime errors you say?
How about if I told you about a language where you never had to worry about these things, and while the only thing between you and runtime errors is your skill to keep things organized and sensible as a developer, if you can manage this - your speed to crank out new features will be reduced by half, 2/3, or more? Is that something you’d be interested in?
Oh yeah - testing w/o types is a million times easier.
And in like 10 years of node development I can’t think of a single runtime error that caused any major issues which would have been caught at compile time. But auto-complete is really nice.
And it’s almost a killer feature to be able to spit out all the properties of a settings object in the IDE - which originates in a 3rd party lib, then can be layered on with new properties added in a local lib which is shared among several apps, then layered on again in the actual app. Almost. But still not worth typescript imo. Bleh.
Or I could just use C#, have it refuse to compile the above, and spend 0.1 seconds changing it to:
bool? b = null;
if(b ?? true) Console.WriteLine(“I am using a sane language”);
The problem with Java there isn’t strong typing, it’s a failure to insist that the typing rules are followed. The if statement requires a boolean, I haven’t provided one, and it’s like “oh that’s cool I trust you, it’ll be a boolean at runtime I’m sure”.
You know where C# gets falsey from, and async/await, and var, and native JSON support, and a lot of the good stuff that makes it better than Java? I bet you do.
Isn’t the problem that a null Boolean type is perfectly valid but if (null) is not? Java I guess is counting on you to make sure it’s populated with a valid value before you try to do anything with it. Also can you just use the primitive lower case boolean? I don’t think that can ever be null.
But it’s been a long time so I could be off. Java gets really weird between Integer and int. I remember basically just avoiding the upper case stuff as much as possible.
C# has no falsiness - the point of the above is that it absolutely insists on a real bool for the if statement, but that syntactically it’s a breeze to give it to it. I will say that nullable primitives were a bit more of a pain to use before the ?? operator was introduced. “var” is just syntactic sugar, everything declared with var is still strongly typed.
I don’t want to use the primitive boolean because the whole nature of what I want is something that distinguishes between “true”, “false”, and “unknown”.
All of Java’s unboxing stuff was a colossally bad idea.
Edit: The problem with using Boolean is that even if you do write the code correctly, there is no alternative to like:
Boolean b = someBoolean();
if(b != null && b) { … }
or
if(Boolean.TRUE.equals(b)) { … }
It’s painfully verbose. You can’t even write:
if(b == true) { … }
Because then Java tries to coerce b to a primitive boolean, and if it’s null, it isn’t one, so it again throws a NullPointerException here. They tried to make syntax easier by breaking their type-checking rules instead of just providing better syntax.
Are there tons of different apps all running in one big C++ app server (I’m assuming like Weblogic as a Java app server since I don’t know much about C++ runtimes)
I like your idea of independently monitoring. I used to have that with node and it came in really handy when we had performance issues - as splunk lagged by a few minutes and was less fine-grained. But it involved putting some hooks inside the app that fired an event at the beginning and end of each piece of middleware. Sounds like you may not be able to get into the app like that. But if you can identify log events that signify the beginning and end of certain features you could come up with a similar real-time dashboard type thing, and maybe have some alarm that tells you to look at it when you get a load-shedding event.
Can any code running on the server create one of these request locks like the log code did?
That seems like a leak if so. One thing I like about node is by design it’s basically impossible to do stuff like this. Although of course if you need transactions for some reason it’s not the right solution. But there might be a way to block locking code by design somehow if it’s not really needed. Or at least scan for it I guess.
We had an issue where somehow a field in JSP was wired up to a piece of data in Oracle, which by some screwup was causing a brief lock on the data (programmed by an offshore dev of course with poor oversight on our end). But unfortunately that JSP widget appeared like 20 times on the home page. So when we got hit with NFL traffic it crashed Oracle, and people couldn’t log on to the site to stream their NFL games = very pissed off customers. It took Oracle sending in a tiger team to figure out what we were doing wrong.
Yes but you literally have to do something you’re never supposed to do with node for that to happen. Any driver to retrieve data or anything else is asynchronous. I’m not even sure how you could pause the thread with a synchronous call that waits. You’d almost have to hack deep into the node core to do it.
What can happen is if you have intense calculations that take like a second to run. Those are supposed to be avoided of course.
We once had some code that initialized moment-timezone, a very heavy package, 57 times inside a loop when it didn’t need to be. I noticed from my middleware timers that one piece, which I knew didn’t make any asynchronous calls out to get data, was taking 2 seconds. I moved it out of the loop and problem solved.
We had a similar problem – 10 seconds of slowdowns in the db very infrequently. Our team has some fragile code – the snowball effect of that 10 second delay was large. It took us a couple months to root cause it.
Along the way I contributed “it’s like the db has a global lock which is held for 10 seconds”. The db is meant to be horizontally scalable (we have hundreds of nodes). It isn’t supposed to have any global locks. So saying it did was a big claim, denied by the db team.
The next discovery was it only happened on certain production machines. Then it was possible to pinpoint a single change in the custom kernel. Who knew we had completely custom machines? Some intern had made a change which held a lock for no good reason, freezing the machines for 10 seconds every N hours. The db has a global lock which ordinarily is held for 0 time, but 0 turned into 10 seconds when the machine froze.
Multiple teams were affected – not just from db usage – and found their way to the bug. It’s very tough to diagnose when the trouble isn’t your code, and is actually many layers away.
The costs of this bug are fun to estimate. It’s a lot. The skill in debugging is also impressive. People would find the right clue and the right person on the next team to follow the lead. Nobody could solve it alone.
My web app and site was a success and is live and being used currently. The big hurdle I had to get over is the absurdly low rate limit bitbucket api. Not a big fan of bitbucket after this. Github is way better.
Also I discovered split screen in vim today and i think it’s changed my life
I’m not sure if this is appropriate for the thread but I have started learning to code from home. I’m only 4 hours into it but Code Academy continues to advertise for me to upgrade to their “Pro” edition.
Has anyone used Code Academy and feel like it’s worth it? If not, why and have you tried another online tool like Tree House.
I am leaning towards learning Python and/or SQL if that makes a difference.
I dont have experience with codeacademy, but I recommend spending $10 on a course on udemy. There’s a ton of beginner courses on different languages. Do one for python - it’s a good language and can get you building real things very quickly. Get a course that has you actually build something you care a little about, like a game or web server.
Keep in mind though python is not a statically typed language, which most of the older languages are. you also won’t really learn a lot of basics like how pointers and memory work. But for beginning and being able to build something very quickly on your own, I love the language.
I just wrote a python application though so I’m a little biased. I fell in love with it completely.
After you’ve mastered the syntax and control flow and are comfortable with stuff like manipulating lists and strings move on to some of the challenge sites like hackerrank and solve the puzzles on there. That will prepare you for real world interviews if you care about that.