• Hey, guest user. Hope you're enjoying NeoGAF! Have you considered registering for an account? Come join us and add your take to the daily discourse.

Programming |OT| C is better than C++! No, C++ is better than C

mltplkxr

Member
I feel like buying a few new books:

Steve McConnell: Code Complete: A Practical Handbook of Software Construction
Apparently, this one is included in pretty much every "Books every Software Developer/Engineer/Programmer/... should read" list.

Bill Karwin: SQL Antipatterns: Avoiding the Pitfalls of Database Programming
Someone mentioned this one in a Stack Overflow answer. Sounds like an interesting read.

Martin Fowler: Patterns of Enterprise Application Architecture
I can't remember how this ended up in my shopping basket, but I do remember that it was recommended in a university lecture I'm attending this semester.

Cay S. Horstmann: Java SE 8 for the Really Impatient
Any opinions on this one? I'm mainly working with Java at university, but I'm ashamed to admit that I've kinda never bothered to check out SE 8. I know that there are lambda expressions and streams, but I've never had a closer look.

All great books.

I think you meant Code Complete 2? Great book. In the same vein, The Pragmatic Programmer is essential too.

SQL Antipatterns is excellent. It helped me to understand how to correctly translate OO concepts to databases. The format is also really instructive: For each antipattern, an explanation of why it's bad, when it's ok, alternatives and an illustration of both the modeling and querying.

Patterns of EAA is a good reference. If you do Java EE, you are already implementing the patterns if you follow good practices. Still, it's Fowler and it's essential reading.

Haven't read the Java 8 book (or any!) but Horstman's Java 2 (1.2!) book is the first Java book I ever read and it made me a fan.

If you still haven't read it: Effective Java is one of the best Java books of all time.

Right now I'm reading through Java Performance: The Definitive Guide, which is one of the best Java books I've read in a long time.
 

Two Words

Member
What's your guys' experience with dealing with TAs that take off 5-10 points off your project grade due to trivial stuff? My last project got a 95/100 even though it works perfectly. I missed 3 points due to organization and 2 points due to comments. This is a CS1 class, but not a fundamentals CS course.

Now, I don't think it is a good idea for me to post all my code, and I'm sure nobody wants to read through a few hundred lines, so just take what I'm saying as a given and respond on that.

My project was organized and commented well. I'm not going to pretend that I came up with the most efficient and organized method for this program, but it was a method that was very clear and did not take needless steps. My comments were also very clear, and anybody reading it would understand exactly what the program is doing at all times. They perfectly follow what the professor said to do. Other students got 100s ,and they even admit that their code was not as efficient or organized as mine. This is the second project in a row where I feel the same TA is playing free with the top few points on my grade.


So is this a common problem with CS classes?
 
It's not clear to me, what kind of window opens. Are we sure it's not just some modal dialog on the webpage? Before knowing exactly what happens, I wouldn't dismiss Selenium just yet.

Yeah, as long as it's a browser window with HTML in it, Selenium is fine. Anything from a third party plugin though and you're boned. (Flash, Java, whatever else)
 

Tan

Member
What's your guys' experience with dealing with TAs that take off 5-10 points off your project grade due to trivial stuff? My last project got a 95/100 even though it works perfectly. I missed 3 points due to organization and 2 points due to comments. This is a CS1 class, but not a fundamentals CS course.

Now, I don't think it is a good idea for me to post all my code, and I'm sure nobody wants to read through a few hundred lines, so just take what I'm saying as a given and respond on that.

My project was organized and commented well. I'm not going to pretend that I came up with the most efficient and organized method for this program, but it was a method that was very clear and did not take needless steps. My comments were also very clear, and anybody reading it would understand exactly what the program is doing at all times. They perfectly follow what the professor said to do. Other students got 100s ,and they even admit that their code was not as efficient or organized as mine. This is the second project in a row where I feel the same TA is playing free with the top few points on my grade.


So is this a common problem with CS classes?

I'm actually often frustrated when TAs grade purely on 'does it work.' Design, organization and good comments/variable/function names are super important. But I don't know what to say if you're saying you did all that stuff well too.
 

Massa

Member
Anyone familiar with Smalltalk + Squeak?

Just on the week of Bloodbornes release my prof drops a java assignment and small talk, and we just started learning small talk a week ago ;_;. I'm working on my java assignment and I'm sure I'll get that done, but just preemptively asking about smalltalk because it honestly intimidates me, I've never used a non imperative language. The assignment in question is a tic tac toe game with a gui + an AI that always results in a draw.

I could do this easily enough in java but I barely have an idea of how to even start a gui in smalltalk (we went over a quinto example in class). Any comprehensive (free) online resources for small talk and how to make a game similar so I could study it?

