u/alex_sakuta

What is more adaptable, more words or more symbols?

I used to like Python for its abundance of english words instead of operators which makes it more readable.

However, I have often seen the common notion where people prefer symbols over keywords. Lately, some of the newer languages have added both new keywords and new symbols.

For eg: Rust using |var| semantics for callback functions. The popular defer that has existed for very long in multiple languages. C adding [[...]] for attributes

Now even though I am saying || and [[]] are new symbols added, they aren't operators, they are just replacing some brackets essentially for a different type of task.

With this context, here is my question:

What if instead of these keywords: await, async, defer, try, catch, weren't keywords, they were replaced by some operator?

There are two cases in my mind, either replace the keywords with a single operator (@ could replace await), annotating the data, or, use a combination of operators (-! could be used to mark a function that can produce an error).

I have the concern, that it may look too ugly because there are a bunch of operators, and in the case of combination of operators, two operators together, changing the meaning of the single operator is also weird.

But, I still wanted to ask, seeing how more experienced people view this situation.

Also, what if, both the operator and the keyword is present? Would that just be wrong because now there are two ways to do the same thing?

reddit.com
u/alex_sakuta — 3 days ago

Is there a way to automatically get the types package for any js package?

I was recently going through npmx and saw how it tells you the type information or the fact that you need an additional package for types for the package that you are about to install.

I was thinking, can there be a tool that can just detect that you are using TS so you'll need the types package and install it for you?

Would such a tool need hardcoding manually the various types packages associated with the JS packages or maybe is there some shortcut?

reddit.com
u/alex_sakuta — 5 days ago

I need someone to teach programming to

I have been very annoyed with how programming languages are taught.

If you learn C first, you only learn basic programming but if you learn JavaScript you are immediately pushed into learning asynchronous programming.

I always thought there must be some methodology that leads to understanding programming correctly and not just the language.

I have been formulating such a method and I want a volunteer.

It would be nice if you are someone who has low to no experience. But if you are someone with a lot of experience, you are a good candidate too because you can definitely poke more holes into my methodology.

If anyone is interested, please reply.

PS: I basically want to test how effective my strategy is and I believe why not help someone with it. Currently, the language that I will work with is C to test this since it is like the most basic modern language.

reddit.com
u/alex_sakuta — 9 days ago

I need someone to teach programming to

I have been very annoyed with how programming languages are taught.

If you learn C first, you only learn basic programming but if you learn JavaScript you are immediately pushed into learning asynchronous programming.

I always thought there must be some methodology that leads to understanding programming correctly and not just the language.

I have been formulating such a method and I want a volunteer.

It would be nice if you are someone who has low to no experience. But if you are someone with a lot of experience, you are a good candidate too because you can definitely poke more holes into my methodology.

If anyone is interested, please reply.


EDIT:

This is how the initial flow that I imagined will go:

printf in C is comprised of 4 main programming concepts: Functions, Error Handling, Variadic Arguments and I/O. Most people don't touch these concepts.

So, how will I separate? Instead of:

  • Data Types
  • Pointers
  • Arrays
  • Loops, etc

My methodology:

  • Data: numbers(boolean, integer, decimals, characters, pointers), objects(arrays, struct).
  • Scope
  • Repetition: Loops, functions
  • etc.

I will write articles for these concepts, you can study them, then in the group, if you have any doubts, we can have discussions and even VCs.

This is my initial idea, I may switch to just making videos instead of articles or alongside articles and then continuing the rest as it is.


PS: I basically want to test how effective my strategy is and I believe why not help someone with it. Currently, the language that I will work with is C to test this since it is like the most basic modern language.

reddit.com
u/alex_sakuta — 9 days ago

What do you do when you have to run LeetCode code locally?

I am sure many of you experience this situation where you want to run the LeetCode question locally for debugging purposes. I hope I am not the only one.

Now, it is not as simple as create a file and run your function because you may wanna run against multiple test cases which would require reading from a file and then inputting and outputting in a decorated manner.

You may also want to visualise data and require debugger or just simple print statements but LeetCode has a terrible stdout and only premium users get a debugger.

Or you may simply require the comfort of working a solution in your own personal code editor as that's where you can write the fastest with all your shortcuts and extensions/plugins baked in which LeetCode simply lacks.

For eg: LeetCode has a broken implementation vim motions and it's very annoying for me.

There are more conveniences that can be added to this process to make it even more comfortable than actually working on LeetCode.

One such convenience is that for people using C++ or other compiled languages, having a build environment so that they can program properly and receive better error messages as well.

I am thinking of creating a template repository for this in which you can just create a new file for coding and one for testcases and write your solution and work on the problem locally 100%.

  • Does such a thing already exist?
  • Does this sound useful to you?
  • Is there an extension solution that already exists for all editors which is maybe a better solution?
reddit.com
u/alex_sakuta — 11 days ago

I am a programmer with very little experience in C and currently my style of gaining experience is just developing the projects that I developed in other languages in C. Because of such nature of my projects I am often looking at implementing dynamic data structures in C.

Now I seem to know of 2 tricks of implementing a dynamic data structure in C:

struct string {
    size_t cap;
    size_t len;
    char *buff;
};

Then use this as struct string everywhere.

OR

struct string {
    size_t cap;
    size_t len;
    char *buff;
};

Then assign the pointer to buff to the pointer to the dynamically allocated variable.

I keep going back and forth on which is better with these pros and cons in mind:

  • The first approach is simple and allows for better type checking and all functions in the codebase would tell you if they are developed specifically for the struct string. The second approach would require the creator to be mindful of the fact that whenever they assign new memory they must carry the rest of the variables and no type checking safety is provided by the compiler as it just sees char *.
  • The first approach requires long syntax to refer to an element obj.buff[index]. The second approach requires nothing as such and has the simple syntax str[index].
  • The first approach because of the previous mentioned con, becomes hectic when we are dealing with a 2d data structure. The second approach doesn't have this issue.
  • Both approaches require some custom macros and function definitions in a codebase to work properly.
  • For both approaches you have to follow them throughout the codebase and stay consistent. However, the first approach does allow for some flexibility in this rule because as mentioned earlier we get type checking and would stay safe from using functions incorrectly.

What do people actually do? Is choosing the second approach just a shiny object syndrome?

Please, let me know your experiences.

reddit.com
u/alex_sakuta — 23 days ago

In my quest of studying about programming languages, I have often found this particular opinion, intriguing.

Package managers are a bad thing.

Now, I know the reason and with some recent news this one really becomes very simple to agree statement.

However, as true as it may be, there is the reality that sometimes we just need packages to perform certain tasks as it would be mundane to do it by ourselves.

JavaScript has packages like: React, Next, Vite, Express, etc.

Python has packages like: Requests, Flask, etc.

You know the rest.

Even the compiled languages such as Golang and Rust have commonly used packages.

Now, one simple solution in my opinion and others has always been to check that the package has been released for some period of time.

I seem to have heard somewhere that pnpm has a way to check a package's info before installing and also a way to setup a check for how old the package's latest release is before allowing updates.

I was wondering if there is one tool that can for all languages, check, whether the package is secure by doing two things:

  1. Check how long since the package's latest version has been reelased.

  2. Do a quick web search to report any issues about the package.

reddit.com
u/alex_sakuta — 27 days ago