/dpt/ - Daily Programming Thread

Pythons are lovely snakes, but terrible programming languages.

What do you hold with, Sup Forums?

Old thread:

Other urls found in this thread:

en.wikipedia.org/wiki/Criticism_of_Java
m.youtube.com/watch?v=iSmkqocn0oQ
en.wikipedia.org/wiki/Criticism_of_C++
docs.spring.io/spring/docs/current/javadoc-api/org/springframework/aop/framework/AbstractSingletonProxyFactoryBean.html,
anyforums.com/
twitter.com/SFWRedditVideos

my hands

Your hand.

>Pythons are lovely snakes, but terrible programming languages.
At least it does not pretend to be fast.

Continuing my full C modular synthesis program, as always. I'm working on making any component able to modulate itself right now. Like an oscillator's rate of oscillation can oscillate according to the oscillator's own waveform.

nice

Why is there so much hype about vs code? It's literally atom but a bit less slow

>a bit
It's far better than atom.
The only thing it needs is a de-bloating of NPM.

>far better

atom: 2
vs code: 3

emacs: 8
vim: 9

Unmatched code completion/intellisense, very user friendly UI, great extensions, etc. The main reason for me to switch from Sublime was intellisense.

>a bit less slow
You have never used Atom then. It's fucking slow.

???

>closed source benchmark
kill your self

I've upgrade my Ubuntu version (and I assume g++ in the process) and now my code doesn't compile anymore.

auto registeredListener = it->target();
gives me the following error now (it used to work without problems earlier):
In file included from /usr/include/c++/7/functional:58:0,
from MessageBus.h:6,
from MessageBus.cpp:1:
/usr/include/c++/7/bits/std_function.h: In instantiation of ‘_Functor* std::function::target() [with _Functor = MyNamespace::Message*(MyNamespace::Message*); _Res = MyNamespace::Message*; _ArgTypes = {MyNamespace::Message*}]’:
MessageBus.cpp:25:70: required from here
/usr/include/c++/7/bits/std_function.h:733:9: error: invalid use of const_cast with type ‘MyNamespace::Message* (*)(MyNamespace::Message*)’, which is a pointer or reference to a function type
return const_cast(__func);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~


What has changed?

this

I tried Atom IDE recently. It was so slow that it was basically unusable. VS Code feels 1000x faster in comparison. Not saying VS Code is very fast overall but it beats the crap out of Atom (like pretty much every other text editor).

I've been sorting through and cleaning up some older scripts I've written and found this cutie pie. I'll now rewrite it in all the languages I know and perhaps learn some new along the way.

Newfag to programming here

please explain in simple terms why woud anyone need to use
>pointers
>classes

>pointers
manipulating memory, in some languages they're necessary for references

>classes
completely unnecessary

>pointers
These differ a lot between different languages, so it depends.
>classes
The cult of OOP tells you that these are for encapsulation and polymorphism.

just use structs

>These differ a lot between different languages, so it depends.
let's say in this case it's C++?

Also, can anybody explain why OOP is considered hot garbage?

in C++ you use pointers to indirectly store things, or as references (though C++ has its own reference system)

is this gonna crash? i'm reading files, i need to cast them to int32* but they might not always fit perfectly.

uint8_t file = new uint8_t[10];
uint32_t * ui32arr = reinterpret_cast(file)


am i ok if i don't touch the bytes that don't fit?

In C++ pointers are necessary for arrays. But they're also used generally for referring to things.

Most people think OOP means Java, and Java sucks. But then again so does OOP in C++.

just use python, bro

cute snek

>new uint8_t[10];
Why new? Just allocate on the stack or use unique_ptr, if you really need this on the heap.

What is wrong with OOP?

dude strict aliasing lmao

use unions

daily reminder that Javascript is python with curly braces.

these files come from outside, they might be several hundred mb in size and this function is not responsible for the memory so i don't have to use smart pointers. file is just an example to illustrate that there'll be 2 bytes which don't fit.

But javascript is weakly typed

That's what I'd like to know. I see the meme of OOP sucking a lot here, often mentioned in the same meme as Java and Indians.

atleast you can't do 1 + '1'

I'm the synthesizer guy ()
I have a separate struct for each musical voice, which allows polyphonic playback at different pitches, velocities, etc, but those voice structs all reference the same pointer for certain values, like the waveform to play back, since that doesn't differ between voices. Meaning that if I want to change the waveform, I don't have to change the value for every voice (which would be potentially audible during live playback) but just change the waveform pointer once. The latter is an atomic operation so it's threadsafe.