Squeak is great, very fun to use. Play around in a workspace, inspect and explore objects as you will. It seems very weird at first but you'll get the hang of it in no time.
 

Two Words

Member
I'm actually often frustrated when TAs grade purely on 'does it work.' Design, organization and good comments/variable/function names are super important. But I don't know what to say if you're saying you did all that stuff well too.
Well, I'm not going to act like I did it the most efficient way ever. I'm sure there are algorithms that simplify my code. But there wasn't anything unorganized or heinously inefficient in my program. And our course does not teach optimization. Ultimately, I feel like I'm losing points simply because it feels like the TA probably thought of a better way to handle the problem. But to me, it seems unfair to lock away the 100% score for only if you make everything perfect in efficiency.
 

tokkun

Member
What's your guys' experience with dealing with TAs that take off 5-10 points off your project grade due to trivial stuff? My last project got a 95/100 even though it works perfectly. I missed 3 points due to organization and 2 points due to comments. This is a CS1 class, but not a fundamentals CS course.

Now, I don't think it is a good idea for me to post all my code, and I'm sure nobody wants to read through a few hundred lines, so just take what I'm saying as a given and respond on that.

My project was organized and commented well. I'm not going to pretend that I came up with the most efficient and organized method for this program, but it was a method that was very clear and did not take needless steps. My comments were also very clear, and anybody reading it would understand exactly what the program is doing at all times. They perfectly follow what the professor said to do. Other students got 100s ,and they even admit that their code was not as efficient or organized as mine. This is the second project in a row where I feel the same TA is playing free with the top few points on my grade.


So is this a common problem with CS classes?

I can give you two pieces of advice that every CS student ought to learn early but most don't.

1. Try to grow a thick skin about criticism of your code. What you are experiencing will follow you into industry if you work at a company that does code reviews (i.e. any company worth its salt that is bigger than a startup). Sometimes criticism will be valid, but just as often people are going to nitpick your code and tell you to do stuff a different way based on their preference, even when it is not strictly better. Learning to conform to the style your TA wants is good practice for doing the same thing with your team lead on the job.

2. Whatever you do, don't try to argue with your instructors over a couple of lost points. It is not worth it. A 95/100 is barely different from a 100/100 in the grand scheme of things, and you do not want to risk giving your instructors a bad opinion of you. If you want feedback about why you lost points, frame it as if you are asking for their advice on how to improve rather than challenging their judgment. Probably the biggest mistake students make is not using a class as an opportunity to network, especially with their instructors. Some day you may want a letter of recommendation or a referral for an internship and keeping positive relationships with your professors and TAs can pay off big time. Obviously this piece of advice applies to life after college as well.
 

leroidys

Member
What's your guys' experience with dealing with TAs that take off 5-10 points off your project grade due to trivial stuff? My last project got a 95/100 even though it works perfectly. I missed 3 points due to organization and 2 points due to comments. This is a CS1 class, but not a fundamentals CS course.

Now, I don't think it is a good idea for me to post all my code, and I'm sure nobody wants to read through a few hundred lines, so just take what I'm saying as a given and respond on that.

My project was organized and commented well. I'm not going to pretend that I came up with the most efficient and organized method for this program, but it was a method that was very clear and did not take needless steps. My comments were also very clear, and anybody reading it would understand exactly what the program is doing at all times. They perfectly follow what the professor said to do. Other students got 100s ,and they even admit that their code was not as efficient or organized as mine. This is the second project in a row where I feel the same TA is playing free with the top few points on my grade.


So is this a common problem with CS classes?

Good design and readable code is essentially equal in importance with "does it work" in industry, so I think this is fine, as long as it's not totally trivial shit.
 

Two Words

Member
I can give you two pieces of advice that every CS student ought to learn early but most don't.

1. Try to grow a thick skin about criticism of your code. What you are experiencing will follow you into industry if you work at a company that does code reviews (i.e. any company worth its salt that is bigger than a startup). Sometimes criticism will be valid, but just as often people are going to nitpick your code and tell you to do stuff a different way based on their preference, even when it is not strictly better. Learning to conform to the style your TA wants is good practice for doing the same thing with your team lead on the job.

2. Whatever you do, don't try to argue with your instructors over a couple of lost points. It is not worth it. A 95/100 is barely different from a 100/100 in the grand scheme of things, and you do not want to risk giving your instructors a bad opinion of you. If you want feedback about why you lost points, frame it as if you are asking for their advice on how to improve rather than challenging their judgment. Probably the biggest mistake students make is not using a class as an opportunity to network, especially with their instructors. Some day you may want a letter of recommendation or a referral for an internship and keeping positive relationships with your professors and TAs can pay off big time. Obviously this piece of advice applies to life after college as well.

