• 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.

DevGAF: The Official Programming Thread

Do you program? If so, in which languages?


  • Total voters
    103

ThatGamingDude

I am a virgin
Here's a mini project to get your feet wet in Infrastructure as Code, a huge pillar of devops:

create a free AWS account and use that to deploy 1 EC2 VM running Linux
But do that using Terraform, and use Packer to build the AMI that gets deployed into the EC2 VM
The VM will need a network, security groups, firewall rules (at the cloud-mgmt level), etc. Bonus points if you use Terraform to also deploy this.
Then use Ansible to configure the server as a Docker host (you can also do this right in the AMI but do it separately so it can teach you why Config Management is important)

If you do that you'll get roughly 50% of what devops is at scale, then you'll learn about the other half: monitoring, logging, CI/CD, container orchestration, etc
Well I work a donut, sounds like I have something to play with tomorrow if I can pull myself away from PSO2

Thanks for the idea man; I've been barking up that tree with other teams here and they just go "I dunno."
 

mango drank

Member
I gots to get back to learning JS.

Now for the real important question: what fonts do you guys like using in your editor? I've tried a bunch of monospaced fonts, but I always seem to come back to Roboto Mono. Easy on the eyes, simple, no fuss. Also, I don't like fonts that use programming ligatures--they're confusing and unclear. But that's just my opinion as a newb.

dUZ1Fop.jpg
 
H

hariseldon

Unconfirmed Member
I gots to get back to learning JS.

Now for the real important question: what fonts do you guys like using in your editor? I've tried a bunch of monospaced fonts, but I always seem to come back to Roboto Mono. Easy on the eyes, simple, no fuss. Also, I don't like fonts that use programming ligatures--they're confusing and unclear. But that's just my opinion as a newb.

dUZ1Fop.jpg

I'm using Jetbrains Mono (comes with their wonderful editors) but it doesn't bother me too much to use other fonts, so long as they're monospaced. I agree about the programming ligatures though, they can fucking die in a fire. I want to see exactly what I typed, no fucking about.
 

mango drank

Member
Probably old news by now, but freeCodeCamp has been saying they're working on releasing Python lessons, and they've started rolling them out:
 

ReyBrujo

Member
Probably old news by now, but freeCodeCamp has been saying they're working on releasing Python lessons, and they've started rolling them out:
Gonna tell my friend about it, he's working as a functional tester trying to broaden his possibilities and Python is pretty good at that. Alas, another Python reminder: the Python Humble Bundle is about to finish.

I gots to get back to learning JS.

Now for the real important question: what fonts do you guys like using in your editor? I've tried a bunch of monospaced fonts, but I always seem to come back to Roboto Mono. Easy on the eyes, simple, no fuss. Also, I don't like fonts that use programming ligatures--they're confusing and unclear. But that's just my opinion as a newb.
When you talk about programming fonts most choose between Consolas, Cascadia Code, Anonymous Pro, JetBrains Mono, etc. Since a couple of months ago I switched to JetBrains Mono which I find very clean. Ligatures at first are odd, but I got used at them, and I think they make the text much more clear for certain languages (in C# body expressions are declared as => so having a single character drawn makes it stand out, same as >= or <= (greater equal or lower equal), indirectly it makes you pay more attention to them.
 

ThatGamingDude

I am a virgin
I gots to get back to learning JS.

Now for the real important question: what fonts do you guys like using in your editor? I've tried a bunch of monospaced fonts, but I always seem to come back to Roboto Mono. Easy on the eyes, simple, no fuss. Also, I don't like fonts that use programming ligatures--they're confusing and unclear. But that's just my opinion as a newb.

dUZ1Fop.jpg
If you get comfortable with JS I would say start learning Node.JS

The company I have now has their own in house front end, and my bosses and devs here are losing their shit over Node.JS

Dev in the office over here is swapping our chats from AJAX to Node.JS; converted part of our Asterisk server to using it too
 
H

hariseldon

Unconfirmed Member
If you get comfortable with JS I would say start learning Node.JS

The company I have now has their own in house front end, and my bosses and devs here are losing their shit over Node.JS

Dev in the office over here is swapping our chats from AJAX to Node.JS; converted part of our Asterisk server to using it too

I'm more of a java guy myself for back-end (though I use a lot of TypeScript for Angular front ends which exist in a similar universe in terms of tools etc) but I'd agree that Node is worth learning - there's a decent amount of work out there for people with skills in that area.
 

ThatGamingDude

I am a virgin
I'm more of a java guy myself for back-end (though I use a lot of TypeScript for Angular front ends which exist in a similar universe in terms of tools etc) but I'd agree that Node is worth learning - there's a decent amount of work out there for people with skills in that area.
It's got me as a server dude interested in it

I just hear ~~java~~ and want to become an hero
 
H

hariseldon

Unconfirmed Member
It's got me as a server dude interested in it

I just hear ~~java~~ and want to become an hero

Java's not so bad. I've been doing it for about 8 years now having previously done PHP since about 2000 and honestly it's good - it does a lot of good work to prevent user idiocy, and from the release of java 8 a lot of new stuff started appearing and a lot of things became less painful, ie we got a proper Date API, functional programming, streams, etc. Combine that with Spring being lovely (and modern spring thankfully doesn't use a tonne of crappy XML files like the old days) and Java actually starts to look quite attractive.