Pointers can be a mess but they're very powerful and have definite practical applications.

How can I like append a string or add to a string?

Like I want to change a name if it's the same

if Name2 == Name 1 then
Name 2 = Name2("bob") + "-A"

that way Name 2 becomes bob-A, name 3 is bob--B

Ect

Something like that

Any ideas or quick solutions?

Language is Lua.

any ideas on getting to a "professional" level by yourself?
its a little hard to describe, but i feel stuck on a level thats just "guy fucking around at home".
Even something simple as html/css i havent mastered, i dont nearly know everything about it, every interaction etc.
All the tutorials and videos are just "this exists", this is how you use it maybe" and just "doing a project" works, but it feels the same. its always "oh this thing is cool, it kinda works" but its so far from completely understanding everything.

I posted yesterday, but I just thought I'd ask again.
18 y/o freshman CS/ math student here, and I was just offered my first programming job. The job requires C# and SQL but I've been a Java cuck my whole life.
Any advice?

Also I'd really like to know why everyone trashes on java

What's the point of using languages that nobody else uses? Is it elitism?

>implying that types in python aren't just a myth

C# is just MS Java. You can learn it quick.

Because Java is trash

You're probably confusing dynamic/static typing with weak/strong typing

>Using an Electron code editor.

...

dynamic strong typing is just runtime checks

we've established many times that static strong typing is superior, in terms of speed and ease of development (over the whole lifecycle), software defect rate, and performance

Mind giving some reasoning for that? That's really what we're looking for.

>we've established many times that static strong typing is superior, in terms of speed and ease of development (over the whole lifecycle), software defect rate, and performance

do you have any study backing that?

These operators man. Depending on the position of the *, it is a reference or a pointer.

There is an entire wikipedia article on the subject

en.wikipedia.org/wiki/Criticism_of_Java

It's still faster than an IDE.

yer

Hi

I need an advice on OOP.
I'm not a "classically" trained programmer. I do write a lot of code, but it's usually isolated and I don't have much experience with designing large complex systems from scratch.
So I'm designing this complicated piece of software and it really needs to be reliable and easy to debug/refactor.
Without going into too much detail I'm struggling to make a choice between the two on the pic.
The system does fairly abstract things, so the usual naive approach to designing classes and methods doesn't work. Ultimately, what the system does is modifying some environment based on input data. However the process of applying modifications is pretty complicated and it needs to be easily monitored and controlled. And I need to store the state of the process in a persistent fashion.

So instinctively my first design draft looked like the thing on the right, but now that I'm implementing it, I'm starting to doubt myself.
How do people usually solve these types of problems? I _think_ abstracting the processes should ultimately reduce the complexity of the system, but I wonder I'm going to run into some problems later in the project life cycle.

>In 2008 the U.S. DOD's Center Software Technology Support published in the "Journal of Defense Software Engineering" an article discussing the unsuitableness of Java as first learned programming language in education.

And look where we are now.

nim is good language

>look where we are now
Yes. Python and Lua being taught as first programming languages instead.

How I long for it to be Scheme and ML instead once again.

Pointers point to memory values instead of being the values instead, which can be useful for optimization. So you can use a pointer instead if the data is bigger than the memory address. Also, C passes copies of the arguments to functions, not the variables themselves, so if you want to edit a value and have it reflected outside of the function you have to use pointers. Being able to manually edit memory locations is very useful in many cases.

Classes are an OOP idea. Theya ren't terribly useful in short code snippets but are great in large codebases for things like encapsulation, basically making it so that you can edit a section of code without any other parts being affected, and code organization, and for making custom datatypes. So for example Iets say I have a number of moderately different processes, the relevant functions and data of which I'm bundling into attributes and methods in corresponding objects. By doing so I can make it so that changing one process via its object does not affect others, and keep it readable and organized, and the code is encapsulated so that changing one process does not affect the others and I can easily alter them, as would not be the case if I were reusing functions. Now, however, I have to write the code of the objects separately, which isn't good. For code reuse purposes I go and take the common methods and attributes and bundle them up into a class, from which I can declare the objects and then manually edit in the differences, or for further abstraction, encapsulation and code readability, use inheritance/polymorphism to differentiate the objects using some other classes whcih contain the process-specific code.

Only people who don't work on large projects think OOP is garbage.

dumb frogposter

Java OOP is only useful for large and complicated codebases and is unnecessary complexity for smaller projects, where OOP from other languages is still applicable. In, say, python bundling up some attributes and methods into a class and then providing an encapsulated interface via getters and setters is very useful is you don't want a headache when refactoring a section of code, since with tregards to the rest fo the codebase you just have to ensure that the getters and setters return the expected values.