My issue is that the TA doesn't give any feedback on why it is supposedly inefficient or unorganized. I've missed points for comments supposedly being incomplete because my comments do not explain why I am doing something (ie explaining the program's overall design logic) when the grading rubric just says to explain what the code is doing. These programs are not very complex and there isn't much to be lost as far as efficiency goes.

To quickly explain the logic, the program is the Game of Life program. It's a dyamic character array that contains spaces and *s. A * is a bacteria. There is a ruleset on what makes bacteria die and respawn. The bacteria are displayed and stored like a 2D grid. There are 3 cases: corners, sides, and middle. I determine the case with a conditional statement to determine how to evaluate that bacteria, and do the simulation accordingly. There really isn't much there that can be inefficient. I'm looking over the code now and it's pretty damn straight forward.

I understand that grading efficiency and organization matters, but it feels like part of our grade is just up to preference that is never being communicated. Write the program and hope the TA likes it that way. That sort of thing.


And getting an A in a class requires you to get As on assignments. The tests in this class are made to be pretty tough. 5 points off a project is not trivial. Getting an A in any class gives you a low margin for error. Needless points being docked makes the margins needlessly slimmer.
 

Slavik81

Member
What's your guys' experience with dealing with TAs that take off 5-10 points off your project grade due to trivial stuff? My last project got a 95/100 even though it works perfectly. I missed 3 points due to organization and 2 points due to comments. This is a CS1 class, but not a fundamentals CS course.

Now, I don't think it is a good idea for me to post all my code, and I'm sure nobody wants to read through a few hundred lines, so just take what I'm saying as a given and respond on that.

My project was organized and commented well. I'm not going to pretend that I came up with the most efficient and organized method for this program, but it was a method that was very clear and did not take needless steps. My comments were also very clear, and anybody reading it would understand exactly what the program is doing at all times. They perfectly follow what the professor said to do. Other students got 100s ,and they even admit that their code was not as efficient or organized as mine. This is the second project in a row where I feel the same TA is playing free with the top few points on my grade.


So is this a common problem with CS classes?
I'm a TA, and I'd be able to tell you exactly why I removed marks if you didn't understand. They should be able to justify why you received the grade you did. You may learn something from asking.

That said, 5% on an assignment is nothing. I wouldn't worry too much about the marks.
 

Two Words

Member
I'm a TA, and I'd be able to tell you exactly why I removed marks if you didn't understand. They should be able to justify why you received the grade you did. You may learn something from asking.

That said, 5% on an assignment is nothing. I wouldn't worry too much about the marks.
Are you saying you want to review it?


Edit- Nevermind, read it wrong the first time.
 

Mr.Mike

Member
So can anyone explain what is meant when it's said a new graphics API will let devs get "closer to the metal"? I'm guessing it's greater control over memory management or somehow greater support for Assembly. But I suspect it might just be a marketing buzzword for a more performant API.
 

Two Words

Member
So can anyone explain what is meant when it's said a new graphics API will let devs get "closer to the metal"? I'm guessing it's greater control over memory management or somehow greater support for Assembly. But I suspect it might just be a marketing buzzword for a more performant API.
I guess you could compare it to manually deleting in C/C++ vs automatic garbage collection in Java. Manual is more efficient, but adds another layer of complexity for the programmer.
 
So can anyone explain what is meant when it's said a new graphics API will let devs get "closer to the metal"? I'm guessing it's greater control over memory management or somehow greater support for Assembly. But I suspect it might just be a marketing buzzword for a more performant API.
So... the details get complicated, but the gist is that DirectX and OpenGL both try to help make things easier for normal rendering by adding many programming constructs and abstractions for doing graphics programming.

But those abstractions are arbitrary, and they make everything else harder. And as it turns out, where gaming is concerned, "everything else" is almost everything. That is, game engines have been fighting a weird battle where the graphics APIs are trying help, but mostly getting in the way.

So when it's said that Vulkan gets "closer to the metal", the hope (and expectation, given who designed the standard) is that it will be getting out of the way this time, the way APIs should.
 
So... the details get complicated, but the gist is that DirectX and OpenGL both try to help make things easier for normal rendering by adding many programming constructs and abstractions for doing graphics programming.

But those abstractions are arbitrary, and they make everything else harder. And as it turns out, where gaming is concerned, "everything else" is almost everything. That is, game engines have been fighting a weird battle where the graphics APIs are trying help, but mostly getting in the way.

So when it's said that Vulkan gets "closer to the metal", the hope (and expectation, given who designed the standard) is that it will be getting out of the way this time, the way APIs should.

I wouldn't go quite that far. Graphics APIs help far and away more than they get in the way. There are just very rare, occasional instances where a developer wants to optimize something a very specific way and it can be hard to do with high level APIs. No matter how close to the metal the APIs allow, 99% of a game isn't going to make use of it or care because it's more trouble than it's worth
 
DirectX and OpenGL help in that they're better than nothing. So of course they're used for "99%", it's the only way to make anything work across different graphics hardware.

Doesn't mean they don't suck at what they do. Hence Mantle, Vulkan, ...
 
DirectX and OpenGL help in that they're better than nothing. So of course they're used for "99%", it's the only way to make anything work across different graphics hardware.

Doesn't mean they don't suck at what they do. Hence Mantle, Vulkan, ...

"What they do" is provide an abstraction over graphics hardware and driver differences. I think it's quite a stretch to say it sucks at that. They are *amazing* at what they do. And Mantle is basically dead, I don't think that's a very good example
 
"What they do" is provide an abstraction over graphics hardware and driver differences. I think it's quite a stretch to say it sucks at that. They are *amazing* at what they do. And Mantle is basically dead, I don't think that's a very good example
I don't really think it's a stretch.

But here's a neat writeup by a guy who worked a lot closer to the problem than I have -- he worked at Nvidia for a bit. (I just gazed into the abyss, flinched, and turned away to a career in not-graphics software):
http://www.gamedev.net/topic/666419-what-are-your-opinions-on-dx12vulkanmantle/#entry5215019
The first lesson is: Nearly every game ships broken. We're talking major AAA titles from vendors who are everyday names in the industry. In some cases, we're talking about blatant violations of API rules - one D3D9 game never even called BeginFrame/EndFrame. Some are mistakes or oversights - one shipped bad shaders that heavily impacted performance on NV drivers. These things were day to day occurrences that went into a bug tracker. Then somebody would go in, find out what the game screwed up, and patch the driver to deal with it. There are lots of optional patches already in the driver that are simply toggled on or off as per-game settings, and then hacks that are more specific to games - up to and including total replacement of the shipping shaders with custom versions by the driver team. Ever wondered why nearly every major game release is accompanied by a matching driver release from AMD and/or NVIDIA? There you go.

The second lesson: The driver is gigantic. Think 1-2 million lines of code dealing with the hardware abstraction layers, plus another million per API supported. The backing function for Clear in D3D 9 was close to a thousand lines of just logic dealing with how exactly to respond to the command. It'd then call out to the correct function to actually modify the buffer in question. The level of complexity internally is enormous and winding, and even inside the driver code it can be tricky to work out how exactly you get to the fast-path behaviors. Additionally the APIs don't do a great job of matching the hardware, which means that even in the best cases the driver is covering up for a LOT of things you don't know about. There are many, many shadow operations and shadow copies of things down there.

The third lesson: It's unthreadable. The IHVs sat down starting from maybe circa 2005, and built tons of multithreading into the driver internally. They had some of the best kernel/driver engineers in the world to do it, and literally thousands of full blown real world test cases. They squeezed that system dry, and within the existing drivers and APIs it is impossible to get more than trivial gains out of any application side multithreading. If Futuremark can only get 5% in a trivial test case, the rest of us have no chance.

The fourth lesson: Multi GPU (SLI/CrossfireX) is fucking complicated. You cannot begin to conceive of the number of failure cases that are involved until you see them in person. I suspect that more than half of the total software effort within the IHVs is dedicated strictly to making multi-GPU setups work with existing games. (And I don't even know what the hardware side looks like.) If you've ever tried to independently build an app that uses multi GPU - especially if, god help you, you tried to do it in OpenGL - you may have discovered this insane rabbit hole. There is ONE fast path, and it's the narrowest path of all. Take lessons 1 and 2, and magnify them enormously.
It goes on from there, I recommend the read.

None of this is to say that there aren't programming badasses that can make things fly even with the handicap -- just that it's a mess, and it's way more complicated than it should be. That is why I call it bad.
 
If you want some understanding of how things got to where they are, DirectX co-creator Alex St. John has a running series of blog posts detailing the conflicts and decisions made at the beginnings of DirectX, and when IRIS GL became OpenGL.

Long story short, the APIs are based on abstractions and not so much how the GPUs work. OpenGL was torn from the ashes of Silicon Graphics' workstations as a high level abstraction for 3D graphics, initially with CAD software mostly in mind, and early evangelists like John Carmack helped get it into real time graphics and games.

Direct3D was largely focused on gaming from its early phases, initially fairly low level but after feedback from games developers it was decided to make the API more programmer friendly at the expense of potential to optimize for performance. Some of this is touched on in St. John's post on Apple's Metal compared to Direct3D 1.0.
 

Milchjon

Member
More of a general question:

When/how did you guys decide on which area(s) to focus on? I mean languages, applications, problems, paradigms, tools, jobs and everything else. Programming/computer science seems like such a vast field, I'm having a hard time to stick to one thing or even a few things to get good at...
 
More of a general question:

When/how did you guys decide on which area(s) to focus on? I mean languages, applications, problems, paradigms, tools, jobs and everything else. Programming/computer science seems like such a vast field, I'm having a hard time to stick to one thing or even a few things to get good at...

Whatever interests you the most.
 
More of a general question:

When/how did you guys decide on which area(s) to focus on? I mean languages, applications, problems, paradigms, tools, jobs and everything else. Programming/computer science seems like such a vast field, I'm having a hard time to stick to one thing or even a few things to get good at...
1. Try a bunch of stuff, see what you like. Or don't like, and narrow it down that way.
2. Take note (ask questions, etc) of what skills are necessary for fields that interest you. For example, if you're dead set on physics simulations, that means some level of high-performance computing, and web app experience will not help much. Then again, maybe you find out you like making web apps...
3. This is more controversial, but I would say to favor technologies with broad utility (python, c, c++, javascript) over things that exist primarily due to legacy inertia (java, php).
4. algorithms! Core CS stuff is something that will help you a lot, even if you never spend a minute doing formal proofs in the "real world". While I've forgotten a ton of the details (Big-O notation and automata and set theory and recurrences...), in my mind there's no question that when I "trust my instincts" when it comes to software design, I'm really just leaning on a lot of what was drilled into me in my CS theory classes.
 

Massa

Member
Its unfortunate C++GAF but my job is going to make me get into Java soon. So any good tutorial sites?

I never used an English language tutorial, but I would recommend playing around with DrJava to get started. It's much simpler than the IDE you'll likely use for real work, but it's great for your first few Java programs and the interactive shell is pretty neat.

The problems with Java are the same as probably deal with in in C++, bad code making bad use of OO.
 

egruntz

shelaughz
Not Flash. Sorry that's all I can tell you haha.

As a rough guess, you'll probably have to pick up databases as well.

Definitely. This is where things get complicated. I would say start with a simple webpage that connects to a webserver and allows you to create an account. You enter a username and password, some info about yourself, and it sends that to the web server and the server writes it to the database. I don't know what's "in" these days, so I'll suggest MySQL just to name drop. From there make a page that that lets you display your account info if you enter your username and password.

Don't ask me how to do any of this stuff, i have no idea. I can implement a database, or a web server but I haven't the first idea how to connect it all together. :)

But the first step is to start small and don't focus too hard on the end goal. You need to learn a lot of stuffs to get there, and making mistakes along the way is part of the process.

Since this is a multiplayer game and I think MMO-lite you will need a server to keep track of players info and what not. So you need a backend language. There are lots of options like PHP, C#, Ruby, Python and so on. Since you know Javascript already, you can try Node.js and write your game server using it.

Also like Haly said, you will need to pick up some SQL thingy for database. You got a variety of options, MySQL, PostgreSQL, NoSQL, but this isn't a big issue. Anything you pick will suit your needs.

As for the game, I'm assuming this is some sort of 3D game right? So you will probably need to pick up something like WebGL. I'm not sure if there are any HTML5 game engines that are 3D, I know there is something like three.js but my knowledge in that area isn't that well. Of course you can use something like Unity3D, but I'm not sure how it handles your game with their web player plugin and how much flexibility you get with it.

Also something to look into when you get further in this is using WebSockets for real-time communication between your game and server. I have seen some people in the past use Socket.io when making online HTML5 games, but I can't speak on its usability. I have only used the thing for trivial features so not sure how well it works for complex apps.

I never took the time to thank you guys for your starter tips and suggestions. I quickly realized that I have a very insufficient understanding of what back-end programming even is, so I got to work right away on studying it. So from what I've collected--and please correct me if I'm wrong--there are two things I'll need to learn:

1) Database
2) Server programming language to communicate with the database