Btw never use PHP. You will be dragged into Wordpress or Drupal and want to kill yourself. I got away from PHP because the work available for it stopped being interesting.
 
Last edited by a moderator:

ReyBrujo

Member
i'm kinda burnt out, thank god for ue4 blueprints
Do you make games? No offense intended but I would never dare program something that's going to be bashed by a 9 year old boy via Twitter :messenger_grinning_sweat: I can only think in what a game programmer feels when he's spent so much time doing something and some unknown guy paying $60 for your product says something like water doesn't look natural or hair looks too rigid and doesn't pay attention to the intricacies of your newly built engine.

I sometimes get criticized but by physicians who paid $3k - $10k for a license to our product ("You aren't a physician so you don't understand the correct workflow" or "This section is way too slow to be useful" with some "Patients may die if you don't fix this allergy reaction issue" mixed on it) who seldom worry about "looks", only about functionality.

Btw never use PHP. You will be dragged into Wordpress or Drupal and want to kill yourself. I got away from PHP because the work available for it stopped being interesting.
So true! PHP statistics are always inflated because of Wordpress. Sure, it has 20% of the market but 17% is probably Wordpress and you'd end up spending more time switching skins than programming. It's very used still in newspapers and blogs and whatever site needing to show sorted entries, but it's not something you'd want to focus on if you want to grow up.

node.js is pretty cool, I spent a whole semester learning about it just to be able to compare it with ASP.NET, Django and Spring. It's limited, though, you must be building something that is I/O intensive, otherwise a miss (Uber wrote their georeference code in Go because even though they were using node.js for other stuff it wouldn't be able to process the amount of data they required).

Regarding Java there was a lot of negative press with the Oracle license bullying. And with Google pushing Kotlin for Android and the amount of alternatives and hybrids available (React Native, Ionic, Xamarin, Flutter, etc) might hurt their mobile side, but the sheer amount of web apps still running will keep it alive for many years more. I also believe that Java was stagnating until C# gained steam (it took Java virtually 8 years to have local variable inference similar to C#'s var, 4 years to get streams to mimick LINQ, even though streams are more powerful indeed, and still no null coalescing or safe navigator operator).
 

Tesseract

Banned
Do you make games? No offense intended but I would never dare program something that's going to be bashed by a 9 year old boy via Twitter :messenger_grinning_sweat: I can only think in what a game programmer feels when he's spent so much time doing something and some unknown guy paying $60 for your product says something like water doesn't look natural or hair looks too rigid and doesn't pay attention to the intricacies of your newly built engine.

I sometimes get criticized but by physicians who paid $3k - $10k for a license to our product ("You aren't a physician so you don't understand the correct workflow" or "This section is way too slow to be useful" with some "Patients may die if you don't fix this allergy reaction issue" mixed on it) who seldom worry about "looks", only about functionality.


So true! PHP statistics are always inflated because of Wordpress. Sure, it has 20% of the market but 17% is probably Wordpress and you'd end up spending more time switching skins than programming. It's very used still in newspapers and blogs and whatever site needing to show sorted entries, but it's not something you'd want to focus on if you want to grow up.

node.js is pretty cool, I spent a whole semester learning about it just to be able to compare it with ASP.NET, Django and Spring. It's limited, though, you must be building something that is I/O intensive, otherwise a miss (Uber wrote their georeference code in Go because even though they were using node.js for other stuff it wouldn't be able to process the amount of data they required).