>Java has an entire wikipedia page dedicated to its criticism.

why's that Hans?

Reminder: m.youtube.com/watch?v=iSmkqocn0oQ

one of our interns suggested that we rewrite our backend in javascript yesterday because he finds it difficult to keep track of two languages at once. he also asked why we've disabled force push on the company git repo and claimed he needs to be able to do it

en.wikipedia.org/wiki/Criticism_of_C++

it's not exactly an achievement.
There's in depth articles way longer than those about C"s many,many pitfalls.

Assembly should be the first programming language people are taught.

what language do cia niggers use?

Probably an in-house one for the really important stuff.

python for scripting and c/asm for meat & potato stuff

Mutable state....gross

so useless it is being adopted by some companies

that's right, it's useless even at being useless

Nothing, it's just that many people here either don't understand it and end up needlessly abstracting their code or have only really used it via using Java for a simple task.

It's highly verbose, and what's useful when you have many developers of varying skill and experience levels in a large project is much less useful when you're a guy trying to quickly implement some stuff. The language has shit like this: docs.spring.io/spring/docs/current/javadoc-api/org/springframework/aop/framework/AbstractSingletonProxyFactoryBean.html, whcih amkes it readilly apparent why epople don't like it for quickly hacking things together.

...

>Also, can anybody explain why OOP is considered hot garbage?

Nobody in here actually has to architect and develop large-scale enterprise applications.

You don't need OOP for a script that automatically sends a message to your mom, but things change when more people are involved on a larger scale

Describe his beard to us.
How many Star Wars action figures does he have on his desk?
How much did he enjoy the latest capeshit film?
What is his favorite food truck?
What are his girlfriend's pronouns?

>but things change when more people are involved on a larger scale
why does it have to?

>larger feature set than sublime
>Not as disgustingly slow and poorly optimized as atom.

i always wonder what kind of neckbeard hears copy pasta like 'pythons are lovely snakes but terrible programming languages' and just immediately accepts it and starts using that saying everytime he gets an opportunity to.

software development was in such a terrible and dire state fucking NATO had to assemble meetings on how to fix it

OOP isn't perfect, but it's proven to work and sure beats what people were doing before that

anime website

Python is shit deal with it.
Stop being a brainlet 'coder' and learn a real language.

>Describe his beard to us.
Bumfluff tache and sideburns
>How many Star Wars action figures does he have on his desk?
None
>How much did he enjoy the latest capeshit film?
What's a capeshit film?
>What is his favorite food truck?
He's obsessed with sushi, don't think you can get that from a food truck
>What are his girlfriend's pronouns?
I don't know if he even has a girlfriend tbqh

>Also, can anybody explain why OOP is considered hot garbage?
I too am interested in comprehending this meme. OOP is standard in any CS curriculum.

frog is not anime

> lovely snakes
They naturally repulse people.

And I especially hate people who have snakes and feed it mammals.

Successful marketing campaign by Sun in the 90s. Businesses now demand that students get taught "industry best practices" like Java and OOP regardless of their (lack of) academic merit

That question was answered about a million times already

On a small scale (i.e. nerds coding shit in /dpt/) it's a lot of overhead, on a larger scale (i.e. actual production systems) it's useful

I've heard people shit on java for years and I always assumed that they meant the opposite, that is only good for small hacks and not great big projects. But in my time of using it, I have found it really useful for putting together these huge frameworks, I've always been confused on that. Thanks.

What language is your backend, in?

Scala. I know there are better choices but we needed something that we could gradually replace an old Java ball of mud with

I really feel like python is so cripplingly simple that I'm glad I didn't learn it first.
Every time I write a program in python, I feel like I may as well be writing in crayon.
It feels like a language that doesn't trust you with the really complicated concepts, and even OOP feels like an after thought.

Anyone else with me on this?

Ah, I could see the complaint then.
Have there ever been any suggestions to replace it with Haskell?

Yes, everyone who was ever taught a language better than Python.

why not kotlin

>>Anyone else with me on this?
literally 3/4ths of the programming world.

People shit on it, but I really like the indentation being a part of the syntax. It forces retards to make their code look clean.

OOP allows you to group your code into self-contained, encapsulated objects which are only accessible through getter and setter functions, allowing you to change code in one are without breaking things in another, and solves the code reuse problems with such object-based implementations with inheritance and polymorphism.

kotlin a shit

I'm considering learning it, why's it shit?


Looks like Java 9 v2 to me