And that's it as far as back-end goes, right? I decided that PHP will probably be best, just cause it uses a syntax I'm very familiar with (feels just like JavaScript) and will be simple to implement in HTML files. Any suggestions as far as what database? People are saying MySQL but I honestly wouldn't know the differences between each database.

So if I have extensive knowledge of:
1) HTML
2) CSS
3) JavaScript / jQuery
4) PHP
5) MySQL

I should be able to build this game that I want, is that right? HTML and CSS I've got pretty much down. I could stand to brush up on my jQuery, and I started taking PHP courses through Codecademy. I'll learn MySQL lastly.

I guess what I don't understand is how to translate this to an actual website. Do I need to purchase servers through, say, HostGator? And then will whatever server I purchase give me a way to add in HTML/CSS/JavaScript/PHP/MySQL files, and it will just magically translate into a fully functioning website? I guess I just hugely lack an understanding of the basics if I'm still having trouble seeing how a website comes into fruition.

I've made website skins and whatnot, but never an actual website. If that makes sense.

Thank you guys for your continued patience with me. I know I must sound like an idiot.
 

hateradio

The Most Dangerous Yes Man
This is the worst possible example for a newbie, but it fits my mental model of enterprise Java code:

https://github.com/EnterpriseQuality...erpriseEdition
i2f89vJuMCWxn.gif