Regarding Java there was a lot of negative press with the Oracle license bullying. And with Google pushing Kotlin for Android and the amount of alternatives and hybrids available (React Native, Ionic, Xamarin, Flutter, etc) might hurt their mobile side, but the sheer amount of web apps still running will keep it alive for many years more. I also believe that Java was stagnating until C# gained steam (it took Java virtually 8 years to have local variable inference similar to C#'s var, 4 years to get streams to mimick LINQ, even though streams are more powerful indeed, and still no null coalescing or safe navigator operator).
games and software, lots of vr stuff currently

that level of criticism goes with the territory, i kinda like wading through mud and blood or wouldn't bother
 

Woffls

Member
I do c# for integration middleware (BizTalk and Azure) but I don’t get to do as much coding as I’d like; might give Unity a go for a laugh. At this point I either need to move into normal .net stacks, or diversify my integration expertise with different solutions.
 

ReyBrujo

Member
games and software, lots of vr stuff currently

that level of criticism goes with the territory, i kinda like wading through mud and blood or wouldn't bother
I guess so, lol.

What attracted me from game programming was Elite, the fact that it could generate an entire galaxy with a single number and an algorithm. But as 3D gained traction I kind of left everything behind, I worked some with OpenGL but just couldn't get used to it. Plus I absolutely hate Blender.

I bought a few bundles of 2D sprites, card games and the like in case I ever decide to try something again. Back in the early 2000 when I started to get bored of gaming I had an idea for a game where you didn't play. You were actually an army commander who decides several parameters during the night and during the day the logic would just react to different events with them. Got the scripting engine working plus the battle system ready but then grew bored and stopped. Years later came My Life as a King which was like what I'd have liked to achieve :messenger_grinning_sweat:
 

mango drank

Member
But as 3D gained traction I kind of left everything behind, I worked some with OpenGL but just couldn't get used to it. Plus I absolutely hate Blender.
Funnily enough, I know a little Python just because of Blender. Blender's UI customization is done in Python, and I've modified other people's UI add-ons for myself, and hacked together some UI things myself too. A lot of add-ons for new functionality are also in Python. Plus, there's scripting available for the objects in your scene, and that's done in Python too, but support for that kind of scripting is kinda spotty and feels half-implemented, and right now it's tedious to get things working smoothly.

As for Blender itself, are you talking about ancient Blender, or Blender in the last couple of years? It's gotten way better since the early 2000s (hah), especially in recent years, since the 2.8x era kicked off. It's starting to take away business from the usual game industry giants (Autodesk, Zbrush, etc). It's been on a rampage lately.
 
Last edited:

ThatGamingDude

I am a virgin
Funnily enough, I know a little Python just because of Blender. Blender's UI customization is done in Python, and I've modified other people's UI add-ons for myself, and hacked together some UI things myself too. A lot of add-ons for new functionality are also in Python. Plus, there's scripting available for the objects in your scene, and that's done in Python too, but support for that kind of scripting is kinda spotty and feels half-implemented, and right now it's tedious to get things working smoothly.

As for Blender itself, are you talking about ancient Blender, or Blender in the last couple of years? It's gotten way better since the early 2000s (hah), especially in recent years, since the 2.8x era kicked off. It's starting to take away business from the usual game industry giants (Autodesk, Zbrush, etc). It's been on a rampage lately.
No shit? Python is starting to get applications out side of...well..our shit?

What libraries do you recommend?
Also, I'd love to pick your brain about TKinter; I'm having some issues with boxes drawing internal default color schemes versus system defaults. Not a huge issue, but it fucking triggers me as a dark theme user
 

mango drank

Member
No shit? Python is starting to get applications out side of...well..our shit?

What libraries do you recommend?
Also, I'd love to pick your brain about TKinter; I'm having some issues with boxes drawing internal default color schemes versus system defaults. Not a huge issue, but it fucking triggers me as a dark theme user
Sorry to disappoint, but I really meant it when I said I know only a "little" Python. I'm very much a dev noob in general, have only poked at it on the side over the years. Re: Python in Blender, for add-ons, I've mostly just modified other people's Blender stuff by poking through their code and changing things here and there, or stealing chunks and branching those off to make my own really simple tools. I dunno nothin bout no libraries, apart from the stuff Blender exposes to let you work with its UI or its 3D scenes. And I haven't done anything in B Py in over a year, so I've forgotten most of it. :messenger_sunglasses:

I think Blender's Python stuff works through an API, so it's just a layer on top of the core app? I don't think plugin developers are putting together crazy custom UI elements using outside libraries--most Blender add-ons I've seen tend to look the same, and use similar UI elements etc. But I could be wrong.
 
H

hariseldon

Unconfirmed Member
Sorry to disappoint, but I really meant it when I said I know only a "little" Python. I'm very much a dev noob in general, have only poked at it on the side over the years. Re: Python in Blender, for add-ons, I've mostly just modified other people's Blender stuff by poking through their code and changing things here and there, or stealing chunks and branching those off to make my own really simple tools. I dunno nothin bout no libraries, apart from the stuff Blender exposes to let you work with its UI or its 3D scenes. And I haven't done anything in B Py in over a year, so I've forgotten most of it. :messenger_sunglasses:

I think Blender's Python stuff works through an API, so it's just a layer on top of the core app? I don't think plugin developers are putting together crazy custom UI elements using outside libraries--most Blender add-ons I've seen tend to look the same, and use similar UI elements etc. But I could be wrong.

Pissing about with other people's code is exactly the right way to start. It's how most people started I think. I started at 8 on my Amstrad CPC 464 with the listings in magazines back in the day, I'd see something in there I didn't like, tweak it, and have a better application. Then I got an Atari ST and started making games as I learned more. The point is you have to start somewhere, and that approach provides scaffolding to allow you to get a feel for those early basic things like working with variables, understanding loops and conditionals, etc.
 

Shifty1897

Member
I use PowerShell and SQL daily for my job. I need to try to get good enough at Python so I can start using that instead of PowerShell in my AWS Lambdas, since the file size is much smaller and the execution time is much faster.
 

Belmonte

Member
Has been a year since I started learning C# to make my game. I always wanted to make one and since I could not get in the industry as a 2D artist, I decided to code the game myself.

It has been a great experience! I'm liking the craft a lot. It is so interesting that I can see myself being a programmer instead of an artist if I had access to a computer instead of crayons when I was a kid.

If my brain could exit my head and punch me, it would though. I find very exhausting to learn code and art at the same time. I'm making very in deep logs of whatever changes I do in the code. I screenshot the screen before and after the change, put on photoshop, write which script it belongs to and explain to myself why it changed.

All this documentation slows the process a lot but I do because it is very easy for a beginner to lost the track. Another thing I do is flowcharts explaining the logic of the moves.
 

ReyBrujo

Member
ReyBrujo ReyBrujo
Since this thread gained some traction, do you think a name change might be in order?

Maybe "DevGAF," or something of the like to fit us being huge nerds
Make it like a OT
Yeah, I'm that dude in the office; "But we can name it something fancy!"
Yeah, it can be an option. I'd say let's wait til the thread is a month old. Then again how do you request a thread title change?

Funnily enough, I know a little Python just because of Blender. Blender's UI customization is done in Python, and I've modified other people's UI add-ons for myself, and hacked together some UI things myself too. A lot of add-ons for new functionality are also in Python. Plus, there's scripting available for the objects in your scene, and that's done in Python too, but support for that kind of scripting is kinda spotty and feels half-implemented, and right now it's tedious to get things working smoothly.

As for Blender itself, are you talking about ancient Blender, or Blender in the last couple of years? It's gotten way better since the early 2000s (hah), especially in recent years, since the 2.8x era kicked off. It's starting to take away business from the usual game industry giants (Autodesk, Zbrush, etc). It's been on a rampage lately.
I was talking about the old one. Last year I took a Python course where Blender scripts were used to build objects. Lots of people hated it because you wouldn't even know what a variable was and you were already trying to read Python code, lol

I find very exhausting to learn code and art at the same time. I'm making very in deep logs of whatever changes I do in the code. I screenshot the screen before and after the change, put on photoshop, write which script it belongs to and explain to myself why it changed.
Unless you also attach a screenshot of the effect of the change (like, how the rendered character looked before the code change and after the code change) what you are doing can be done with version control. Have you tried any of them? Git is the currently most used one (and harder to understand) but there are simpler ones to get you started (like CVS and SVN even if they are considered obsolete right now). They are similar to Dropbox's history, basically they let you track down file changes through time, let you go back to a previous version and compare changes between two versions.

