Programming thread

  • There is a bug with the post editor. Images pasted from other websites from your clipboard will automatically use the [img] tag instead of uploading a copy as an attachment. Please manually save the image, upload it to the site, and then insert it as a thumbnail instead if you experience this.

    Ongoing DDoS attack. kiwifarms.ru may work better for now.

AmpleApricots

kiwifarms.net
Joined
Jan 28, 2018
lua is pretty cool and speedy. What ultimately convinced me of luas speed and compactness was compiling the interpreter (with surprisingly few changes) and running it on a 7 Mhz 68k Amiga with 4 MB of RAM just fine and at good speed for that system. It just doesn't lend itself to bigger programs well. (neither the system nor the language) People will tell you it does with linters and such but don't believe their lies.

I'd also recommend looking into go. Some of the critique leveled at it is valid but I have the feeling it has a good chance to become the next big thing.(tm) (When I said that about C# in the 00s people laughed at me)

If all you ever want to do is glue code others have written together with fast and seemingly impressive results but without understanding how anything really works, you can pick python. If you actually want to learn anything that's applicable outside of that very specific scenario, don't pick python.

Also as has been said, C. Newcomers are scared of C for some reason but it's actually a very simple and utilitarian language you can at least write small programs with in no time. Absolutely no reasons to be scared of it.

If you want to write things of horrifying beauty that will run aeons until where even death may die, pick forth, now that's a language with chest hair!
 
Last edited:

Least Concern