Code:
public String getReturnString() {
  final StringBuilder myStringBuilder = new StringBuilder("Buzz");
  final String myString = myStringBuilder.toString();
  return new String(myString);
}


i2f89vJuMCWxn.gif
 

msv

Member
This is the worst possible example for a newbie, but it fits my mental model of enterprise Java code:

https://github.com/EnterpriseQualityCoding/FizzBuzzEnterpriseEdition
That uses nothing of Java EE... No beans, no CDI, no servlets, no JMS, nothing. Is it a mockery of business Java code in general?

I hated Java EE on our last project. What do people here think about Application Servers? I used Glassfish then and was locked in round the end of the project, wanted to switch to Wildfly but would be too much of an effort. We defended our bugs by saying that Glassfish is utter shit, which is actually true.

What advantage does an Application Server even give? It really seems like a redundant layer on top of the OS. You don't need to have all of this combined into one application, it creates a single point of failure that's not nearly as reliably as the average OS.. so why not use the OS's application management features? 'Hot swap' separate applications instead of 'Enterprise applications' (lol). Not to mention that Hot swapping NEVER worked in glassfish. What are the reasons a company would choose to use a Java EE Application Server?
 
That uses nothing of Java EE... No beans, no CDI, no servlets, no JMS, nothing. Is it a mockery of business Java code in general?