In other news the Python bundle ended and they added a JavaScript one with video courses from Zenva (which I believe I've never heard before).
 
Last edited:

Belmonte

Member
Unless you also attach a screenshot of the effect of the change (like, how the rendered character looked before the code change and after the code change) what you are doing can be done with version control. Have you tried any of them? Git is the currently most used one (and harder to understand) but there are simpler ones to get you started (like CVS and SVN even if they are considered obsolete right now). They are similar to Dropbox's history, basically they let you track down file changes through time, let you go back to a previous version and compare changes between two versions.

Thanks for the tip! I'm watching some videos about version control right now.

The game is 2D so there isn't much software rendering but sometimes I need to explain to myself changes in Unity instead of Visual Studio so I attach a screenshot. I make copies of the game from time to time also.
 

ReyBrujo

Member
You can create an account at github, upload your code there (if you don't want anyone to read it you can create a private repository) and then use github (with git) to store there. Any doubt you have you can ask here since versioning is a vital part of programming.
 

Belmonte

Member
You can create an account at github, upload your code there (if you don't want anyone to read it you can create a private repository) and then use github (with git) to store there. Any doubt you have you can ask here since versioning is a vital part of programming.


Thanks man!

Here are some examples of what I do:

vUT01wl.jpg



UTi7LjR.jpg



AX1Y4Pv.jpg


Can I do these types of annotations/sketches with Git or it is just lines of code?
 

ReyBrujo

Member
No, just lines of codes, That's why I said if you used it for graphical things like renders you would have to continue with them manually. The Actor one could be seen as this (no image since I can't seem to upload images):


$ git log --oneline --graph --decorate
* 13466eb (HEAD -> master) GetUp em falso
* bf4e4d5 initial upload

$ git log
commit 13466ebb797bf61bd23eb9f34cb01b19162b97d4 (HEAD -> master)
Author: Des <[email protected]>
Date: Wed Jul 22 17:40:53 2020 -0300

GetUp em falso

Colocamos o bool "GetUp" em falso quando o DidGetUp() é chamado.
E ele é chamado por um evento de animacao.


commit bf4e4d5f0543480702d76c42f2d09c9bc3263abb
Author: Des <[email protected]>
Date: Wed Jul 22 17:39:03 2020 -0300

initial upload

$ git diff bf4e 1346
diff --git a/actor.cs b/actor.cs
index d244b0c..fda263d 100644
--- a/actor.cs
+++ b/actor.cs

@@ -1,6 +1,7 @@
public void DidGetUp() // Called when "getup" animation ends
{
isKnowckedOut = false;

+ baseAnim.SetBool("GetUp", false); // Fix to prevent bug when getting up immediately

- Debug.Log("KNOCKEDOUT falso");
+ //Debug.Log("KNOCKEDOUT falso");

}


The important snip is the very last one, a patch where lines removed are marked with - in red and added lines marked with + in green.
 
Last edited:

Anki

Banned
I use swift and objective-c for my work and I love it. At first i was working in web development but i quickly realised i dont like it so i switch to mobile.
 
H

hariseldon

Unconfirmed Member

The O'Reilly books are a bit dry but they're proper quality content, well worth picking up. Good range of content covered, including the currently very fashionable Kotlin, Scala, Go and Rust alongside the wonderful Typescript and traditional stuff like PHP and Perl (never use Perl - it's the only language worse than PHP) and enterprise stuff like C# and Java.
 

ReyBrujo

Member
The oldest book in that bundle is from 2015 which isn't that bad for an O'Reily bundle (2008-2010 is the norm), with quite a few books / preview editions from 2020. I just bought it because I'm a nerd. All the files come in 3 formats, PDF, ePub and mobi.

For someone wanting to learn programming (with an idea of programming) the Go book can be pretty useful. Go (you could call it Google's Python) is getting more and more followers every day and it's being used in many places where Javascript fails due its interpreted nature. The book's index (haven't yet checked its contents) is basically all the areas you'd cover if you were watching a video tutorial (but with the depth of a book, of course). The main problem with Go is similar to Python's main problem for newbies: no GUI action, pure console which might make some people nervous.

Back in the early 2000 I chose Perl instead of Python when you had to choose sides for LAMP. And it served me really well when I entered this company and had to create reports about the 25000 source code files in four different languages. It's great for parsing text but hasn't aged well.

By the way, through the years I've bought some book dupes (not because I wanted but because two or more bundles brought each a copy) plus I've bought two copies of the recent Technology Essentials for Business by Manning Publications so I'll post a list of books and stuff that I can give away at a later date. Some stuff (like keys) are obviously redeemable once, some I should probably give as a bundle (like, the PDF, mobi and ePub versions of a book) and some might be just an individual copy (like a video course that has to be downloaded).
 

mango drank

Member
Anyone ever do anything interesting / useful with Processing or its variants? (Processing.py, p5.js) I learned a little Processing last year to see if it could help out with some occasional tedious vector graphics stuff, and while it seemed promising for some weird edge cases, it seemed kinda clunky and tedious all on its own lol.

I ask because there's another Humble Bundle that includes books on Processing.py and p5.js, so I figure what the hell, I can give it another shot. A good excuse to get back into Python at least.
 

ReyBrujo

Member
Sorry, never used it myself. If you still remember how to use it or got some old samples it could be cool if you shared some code and result to get to know what it does.

The $1 tier got pretty short books (after removing all the unnecessary prologues, indexes, etc). I also count appendixes apart because sometimes they are a waste of space.
  • 97 Things Every Java Programmer Should Know (210 pages)
  • Think Julia (261 pages)
  • Programming Scala (543 pages)
  • Introducing Go (98 pages of contents and a 9-page appendix with answers)
  • Learning Perl (292 pages plus 64 pages of appendixes)
The $8 tier:
  • Learning SQL (317 pages plus 28-page appendix)
  • Programming PHP (384 pages plus 107-page function listing)
  • R Cookbook (554 pages)
  • Head First Kotlin (395 pages plus 39-page appendix)
  • Using Asyncio in Python (129 pages with 15-page appendix)
The $15 tier:
  • Programming Rust (583 pages)
  • C# 8.0 in a Nutshell (1045 pages)
  • Fluent Python (708 pages and 37-page appendixes)
  • Learning Java (438 pages and 20-page appendix)
  • Programming TypeScript (268 pages and 20-page appendix)
Honest thoughts (without having reading them still): At first glimpse if you got zero or minimal knowledge and want to learn Go, Julia o Perl those books at $1 tier seem pretty good (but I guess you should have some programming insights).

Regarding the $8 tier, Head First Kotlin is a good introduction to Kotlin (the 395 pages is misleading since every book has at least one illustration, UML note or side note taking space). However it's not an introductory book to programming, you are supposed to know another language or have done some programming fundamentals' course since it won't explain you what is inheritance, it will just use it.

Regarding the $15 tier, don't use that C# book to learn it, it's a reference guide which means it will very likely mix basic with advanced information that'd just confuse you. The Programming TypeScript book seems good for learning it, but maybe it would be better to start by learning JavaScript and its nuances, otherwise you'd not be able to fall back (for example, if you need to write front-end code in pure JS. Some of the books like the Learning Java got lots of pages explaining how to configure it, how to install IDEs, etc, so it might end up shorter than those 438 pages.
 

mango drank

Member
Sorry, never used it myself. If you still remember how to use it or got some old samples it could be cool if you shared some code and result to get to know what it does.

I dug up some old Java code and I'm polishing it up to show, but I'm stuck. Looks like there are some Java experts here, so if anyone has a min, I have a question. I'm trying to create a 3D array. That's usually simple enough, but in this case, I want to be able to assign the various array lengths dynamically over time, instead of creating the entire 3D array from the start:
Java:
// these values will be used to dynamically create the main 3D array later
int[] arrNums = {6, 8, 4, 12, 8};

// create the first level of the main 3D array
float[] arr3D = new float[arrNums.length];

// create the deeper levels of the 3D array
for (int i = 0; i < arrNums.length; i++) {
    arr3D[i] = new float[arrNums[i]][2]; // why doesn't this work? How to do this properly?
}

For the line within the for loop, the Processing interpreter throws up the error "cannot convert from float[][] to float[]." What's the proper way to do it? Processing uses Java 8, so I wouldn't be able to use newer approaches. The above would be trivial to do in JS. I dunno why Java arrays are so weird to work with.

EDIT: never mind, I figured out the syntax:
Java:
int[] arrNums = {6, 8, 4, 12, 8};

float[][][] arr3D =  new float[arrNums .length][][];

for (int i = 0; i < arrNums .length; i++) {
      arr3D[i] = new float[arrNums [i]][2];
}
 
Last edited:

ReyBrujo

Member
Does it need to be a matrix? You could just use an array as new float[arrNums * 2] and then convert x, y pairs to a one dimension y * arrNums + x index.

I'd personally use an ArrayList unless performance was an issue after having coded it.
 
Last edited:

mango drank

Member
Does it need to be a matrix? You could just use an array as new float[arrNums * 2] and then convert x, y pairs to a one dimension y * arrNums + x index.

I'd personally use an ArrayList unless performance was an issue after having coded it.
No performance concerns, it's just stuff that draws once, no interactivity (...yet). Also, are you suggesting to create two separate arrays, one for X, and one for Y? They'd still need to be matrices in that case, wouldn't they? But they'd be 2D instead of 3D.

(hours later) I wrote this using ArrayLists at first, and then stripped that out and simplified it, using just a basic 3D array. Here's the output image, and the code is below. It can create nets of arbitrary column numbers and nodes:

KQJfbUE.jpg


Java:
// IMPORTS
import processing.pdf.*;
import java.util.Date;


// GLOBALS
int[] arrCols = {2, 6, 16, 14, 18, 16, 12, 14, 6}; // # of cols, and # of nodes in each col

float[][][] arrCoords =  new float[arrCols.length][][]; // all coords

float distHoriz = 160; // horizontal distance between ellipse columns
float distVertical = 40; // vertical distance between ellipses
float eDiameter = 12; // ellipse diameter

color swatch1 = color(255, 255, 255);
color swatch2 = color(92, 128, 255);
color swatch3 = color(255, 255, 255, 0);
color swatch4 = color(255, 255, 255, 128);
float strokeWeightL = .5;
float strokeWeightE = 3;
float eStrokeOffset = 12;

// get height of tallest column
public float getNetHeight() {
  int tallest = 0;
  for (int i = 0; i < arrCols.length; i++) {
    if (arrCols[i] > tallest) { tallest = arrCols[i]; }
  }
  
  return tallest;
}


// SETUP
void setup() {
  beginRecord(PDF, "export_test.pdf");
  size(1800, 900);
  background(30, 30, 40);
  
  noLoop();
}


// DRAW
void draw() {
  float centerX = width / 2;
  float centerY = height / 2;
  float netWidth = distHoriz * (arrCols.length - 1); // width of net
  float netHeight = distVertical * (getNetHeight() - 1); // height of net
  
  // populate arrCoords; draw connecting lines
  for (int i = 0; i < arrCols.length; i++) {
    arrCoords[i] = new float[arrCols[i]][2];
    
    for (int j = 0; j < arrCols[i]; j++) {
      // calculate x,y coords
      float x = (i * distHoriz) - (netWidth / 2) + centerX;
      float yDelta = (netHeight - (distVertical * (arrCols[i] - 1))) / 2;
      float y = (j * distVertical) - (netHeight / 2) + centerY + yDelta;
      
      arrCoords[i][j][0] = x;
      arrCoords[i][j][1] = y;
      
      // draw connecting lines; start at i == 1, drawing right to left
      if (i >= 1) {
        for (int k = 0; k < arrCoords[i - 1].length; k++) {
          stroke(swatch4);
          strokeWeight(strokeWeightL);
          line(arrCoords[i][j][0], arrCoords[i][j][1], 
            arrCoords[i - 1][k][0], arrCoords[i - 1][k][1]);
        }
      }
    }
  }

  // draw ellipses over lines
  for (int i = 0; i < arrCoords.length; i++) {
    for (int j = 0; j < arrCoords[i].length; j++) {
      fill(swatch1);
      stroke(swatch1);
      strokeWeight(strokeWeightE);
      ellipse(arrCoords[i][j][0], arrCoords[i][j][1], eDiameter, eDiameter);
      
      fill(swatch3);
      stroke(swatch2);
      strokeWeight(strokeWeightE);
      ellipse(arrCoords[i][j][0], arrCoords[i][j][1], 
        eDiameter + eStrokeOffset, eDiameter + eStrokeOffset);
    }
  }
  
  endRecord();
  println( "PDF saved: " + new Date() );
}
 
Last edited:

ReyBrujo

Member
Oh, that's pretty sweet! I'll have to check about processing later.

Also, are you suggesting to create two separate arrays, one for X, and one for Y? They'd still need to be matrices in that case, wouldn't they? But they'd be 2D instead of 3D.
I meant you were creating an array where each place was occupied by a 2D matrix of [some value][2]. This [some value][2] matrix can also be represented as a 1-dimension vector of [some value * 2], then converting (x, y) coordinates as y * 2 + x. So, a [8][2] matrix can also be a simple [16] vector, with [6][1] being converted to 6*2+1 = [13] saving you the trouble of a float[][][].
 

mango drank

Member
I meant you were creating an array where each place was occupied by a 2D matrix of [some value][2]. This [some value][2] matrix can also be represented as a 1-dimension vector of [some value * 2], then converting (x, y) coordinates as y * 2 + x. So, a [8][2] matrix can also be a simple [16] vector, with [6][1] being converted to 6*2+1 = [13] saving you the trouble of a float[][][].
Ah, I didn't get that. I was really just looking for basic syntax help w/ the 3D array originally. I ended up figuring that out myself just now, after going through hell trying to parse the objects in ArrayList, haha. I simplified my earlier code to just use a float[][][] by itself.

Re: vectors, I don't know anything about vectors in Java, or any other language. Are they useful for graphics in general?
 

ReyBrujo

Member
MS-600 on Thursday.

Weeeeeeee.
Good luck! (y) I should have taken 70-483 years ago but never really cared about it, and when I actually wanted to, covid suspended the tests and now it's retired :messenger_unamused:

Re: vectors, I don't know anything about vectors in Java, or any other language. Are they useful for graphics in general?
In strongly typed languages vectors or arrays are useful in any situation where you need every element to be of the same type and when you know the amount of positions you want to hold in advance.
 
Last edited:
H

hariseldon

Unconfirmed Member
Passed my exam. Got some more Azure certs to grab this quarter, but I'm getting some practical experience with that on a new client. No substitute for getting your hands dirty.

Absolutely. I suspect certs are more important these days than they used to be but the thing that got me into the business back in 2000 was concrete examples of work (I somehow blagged my way in as a designer despite not being able to draw for shit before pivoting to code). I suspect one can still get the entry-level stuff that way, and if you're good enough you can very quickly get your salary up. In my own case, I was out of the business for a few years, came back on a junior salary and tripled it in 10 years, to give an illustration of the kind of pace of wage increase that is achievable.
 
Last edited by a moderator:

Lanrutcon

Member
Absolutely. I suspect certs are more important these days than they used to be but the thing that got me into the business back in 2000 was concrete examples of work (I somehow blagged my way in as a designer despite not being able to draw for shit before pivoting to code). I suspect one can still get the entry-level stuff that way, and if you're good enough you can very quickly get your salary up. In my own case, I was out of the business for a few years, came back on a junior salary and tripled it in 10 years, to give an illustration of the kind of pace of wage increase that is achievable.

Main reason I'm chasing the certs is that our BU qualifies for more tenders if we reach certain certification thresholds. Clients ask for the sprint teams to have certain certs in a variety of disciplines. With the world doing as greeeeeat as it is atm, every advantage counts in securing contracts.
 
H

hariseldon

Unconfirmed Member
Main reason I'm chasing the certs is that our BU qualifies for more tenders if we reach certain certification thresholds. Clients ask for the sprint teams to have certain certs in a variety of disciplines. With the world doing as greeeeeat as it is atm, every advantage counts in securing contracts.

Absolutely sounds like you have a sound business case then. I picked up an MSc a few years ago (did it part-time while working full time - intellectually pretty easy but I was knackered doing it) so I'm not against qualifications, just offering an alternative route for anyone reading this thread. I'm not sure it hugely affected my salary but it probably lifted the ceiling and work paid for it so it's a good bet either way. For those without those options, the amount one can do in terms of teaching oneself is pretty decent, on the code side at least. There are some really decent courses on Udemy if videos are your thing, coding books are pretty cheap and there's a tonne of good online tutorials free out there for anyone who wants them. There have never been fewer barriers to learning, though there is the problem of knowing exactly what to learn and there are a lot more things you need to have under your belt than when I first entered this business, ie everyone expects you to know 50 different frameworks etc. That's where there is value in finding a dev to talk to who will listen to you and figure out what you actually want to do (though to be clear if you talk to 10 devs about a problem you'll get 20 different solutions - in the end you have to use a certain amount of your own judgement).
 
Last edited by a moderator:
Top Bottom