Pretend I have a spooky avatar like everyone else
kiwifarms.net
Joined
Sep 23, 2018
Lua has no strong types, no proper classes/OOP, no curly braces ("do/end"-style block definitions instead), not even a proper regex implementation (it has its own pattern-based string-matching thing instead which is more or less useful for most situations you'd use regex for - I recall reading somewhere that adding a real regex engine would something like double the size of the codebase for the interpreter, so fair enough. The 80/20 rule is real). By all accounts I should hate it, but I don't. It just seems so… cute and in good faith. It's like the adorable puppy of shitty third-tier scripting languages. Even when it pisses on the carpet, it feels like if you get angry about it, that's more on you than the puppy.

Oh, but it's also a mutant greyhound puppy which runs much faster than it has any business to, somehow.
 

Rusty Crab

cowboy hats are crab hats
kiwifarms.net
Joined
Jun 20, 2020
Lua has no strong types, no proper classes/OOP, no curly braces ("do/end"-style block definitions instead), not even a proper regex implementation (it has its own pattern-based string-matching thing instead which is more or less useful for most situations you'd use regex for - I recall reading somewhere that adding a real regex engine would something like double the size of the codebase for the interpreter, so fair enough. The 80/20 rule is real). By all accounts I should hate it, but I don't. It just seems so… cute and in good faith. It's like the adorable puppy of shitty third-tier scripting languages. Even when it pisses on the carpet, it feels like if you get angry about it, that's more on you than the puppy.

Oh, but it's also a mutant greyhound puppy which runs much faster than it has any business to, somehow.
lua is great but people misuse it horribly. It's so small and has so little overhead that you don't have to feel bad about spinning up an entire VM to read a single file. It's a utility.

The creators literally describe it as "a configuration language". That is, you're supposed to make config files with it that would otherwise be too complicated to do in other formats. The conclusion, of course, then is that you should write an entire million line application in it.
 

Unassuming Local Guy

Friendly and affectionate
kiwifarms.net
Joined
Jun 13, 2020
Also as has been said, C. Newcomers are scared of C for some reason but it's actually a very simple and utilitarian language you can at least write small programs with in no time. Absolutely no reasons to be scared of it.
The vast majority of people who want to program as a hobby want to learn one language, for obvious reasons. Today, that language is basically always going to be either Java (thanks to the dominance of Android) or Python (because it's easy). C is so low level it's a step away from Assembly, and almost nobody needs or wants that level of control and optimization any more. Very few hobby programmers need anything lower than Java or Python, and those that do would do fine with C++ or C#.

C has basically become a legacy language aside from the singular application of microprocessor programming. It's replaced assembly almost entirely and become the worldwide standard in that field, so it still maintains a very healthy demand, but if you learn C that's what you're going to be doing. That or writing OS kernels, but getting paid to write kernels is even more niche and requires even more of a specific type of personality.
 

stares at error messages

kiwifarms.net
Joined
Dec 7, 2020
The vast majority of people who want to program as a hobby want to learn one language, for obvious reasons. Today, that language is basically always going to be either Java (thanks to the dominance of Android) or Python (because it's easy). C is so low level it's a step away from Assembly, and almost nobody needs or wants that level of control and optimization any more. Very few hobby programmers need anything lower than Java or Python, and those that do would do fine with C++ or C#.

C has basically become a legacy language aside from the singular application of microprocessor programming. It's replaced assembly almost entirely and become the worldwide standard in that field, so it still maintains a very healthy demand, but if you learn C that's what you're going to be doing. That or writing OS kernels, but getting paid to write kernels is even more niche and requires even more of a specific type of personality.
I want to learn programming as a hobby but I don't want to become tranny. What should I do?
Picking a language can be like going grocery shopping. Every thing is the same, but you still have trade-offs. Python3 is a great option for beginners. Do note that each whole number release of Python is different from the last and only has few similarities.

JavaScript is a mess. If you're not doing websites I'd stay away from it. The problem is that everything is done at unpredictable times relative to other languages. With other languages you can imagine what the programing will being doing at a point in execution. JavaScript has that less because most Node functions want to take an async callback or in the browser the event loop is not continuous and will be paused at unknown times depending on the browser's choice to budget resource.

If you're doing C and C++ stuff you'll need to learn about linking. That's not that complicated, you just add arguments to the compiler command to include certain libraries.

Java has 'class'es and 'static main's, so if you can find an example of a Hello World program to get started with you can skip that part of the boiler plate to get up and running. Also, the name of the java file has to mimic the name of 'public class' for that file. Your are allow one public class per file and the file's name has to be the same as the class; messes up noobies all the time. Python3 doesn't have these problems, so it's easier to get up and running with for the experienced.

Game modding or silly little file IO batch/script with very specific application only for me. Webpage is nice too but I have zero creativity.
Lua has an IO library and you can do some basic scripting with it too. Really it's meant to be easily integrated into C and C++ (probably other languages too). Websites are really very different from other kinds of programming. Short of having experience with a language that may bias you as to what frameworks you might want to use, there are not many transferable skills form writing a simple shell prompt program and figuring-out how you are meant to slop together HTML, CSS, and JavaScirpt.

  1. Tutorial Point can be good. Look for the 'Quick Guide' in the section menu; it's the entire course in one page, so you don't have to jump around.
  2. Stack Overflow can be less good; you have to hunt around for what would work best for your situation. The out of the box responses are usually, 'You should go use this library (that you aren't using already and don't really need and there is a perfectly good way to do it without add more work for your self)'. Really not that helpful and the attitudes of users on Overflow is a crap-shoot.
  3. <https://www.rosettacode.org/> is good, but you actually have to know what problem you want and then look for language examples that are right for you. Sometimes the examples are not so helpful or well written.
 

Considered HARMful

kiwifarms.net
Joined
Dec 17, 2019
Today, that language is basically always going to be either Java (thanks to the dominance of Android) or Python (because it's easy).
Hard disagree on the causality of "Java because Android". Google is pushing Kotlin hard, they basically actively discourage using Java. Of course, I don't discount the existing body of code and StackOverflow threads having Java still...

C is so low level it's a step away from Assembly, and almost nobody needs or wants that level of control and optimization any more.
This is an oft repeated overstatement (or maybe oversimplification?) of C.
 

Unassuming Local Guy

Friendly and affectionate
kiwifarms.net
Joined
Jun 13, 2020
Hard disagree on the causality of "Java because Android". Google is pushing Kotlin hard, they basically actively discourage using Java. Of course, I don't discount the existing body of code and StackOverflow threads having Java still...


This is an oft repeated overstatement (or maybe oversimplification?) of C.
Kotlin is basically Java but better, and yes, Google has all but forsaken Java, but nearly all Android programming is still done in Java, augmented by the fact that it's also an old language with numerous libraries and fantastic portability. Not to mention documentation. Even the most popular Kotlin libraries have dogshit documentation and nearly no community support.

Yes, Kotlin can be directly converted to and from Java at will, but that actually hurts it in the long run. Anyone who knows Java will just write Java and then automatically convert it, learning just enough Kotlin to fix any errors that arise in the process. Why bother learning the language when it's basically just another syntax of Java?

I personally am learning it, and in many ways it is much nicer to work with than Java, but that is what people think. Kotlin currently enjoys the same popularity as D and Ada, two languages most non professionals have never even heard of, and that's not likely to change significantly any time soon. At least not while the current batch of programmers who've been using Java for the past 20 years are still around.
 

Shoggoth

kiwifarms.net
Joined
Aug 9, 2019
Anybody else ever been in the situation where they were only person able to understand and keep a super critical undocumented legacy system running, knowing that if you left it would instantly catch on fire and implode, while your dumb coworkers wouldn't able to fix it, and if they hired someone else they wouldn't be able to understand it?

The legacy codebase is the ripest shit garbage humanly imaginable, but they're so locked in they can't replace or refresh it. Their dependency on me makes up for how shitty it is, since they and I both know what a catastrophe will occur when I leave this job, so they've been kissing my ass. Sometimes even shitty situations can have upsides, lol.
Leave now. You'll never get promoted or something interesting to do because they rely on you to maintain this piece of trash
 

Shoggoth

kiwifarms.net
Joined
Aug 9, 2019
Rx (Reactive) programming is probably one of the best libraries and design pattern I’ve ever used to develop. Observables in RxJS are so much better than Promises and it kills me every time i see a Promise wrapping an observable in production code. Nearly everything in Angular is an Observable and yet the other devs fight against it with JS async/await instead of learning the design pattern. It’s extremely clean to use one flat RxJS chain to accomplish an operation instead of 4 Promises nested inside each other.
You know why I hate Rx? Because the idea is good but not generic. It doesn't play nice with everything else. At least in a language like Haskell, a stream would be a functor so you could map over it just like everything else, but no, in Rx you have to reinvent the language and melt the brain of whoever is using it.
Sorry for double post
 

John Furrman

they should have sent a poet
True & Honest Fan
kiwifarms.net
Joined
Aug 20, 2014
You know why I hate Rx? Because the idea is good but not generic. It doesn't play nice with everything else. At least in a language like Haskell, a stream would be a functor so you could map over it just like everything else, but no, in Rx you have to reinvent the language and melt the brain of whoever is using it.
Sorry for double post
I suppose it depends a lot on the application. For languages that don’t have stream like objects natively, i can see the argument for using Rx. Javascript for sure gets a lot of lift from Rx and the loose typing makes things work easier together. But I am not familiar with haskal. What is a functor? What is the Rx equivalent? Do the strong types make it difficult?
 

Shoggoth

kiwifarms.net
Joined
Aug 9, 2019
I suppose it depends a lot on the application. For languages that don’t have stream like objects natively, i can see the argument for using Rx. Javascript for sure gets a lot of lift from Rx and the loose typing makes things work easier together. But I am not familiar with haskal. What is a functor? What is the Rx equivalent? Do the strong types make it difficult?
It's about implementing things in terms such that you could operate over them generically. A functor is something you can map over. A list, stream and promise are all functors. If they all implemented a functor interface, you could map over them in a manner independent of their implementation. Just consider the atrocity of flamap or mapcat when you have a stream of promises or maybes. This shit should just have a generic behavior to "un-nest" it. You can't reduce over them generically, either.
Rx is nice, but it's not generic, which is gross.
 

Cold Root Beer

Refreshing
kiwifarms.net
Joined
Jul 8, 2020
I would use this heavily to leverage either a pay raise or getting technical lead if you can. If you are the only person capable of maintaining it then you are by definition a single point of failure for the company.

Should be able to squeeze a slightly higher salary if you wanted to friend.

Appreciate the advice, but rather than salary, I'm using my leverage in other ways. There's no way I'm planning on staying with this place long term, so I'm maximizing my personal time.

The position is still full-remote, and I use their reliance on me to minimize the amount of time I spend actually working each week. I probably only do about 1-2 hours of actual development a week, 0-6 (usually on the lower end of that scale) hours of "Oh fuark, Cold Root Beer! Our terrible buggy system has gone completely down again! Fix it ploz!", and about 3-6 hours worth of meetings.

So, I'm getting salaried for 40 hours, but only really spending a fraction of that time actually doing work for them. The fact that I'm the only person that could even possibly fix the system in those 0-6 hours when the system randomly implodes itself gives me the leverage that they don't care about me not really doing anything else.

So, I've been using all this extra time to pursue further education that will result in an accreditation that will dramatically improve my career/life options, and likely lead to me being able to get jobs 2-3x my current salary (that I wouldn't otherwise be able to).

So, basically I'm keeping the lights on for their terrible legacy monster until I can springboard away into the big money.

I'm very much in the same boat. I've tried to follow the boyscout rule of improving it as I go along, but it was a 10 year effort by about 40 people resulting in a million lines of incomprehensible (but critical) gibberish. I'm convinced that dealing with it over so many years has given me some kind of brain damage.
I've always just made it very clear to the BAs, POs, and Managers about what a fuckin' mess they have on their hands and have handed me, and every time they ask for changes, I make it clear that the ball of yarn is such that any little changes are difficult, any 'bug' fixes take an un-estimable amount of time to investigate the cause, and any 'changes' they really require will take intensive UAT testing on their part.

By making the Business do the bulk of the testing (and given how painful the system is to use), I've trained them to wince at the idea of poking the beast as much as I do whenever I have to wrestle with the legacy jank.

Lol learn Cobol and go into the financial industry. It's miserable work, but you'll never, ever be out of work.
The Financial sector and the Government sector has the highest amount of catch-22 "Fix this legacy hellscape, but you're not allowed to rebuild and redesign the system in the way that's required to fix this legacy hellscape".

Leave now. You'll never get promoted or something interesting to do because they rely on you to maintain this piece of trash
I know, I knew what a shit deal it was when I saw the steaming pile codebase I was foisted when I joined, but the work-life balance was so good from the start that I decided to just to minimize the amount of time I had to actually work, and instead basically use this as a full-time job that I have to only put in part-time hours, and use the extra time to privately do some self-improvement pursuits that will dramatically improve my career prospects and salary.

They're going to be in for a world of hurt when I finish my education in the next <6 months and jump ship, this system is going to explode and none of my co-workers have the brain cells to fix it.
 

John Furrman

they should have sent a poet
True & Honest Fan
kiwifarms.net
Joined
Aug 20, 2014
It's about implementing things in terms such that you could operate over them generically. A functor is something you can map over. A list, stream and promise are all functors. If they all implemented a functor interface, you could map over them in a manner independent of their implementation. Just consider the atrocity of flamap or mapcat when you have a stream of promises or maybes. This shit should just have a generic behavior to "un-nest" it. You can't reduce over them generically, either.
Rx is nice, but it's not generic, which is gross.
Ah, I see. Thanks for explaining.

I don't think I've struggled too much with higher order RxJS Observables, switchMap has always taken care of them in my use cases. But I have to admit with multiple sources that each return higher order Observables, it take more than some mental effort to resolve the inner observables in the desired fashion. I think I avoided the generic-less issue since Javascript doesn't have generics, so I'm having some trouble understanding the problems it creates in strong typed languages.
 

Shoggoth

kiwifarms.net
Joined
Aug 9, 2019
I know, I knew what a shit deal it was when I saw the steaming pile codebase I was foisted when I joined, but the work-life balance was so good from the start that I decided to just to minimize the amount of time I had to actually work, and instead basically use this as a full-time job that I have to only put in part-time hours, and use the extra time to privately do some self-improvement pursuits that will dramatically improve my career prospects and salary.
Comfort and convenience are important factors. Absolutely take advantage of the situation if you can, just don't be afraid to jump ship when the time comes.
I don't think I've struggled too much with higher order RxJS Observables, switchMap has always taken care of them in my use cases. But I have to admit with multiple sources that each return higher order Observables, it take more than some mental effort to resolve the inner observables in the desired fashion. I think I avoided the generic-less issue since Javascript doesn't have generics, so I'm having some trouble understanding the problems it creates in strong typed languages.
It's an issue in dynamically typed languages, too, because they still have types, they're just "resolved" at run time. I'm not saying the rx abstraction is bad or useless, I'm complaining the implementations put up walls between themselves and everything else. Even in JS, you should be able to .map() over everything. That includes observables, lists, arrays, strings, promises. Those are types. So what if they're dynamic? The implementation of the language does not support this.
I recommend reading some of the original papers about streams and operators fusion, there's a lot of gems there.
 

ConcernedAnon

Concerned and hopefully anonymous
kiwifarms.net
Joined
Mar 21, 2017
Ah, I see. Thanks for explaining.

I don't think I've struggled too much with higher order RxJS Observables, switchMap has always taken care of them in my use cases. But I have to admit with multiple sources that each return higher order Observables, it take more than some mental effort to resolve the inner observables in the desired fashion. I think I avoided the generic-less issue since Javascript doesn't have generics, so I'm having some trouble understanding the problems it creates in strong typed languages.
It's not just about generics as in <T>, rather it's about having a common interface that allows for a function to operate over multiple data types seamlessly. C# example; there is no common "IVectorSpace" interface type in C#, and it is impossible to access operators in generic code, thus it is impossible to write a generic Bezier function at least without resorting to reflection.
C#:
public static (float a, float b, float c, float d) BezFactors(float x) {
    var oneMinX = 1-x;
    var xSqr = x * x;
    var oneMinXSqr = oneMinX*oneMinX;
    return (oneMinXSqr*oneMinX, 3*oneMinXSqr*x, 3*oneMinX*xSqr, xSqr*x);
}

public static float Bez(float x, float a, float b, float c, float d) {
    var (af, bf, cf, df) = BezFactors(x);
    return af*a + bf*b + cf*c + df*d;
}

public static Vec3 Bez(float x, Vec3 a, Vec3 b, Vec3 c, Vec3 d) {
    var (af, bf, cf, df) = BezFactors(x);
    return af*a + bf*b + cf*c + df*d;
}

//... One for each type you want to interpolate 😩




I finished writing and testing a concurrent skip list type yesterday, mercifully the main issues were deadlock related and were relatively diagnosable, if there'd been any structural corruption it would have been a nightmare. Unfortunately this is just the warm up, because what I really need is a concurrent N-N map type so my next task is making a 2d concurrent skip list 😩

It's doable, basically imagine a singly linked list but each node has two next pointers; such a structure has a lot of desirable properties, it's an n-n map, it can be traversed concurrently, and it can be extended into a 2d skip list to get log(n) complexity for all operations. Still, it's going to be hell to visualize and debug.
 
Last edited:

Leotardo DaVinci

Clothes are meant to be worn!
kiwifarms.net
Joined
Nov 28, 2018
Appreciate the advice, but rather than salary, I'm using my leverage in other ways. There's no way I'm planning on staying with this place long term, so I'm maximizing my personal time.
That's another way of gaining somehow. You doing that should inspire higher ups to actually get people to understand the legacy code so you can do other shit.
So, basically I'm keeping the lights on for their terrible legacy monster until I can springboard away into the big money.
This is a great thing. If you put it on your salary that you were the sole reason that their legacy code was operational means that they will probably value you incredibly well.
 

Shoggoth

kiwifarms.net
Joined
Aug 9, 2019
I finished writing and testing a concurrent skip list type yesterday, mercifully the main issues were deadlock related and were relatively diagnosable, if there'd been any structural corruption it would have been a nightmare. Unfortunately this is just the warm up, because what I really need is a concurrent N-N map type so my next task is making a 2d concurrent skip list 😩

It's doable, basically imagine a singly linked list but each node has two next pointers; such a structure has a lot of desirable properties, it's an n-n map, it can be traversed concurrently, and it can be extended into a 2d skip list to get log(n) complexity for all operations. Still, it's going to be hell to visualize and debug.
Can I ask why? What access pattern are you trying to implement here? Can't you solve it some other way, such as optimistic concurrency and immutable data structures?
ex, the entire data structure is immutable, behind a managed ref, each bin is also immutable behind a managed ref, reads are "free", inserts require some STM and then you transact an update to the bin and the head.
 

Some Curious Person

kiwifarms.net
Joined
Dec 2, 2020
Ok sers, if you really want to improve your coding skills you must watch my brother Ranjeesh videos. He will make you into jeff bezos master code guru.