When I last checked like a year ago, there were beans, servlets and JMS stuff (among others) in the pull requests. But you know how Enterprise Editions are, the release cycles are rather slow because you wouldn't want to break backwards compatibility for Java EE for Microwaves 1.2
 
Squeak is great, very fun to use. Play around in a workspace, inspect and explore objects as you will. It seems very weird at first but you'll get the hang of it in no time.

Yeah I'm actually enjoying using it. He gave us the option for GNU smalltalk or squeak, I think squeak will be much easier.

Funny coincidence. I'm in a similar situation. We have to do two assignments: For the first, we're free to choose any object-oriented language, but the second has to be in Smalltalk using Squeak. And both assignments are actually games too.

My first assignment was a java game using the graphics with plinko. I finished that, we haven't discussed threading in the class so I had to use an active timer keyed to repaints. Such janky code but it worked thankfully.

You've already linked to Squeak By Example, and honestly that's the most up to date, printed resource on Squeak Smalltalk that I'm aware of. Stephane Ducasse, the guy who later founded the Pharo Smalltalk project (a Squeak fork), has had an archive of printed Smalltalk resources, but many of those are not really a good fit for Squeak.

Squeak's another odd choice to teach. It is based on an open source build of Apple Smalltalk-80 from the mid-90s, yes, but since it was open sourced it was largely positioned as infrastructure for research projects by former Smalltalkers. Pharo is probably more beginner friendly, but I've seen first hand a Smalltalk-80 developer struggle as much as I to understand it.

I wish I could help you more. Digitalk Smalltalk/V and Smalltalk-80 were pretty easy to learn, but Squeak and Pharo have a ton of new, special purpose objects and projects that I just don't know where to begin.

Yeah I'll probably sit down and read most of that PDF. I've got friday + all weekend and some time on monday/tuesday to write the tic tac toe game. Thankfully he eliminated the part about making an AI that always results in a win/tie so it's made my job significantly easier.
 

msv

Member
Anyone have any good examples of PRINCE2 Project Initiation Documents (PID)? Struggling with the framing, since this will be a one man team (me) project, where I'm the product owner and everything else as well - a bit lost on how to frame it as something with business value.
 
That uses nothing of Java EE... No beans, no CDI, no servlets, no JMS, nothing. Is it a mockery of business Java code in general?

I hated Java EE on our last project. What do people here think about Application Servers? I used Glassfish then and was locked in round the end of the project, wanted to switch to Wildfly but would be too much of an effort. We defended our bugs by saying that Glassfish is utter shit, which is actually true.

What advantage does an Application Server even give? It really seems like a redundant layer on top of the OS. You don't need to have all of this combined into one application, it creates a single point of failure that's not nearly as reliably as the average OS.. so why not use the OS's application management features? 'Hot swap' separate applications instead of 'Enterprise applications' (lol). Not to mention that Hot swapping NEVER worked in glassfish. What are the reasons a company would choose to use a Java EE Application Server?

AS have builtin admin tools for clustering, handling multiple security realms, and have stable connectors for being proxied through a standard http server. In reality, AS have no benefit until you get to multiple AS each of which use multiple servers to serve content. It's more for high throughput and uptime for those that can afford it. Otherwise, you're better served using embedded servlet containers like with Spring Boot and Dropwizard if going Java.
 

msv

Member
AS have builtin admin tools for clustering, handling multiple security realms, and have stable connectors for being proxied through a standard http server. In reality, AS have no benefit until you get to multiple AS each of which use multiple servers to serve content. It's more for high throughput and uptime for those that can afford it. Otherwise, you're better served using embedded servlet containers like with Spring Boot and Dropwizard if going Java.
Which AS are quality then? My only real experience now is with Glassfish, and that was honestly the most unreliable piece of supposedly scalable software I have ever come across. The admin console is so incredibly slow as well, and wastes an enormous amount of resources - just loading up the admin console in Glassfish takes up more than a minute on a decent laptop and consumes a lot of memory. Wildfly was better in this regard, but the admin console was really nothing workable, you still needed to set everything in xml files.

Distributing the content of Application Servers, that wouldn't work with a simple message broker? Or, because the AS is closer to the content, you can be more efficient with the resources and have less redundancy when using multiple servers?

Don't mean to be dismissive by the way! I'm honestly interested, I've been taught that there's advantages to these AS but I still haven't been able to really grasp what those actually are.
 

wolfmat

Confirmed Asshole
Distributing the content of Application Servers, that wouldn't work with a simple message broker? Or, because the AS is closer to the content, you can be more efficient with the resources and have less redundancy when using multiple servers?
Distributing application server content is what's called deployment. This entails pushing the compiled backend code, libraries, templates and configuration and whatever (effectively, the compiled application) into the AS ecosystem. Of course you can manually inject runtime-relevant content, but that's not the intended workflow. You'd probably rather use something like vagrant or whatever. There may or may not be a broker under the hood there.
Servers still need the compiled stuff though. And connectors. And the XML shit. Packaged. Effectively, your "distribute-AS-content"-worker will still have to do classical deployment to conform to the AS environment. Therefore, you really want to rely on your toolset, which is made for that.

Does that help you?

Basically, there's a defined workflow that's based upon a defined toolset with application servers, and you learn that workflow to be productive and conform in an enterprise environment.

Because the latter feels so icky, small teams like to deviate from the AS ecosystem to gain flexibility in the deployment process (disjointed application workflows, like asynchronous off-site compute pipelines, make such deviations sensible, for example). But you could then also just manage multiple application server setups with multiple deployment plans.

I like the approach of doing everything user-frontend-wise (including views and DB connectors for MVC) in AS, but everything else which pulls data, computes and pushes data sans user input, has its own shell-driven ecosystem, with queueing, asynch worker setups and tiny handmade consumers. Java EE is uncomfortable with such a strategy though.


"Which AS are quality then?" -- Depends on what you want to do. It's not easy to find out which one fits well. It makes sense to become intimate with an AS that is popular. That builds experience which you'll need to match your pie-in-the-sky app with the coolest AS for the job.

The last time I've touched anything Java EE was in 2007. It was tedious, restrictive programming. It felt like I was trying to sprint in jelly. I didn't enjoy it. The money was good though :p
 

injurai

Banned
Anyone have any knowledge of the parallel computing industry? Sort of curious about it, will be taking a parallelization course next semester.
 

msv

Member
Does that help you?
Great writeup, certainly tickles my jimmies; but alas there's still no click here. I guess I would need a concrete example of where a full on AS would be (one of) the best choice(s). I get the advantages of the separate parts in certain scenario's, but personally I could only see disadvantages when combining them all in a full spec AS.

We made a system with a network backend that had a user module communicating with it for storing and retrieving user data, which 5 webapplications communicated with through persistent JMS queues. All of the separate modules had to be running on an AS. So I guess my view on it would sync with what you say here:

I like the approach of doing everything user-frontend-wise (including views and DB connectors for MVC) in AS, but everything else which pulls data, computes and pushes data sans user input, has its own shell-driven ecosystem, with queueing, asynch worker setups and tiny handmade consumers. Java EE is uncomfortable with such a strategy though.

Since I would have preferred to have just the webapps running on an AS and the backend as something standalone? It was just so limiting working with Java EE, getting multithreading to work with JMS on an AS was almost impossible. And everything was extremely slow. I felt I had to relearn an entire language (the Java EE API) just so I could do the things I could already do, but slower, less efficient and more buggy. In the backend at least. Serving up HTML pages at the frontend, I'm not sure what the best option would be in Java.

The last time I've touched anything Java EE was in 2007. It was tedious, restrictive programming. It felt like I was trying to sprint in jelly. I didn't enjoy it. The money was good though :p
I can echo those feelings for my 6 month project and other Java EE courses last year.
 
I never used an English language tutorial, but I would recommend playing around with DrJava to get started. It's much simpler than the IDE you'll likely use for real work, but it's great for your first few Java programs and the interactive shell is pretty neat.
I agree. Dr Java's an interactive interpreter that allows you to poke around with Java 6, 7 and 8 as you're learning it. It was largely developed by a CompSci professor, Dr. Robert Cartwright, for the purpose of providing a more interactive experience for teaching how to put together Java programs, quite like IDLE for Python and IRB for Ruby. He's been planning to extend it to teach multicore programming, but I don't know how far along that project is.

As Massa says, it's not a professional, enterprise, suit and tie IDE experience. But it's nice to get started with.
 
Multicore anything ain't that bad, as long as you're careful about limiting interactions between threads (or insert abstraction here) and programming paranoidly around that.

Best way to go is to use as few threads as possible for the job you're doing. Keep GUI and real time graphics interactions on the main threads, most simple work on main, and anything that will take an indeterminate amount of time or might lock up the UI on a background thread with a simple procedure to communicate an "I'm done" message with the completed results of that task back on the main thread, once work on the background thread finishes.

Last thing, and this is the "paranoidly" bit, is you want to keep whatever variables that background thread is touching or working with as isolated to that thread as possible, do not access them from main, do not cross the streams. Same goes for main thread variables, they shouldn't be accessed from a background thread. A common strategy is to pass a complete structure that has copies of all the data a background thread needs to work with from main to background, and main never hears from background again until work's finished.

This is why closure-based strategies are a bit trendy in multicore programming, now. It's easy to pack up your work that way into a function, send it off for background processing, and maintain multicore best practices that way.
 
That uses nothing of Java EE... No beans, no CDI, no servlets, no JMS, nothing. Is it a mockery of business Java code in general?

I hated Java EE on our last project. What do people here think about Application Servers? I used Glassfish then and was locked in round the end of the project, wanted to switch to Wildfly but would be too much of an effort. We defended our bugs by saying that Glassfish is utter shit, which is actually true.
Well, yes. It's a hello world app, ostensibly.

What advantage does an Application Server even give? It really seems like a redundant layer on top of the OS. You don't need to have all of this combined into one application, it creates a single point of failure that's not nearly as reliably as the average OS.. so why not use the OS's application management features? 'Hot swap' separate applications instead of 'Enterprise applications' (lol). Not to mention that Hot swapping NEVER worked in glassfish. What are the reasons a company would choose to use a Java EE Application Server?
I'm partial to jetty myself, which is to say that I wash my hands of the whole thing... but the primary utility the J2EE containers (tomcat, glassfish, oracle's thingy, etc) give is ease* in administration, and a layer of sandboxing. Production environments usually don't have a single point of failure, the webapps are run in their own container processes -- potentially not even on the same server.

The madness that ensues with J2EE is usually when constructing a developer environment that's supposed to be "close to" the production environment. But obviously you don't need a robust server, so you throw a single tomcat server up, and start hotswapping war files like it's cool (never** happens in production), and developers get pissed off at all this nonsensical crap they have to put up with.

* perceived
** citation needed
 

GK86

Homeland Security Fail
How do I check if an element is already in a list/array?

Edit- Forgot to mention, this is in Python (2.7).

I have the following code:

Code:
for item in page_info:
            if len(item.contents) > 3:
                a_element = item.contents[3].find("a")
                if a_element:
                    link = a_element.get('href')
                    
                if "/places" in link:
                    full_url.append(url + link)

I'm scraping a page for url links and placing them into "link." The url's coming from this part, look like "/places/blahblahblah" or "/events/blahblahblah." The last piece of two lines of the code are making sure it is only grabbing the "/places" urls.

The problem is, that there are duplicates urls on each page. How do I check if the url has already been scraped before adding it into the full_url array?

I would appreciate any help/direction.
 

mercviper

Member
How do I check if an element is already in a list/array?

I have the following code:

Code:
for item in page_info:
            if len(item.contents) > 3:
                a_element = item.contents[3].find("a")
                if a_element:
                    link = a_element.get('href')
                    
                if "/places" in link:
                    full_url.append(url + link)

I'm scraping a page for url links and placing them into "link." The url's coming from this part, look like "/places/blahblahblah" or "/events/blahblahblah." The last piece of two lines of the code are making sure it is only grabbing the "/places" urls.

The problem is, that there are duplicates urls on each page. How do I check if the url has already been scraped before adding it into the full_url array?

I would appreciate any help/direction.

My only thought is to traverse through your full_url array with the new url value until you find a match or traverse the entire array and only append it if you don't find a match. It seems kinda inelegant and possibly time consuming dependent on how big your url list gets though.
 
Top Bottom